From 798f9584b96064d4497b096755373d0571290100 Mon Sep 17 00:00:00 2001 From: Kevin Ge Date: Thu, 12 Oct 2023 11:16:30 -0500 Subject: [PATCH] fix: only add gtag script to prod environments (#712) --- src/env/schema.mjs | 4 ++-- src/pages/_app.tsx | 23 +++++++++++++---------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/env/schema.mjs b/src/env/schema.mjs index 69599aa3d..250ceb214 100644 --- a/src/env/schema.mjs +++ b/src/env/schema.mjs @@ -39,10 +39,10 @@ export const serverSchema = z.object({ * To expose them to the client, prefix them with `NEXT_PUBLIC_`. */ export const clientSchema = z.object({ + NEXT_PUBLIC_NODE_ENV: z.enum(['development', 'test', 'production']), NEXT_PUBLIC_UMAMI_URL: z.string(), NEXT_PUBLIC_UMAMI_WEBSITE_ID: z.string(), NEXT_PUBLIC_VALIDATOR: z.string(), - // NEXT_PUBLIC_BAR: z.string(), }); /** @@ -52,8 +52,8 @@ export const clientSchema = z.object({ * @type {{ [k in keyof z.infer]: z.infer[k] | undefined }} */ export const clientEnv = { + NEXT_PUBLIC_NODE_ENV: process.env.NODE_ENV, NEXT_PUBLIC_UMAMI_URL: process.env.NEXT_PUBLIC_UMAMI_URL, NEXT_PUBLIC_UMAMI_WEBSITE_ID: process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID, NEXT_PUBLIC_VALIDATOR: process.env.NEXT_PUBLIC_VALIDATOR, - // NEXT_PUBLIC_BAR: process.env.NEXT_PUBLIC_BAR, }; diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 3981628fa..2702a2c5a 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -115,17 +115,20 @@ const NebulaApp: AppType<{ session: Session | null }> = ({ /> )} + {env.NEXT_PUBLIC_NODE_ENV === 'production' && ( + <> + + gtag('config', 'G-5V674KK1JX'); + `} + + + )} setHasWarned(true)}