From 289bb13568d17408f74d4de148e17b4d848924db Mon Sep 17 00:00:00 2001 From: Gery Hirschfeld Date: Thu, 22 Aug 2024 14:27:33 +0200 Subject: [PATCH 1/2] feat(): ga can be disabled with local storage key ga_debug_mode --- package-lock.json | 5 +++++ src/google-tag-manager.ts | 13 +++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 005f844..49609ff 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9129,6 +9129,11 @@ "safer-buffer": "^2.0.2", "tweetnacl": "~0.14.0" }, + "bin": { + "sshpk-conv": "bin/sshpk-conv", + "sshpk-sign": "bin/sshpk-sign", + "sshpk-verify": "bin/sshpk-verify" + }, "engines": { "node": ">=0.10.0" } diff --git a/src/google-tag-manager.ts b/src/google-tag-manager.ts index fa6b2c5..2d79e2e 100644 --- a/src/google-tag-manager.ts +++ b/src/google-tag-manager.ts @@ -11,7 +11,8 @@ export class BalGoogleTagManager { applicationName: string; public isEnabled(): boolean { - return (window as any)[DATA_LAYER] != null; + const win = window + return win && ((win as any)[DATA_LAYER] != null || win.localStorage.getItem('ga_debug_mode') === 'true'); } public load(settings: GtmSettings): void { @@ -31,11 +32,11 @@ export class BalGoogleTagManager { public sendClickEvent(label: string): void { if (label) { this.googleAnalyticsSendEvent({ - event: VIRTUAL_FUNNEL_CLICK, - VirtualClickCategory: VIRTUAL_FUNNEL_CLICK, - VirtualClickAction: this.applicationName, - VirtualClickLabel: label - }); + event: VIRTUAL_FUNNEL_CLICK, + VirtualClickCategory: VIRTUAL_FUNNEL_CLICK, + VirtualClickAction: this.applicationName, + VirtualClickLabel: label + }); } }; From 5ce1463aba0fea054f71fc6f7bed043abbad3e76 Mon Sep 17 00:00:00 2001 From: Gery Hirschfeld Date: Thu, 22 Aug 2024 14:30:26 +0200 Subject: [PATCH 2/2] feat(): ga can be disabled with local storage key ga_debug_mode --- src/google-tag-manager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/google-tag-manager.ts b/src/google-tag-manager.ts index 2d79e2e..d839eb3 100644 --- a/src/google-tag-manager.ts +++ b/src/google-tag-manager.ts @@ -12,7 +12,7 @@ export class BalGoogleTagManager { public isEnabled(): boolean { const win = window - return win && ((win as any)[DATA_LAYER] != null || win.localStorage.getItem('ga_debug_mode') === 'true'); + return win && (win as any)[DATA_LAYER] != null && win.localStorage.getItem('ga_debug_mode') !== 'true'; } public load(settings: GtmSettings): void {