From 51ad8ab3bd292965b6d86f00c60337a69beb717c Mon Sep 17 00:00:00 2001 From: Robert Helmer Date: Fri, 26 Jan 2024 17:22:08 -0800 Subject: [PATCH] MNTOR-2832/fix ga4 debug mode (#4097) * MNTOR-2832 - configure GA4 debug mode with build time env var --- .env-dist | 3 +++ src/app/hooks/useGa.ts | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.env-dist b/.env-dist index 8600b8421..bb8163034 100755 --- a/.env-dist +++ b/.env-dist @@ -170,3 +170,6 @@ NEXT_PUBLIC_GA4_MEASUREMENT_ID=G-CXG8K4KW4P # Used during CI to upload sourcemaps to Sentry. UPLOAD_SENTRY_SOURCEMAPS=false SENTRY_AUTH_TOKEN= + +# Whether GA4 sends data or not. NOTE: must be set in build environment. +NEXT_PUBLIC_GA4_DEBUG_MODE=true diff --git a/src/app/hooks/useGa.ts b/src/app/hooks/useGa.ts index 7271d0e13..ca0922b0a 100644 --- a/src/app/hooks/useGa.ts +++ b/src/app/hooks/useGa.ts @@ -52,7 +52,7 @@ export const useGa = (): { }; } => { const debugMode = - process.env.NEXT_PUBLIC_NODE_ENV !== "production" && + process.env.NEXT_PUBLIC_GA4_DEBUG_MODE === "true" && process.env.NODE_ENV !== "test"; useEffect(() => {