Skip to content

Commit

Permalink
fix: blank page issue if google analytics blocked (openedx#234)
Browse files Browse the repository at this point in the history
This fix is added to handle Google annalytics case which is injected
by the segment.min.js.
  • Loading branch information
waheedahmed authored Nov 2, 2021
1 parent 164681d commit 78d3f69
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/analytics/SegmentAnalyticsService.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,18 @@ class SegmentAnalyticsService {
resolve();
});

// this is added to handle a specific use-case where if a user has blocked the segment
// domain in their browser, this promise does not get resolved and user see a blank
// this is added to handle a specific use-case where if a user has blocked the analytics
// tools in their browser, this promise does not get resolved and user sees a blank
// page. Dispatching this event in script.onerror callback in analytics.load.
document.addEventListener('segmentFailed', resolve);
// This is added to handle the google analytics blocked case which is injected into
// the DOM by segment.min.js.
setTimeout(() => {
if (!global.ga || !global.ga.create) {
this.segmentInitialized = false;
resolve();
}
}, 2000);
});
}

Expand Down

0 comments on commit 78d3f69

Please sign in to comment.