Skip to content

Commit

Permalink
Fix: edge case where the navigation entry is not present (#2137)
Browse files Browse the repository at this point in the history
  • Loading branch information
MSNev committed Aug 22, 2023
1 parent 8f53f2d commit 45b91f7
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,11 @@ export class AnalyticsPlugin extends BaseTelemetryPlugin implements IAppInsights
let perf = getPerformance();
// Access the performance timing object
const navigationEntries = (perf && perf.getEntriesByType && perf.getEntriesByType("navigation"));
if (navigationEntries) {

// Edge Case the navigation Entries may return an empty array and the timeOrigin is not supported on IE
if (navigationEntries && navigationEntries[0] && !isUndefined(perf.timeOrigin)) {
// Get the value of loadEventStart
const navigationEntry = navigationEntries[0] as PerformanceNavigationTiming;
const loadEventStart = navigationEntry.loadEventStart;
const loadEventStart = (navigationEntries[0] as PerformanceNavigationTiming).loadEventStart;
pageView.startTime = new Date(perf.timeOrigin + loadEventStart);
} else {
// calculate the start time manually
Expand Down

0 comments on commit 45b91f7

Please sign in to comment.