none
AI Logging Fails in Firefox if Navigation Occurs Immediately After RRS feed

  • Question

  • Hi,

    I'm having a problem in Firefox (not IE or Chrome) where AI logging fails if the page is refreshed or another page is loaded too quickly after the AI logging event is called. Here's a test I ran which illustrates the problem:

    1. I opened the Firefox console and entered 'appInsights.trackEvent("testing");'

    2. I quickly refreshed the page (or navigated elsewhere).

    3. The console showed an error, "Failed to send telemetry:" at ai.0.js:1:1252 (a minified script). The "testing" event never shows up in my log in Azure.

    If I wait at least 10-15 seconds before executing step 2, no error is shown, and the "testing" event does show up in my log. This is an issue for me since I want logging to occur when users click on certain links. However, when the user clicks on a link with telemetry in Firefox, the error shows up and logging does not occur since it needs those 10-15 seconds in order to work before the page is redirected elsewhere.

    Has anyone else seen this problem, and/or does anyone have any advice on how to go about solving it?

    Thanks,

    SJ

    Friday, November 20, 2015 5:32 PM

Answers

  • AppInsights JS SDK doesn’t send custom events to the server right away. It collects them in a buffer and sends them after 15 seconds. You can change the delay by setting ‘maxBatchIntervalin your snippet (right below the ‘instrumentationKey’). This behavior is common for all browsers, not only for Firefox. You can trigger the send event by calling appInsights.flush(). This will send track events immediately.

    If you want to track the click event, there might not be enough time to send the event since the browser is already navigating to another page. The other option is to track a click event on the target page. You can achieve this by adding a custom parameter to the URL. This parameter will say which link was clicked – e.g. example.com?clicked=Link123.

    Monday, November 23, 2015 5:49 PM