From 9e2f7fb59d914fdb5caf77f81cbd4644a0e96231 Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Wed, 7 Dec 2022 19:28:40 +0200 Subject: [PATCH] Fix process.env in frontend code --- app/root.tsx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/root.tsx b/app/root.tsx index ed2c6b7a0..7cf80e363 100644 --- a/app/root.tsx +++ b/app/root.tsx @@ -67,6 +67,7 @@ export const meta: MetaFunction = () => ({ export interface RootLoaderData { locale: string; patrons: FindAllPatrons; + gtmId?: string; user?: Pick< UserWithPlusTier, | "id" @@ -86,6 +87,7 @@ export const loader: LoaderFunction = async ({ request }) => { { locale, patrons: db.users.findAllPatrons(), + gtmId: process.env["GTM_ID"], user: user ? { discordName: user.discordName, @@ -131,7 +133,7 @@ function Document({ - + {data?.gtmId ? : null} @@ -203,11 +205,7 @@ export const ErrorBoundary: ErrorBoundaryComponent = ({ error }) => { ); }; -function GTM() { - const id = process.env["GTM_ID"]; - - if (!id) return null; - +function GTM({ id }: { id: string }) { return ( <>