Skip to content

Commit

Permalink
Add visibilitychange event to the set of events tracked for triggerin…
Browse files Browse the repository at this point in the history
…g page unload #1599
  • Loading branch information
MSNev committed Jul 1, 2021
1 parent 21dea6a commit b2e666d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion AISKU/src/Initialization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ export class Initialization implements IApplicationInsights {
let added = addEventHandler('beforeunload', performHousekeeping);
added = addEventHandler('unload', performHousekeeping) || added;
added = addEventHandler('pagehide', performHousekeeping) || added;
added = addEventHandler('visibilitychange', performHousekeeping) || added;

// A reactNative app may not have a window and therefore the beforeunload/pagehide events -- so don't
// log the failure in this case
Expand All @@ -509,10 +510,11 @@ export class Initialization implements IApplicationInsights {
}
}

// We also need to hook the pagehide event as not all versions of Safari support load/unload events.
// We also need to hook the pagehide and visibilitychange events as not all versions of Safari support load/unload events.
if (!appInsightsInstance.appInsights.config.disableFlushOnUnload) {
// Not adding any telemetry as pagehide as it's not supported on all browsers
addEventHandler('pagehide', performHousekeeping);
addEventHandler('visibilitychange', performHousekeeping);
}
}
}
Expand Down

0 comments on commit b2e666d

Please sign in to comment.