Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/analytics/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ export class AngularFireAnalytics {

if (!analyticsInitialized) {
if (isPlatformBrowser(platformId)) {
gtag = (window[GTAG_FUNCTION_NAME] as any) || ((...args: any[]) => {
(window[DATA_LAYER_NAME] as any).push(args);
});
window[DATA_LAYER_NAME] = window[DATA_LAYER_NAME] || [];
// tslint:disable-next-line: only-arrow-functions
gtag = (window[GTAG_FUNCTION_NAME] as any) || (function(..._args: any[]) {
(window[DATA_LAYER_NAME] as any).push(arguments);
});
Comment on lines +69 to +72
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We really should have a comment in here that warns developers/contributors to making this an arrow function causes GA to break completely.

In the current state, it's likely that someone will come in and "fix" this breaking GA again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I can make and submit another PR when I have free time

analyticsInitialized = zone.runOutsideAngular(() =>
new Promise(resolve => {
window[GTAG_FUNCTION_NAME] = (...args: any[]) => {
Expand Down