Skip to content

Commit 82c90f1

Browse files
committed
refactor(analytics): Add warning in the code
Adding a warning in the code so no one can turn the gtag function into an arrow function. PR angular#2594
1 parent 1608676 commit 82c90f1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/analytics/analytics.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ export class AngularFireAnalytics {
6666
if (!analyticsInitialized) {
6767
if (isPlatformBrowser(platformId)) {
6868
window[DATA_LAYER_NAME] = window[DATA_LAYER_NAME] || [];
69+
/**
70+
* According to the gtag documentation, this function that defines a custom datalayer cannot be
71+
* an arrow function because 'arguments' is not an array, it is actually an object that behaves
72+
* like an array and contains more information besides indexes. Transform into arrow Funcion
73+
* created issue #2505 causing the analytics to no longer send data to the console.
74+
*/
6975
// tslint:disable-next-line: only-arrow-functions
7076
gtag = (window[GTAG_FUNCTION_NAME] as any) || (function(..._args: any[]) {
7177
(window[DATA_LAYER_NAME] as any).push(arguments);

0 commit comments

Comments
 (0)