From 289bb13568d17408f74d4de148e17b4d848924db Mon Sep 17 00:00:00 2001 From: Gery Hirschfeld Date: Thu, 22 Aug 2024 14:27:33 +0200 Subject: [PATCH] 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 + }); } };