From 22d5fd929cf1a1efe4e7c18e9d3c1595346db59e Mon Sep 17 00:00:00 2001 From: Alex Burke Date: Wed, 5 Jul 2023 11:38:46 -0700 Subject: [PATCH] Append NEXT_PUBLIC before env vars 1. We need to append this to access it in the frontend. These are not secret keys, so it's fine to expose them in the frontend. 2. Also clean up some console logs. --- .../troubleshooting/components/TagManager.tsx | 11 +++++------ frontend/templates/troubleshooting/index.tsx | 3 ++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/frontend/templates/troubleshooting/components/TagManager.tsx b/frontend/templates/troubleshooting/components/TagManager.tsx index fc4bf4a7..6178541b 100644 --- a/frontend/templates/troubleshooting/components/TagManager.tsx +++ b/frontend/templates/troubleshooting/components/TagManager.tsx @@ -35,25 +35,24 @@ function GoogleNoScript() { } function MatomoScript() { - console.log('matomo script'); const params = new URLSearchParams(); const environment = params.get(GET_PARAM) || DEFAULT_ENV; const configUrl = (function () { switch (environment) { case 'Live': - return process.env.MATOMO_TAG_MANAGER_CONTAINER_URL_LIVE; + return process.env + .NEXT_PUBLIC_MATOMO_TAG_MANAGER_CONTAINER_URL_LIVE; case 'Staging': - return process.env.MATOMO_TAG_MANAGER_CONTAINER_URL_STAGING; + return process.env + .NEXT_PUBLIC_MATOMO_TAG_MANAGER_CONTAINER_URL_STAGING; case 'Dev': - return process.env.MATOMO_TAG_MANAGER_CONTAINER_URL_DEV; + return process.env.NEXT_PUBLIC_MATOMO_TAG_MANAGER_CONTAINER_URL_DEV; default: throw new Error(`Unknown environment: ${environment}`); } })(); - console.log(`Matomo script: ${configUrl}`); - const scriptTag = ` var c = "${configUrl}"; diff --git a/frontend/templates/troubleshooting/index.tsx b/frontend/templates/troubleshooting/index.tsx index 66e90d65..ef380144 100644 --- a/frontend/templates/troubleshooting/index.tsx +++ b/frontend/templates/troubleshooting/index.tsx @@ -81,7 +81,8 @@ const Wiki: NextPageWithLayout<{ ); console.log( - 'matomo live url: ' + process.env.MATOMO_TAG_MANAGER_CONTAINER_URL_LIVE + 'matomo live url: ' + + process.env.NEXT_PUBLIC_MATOMO_TAG_MANAGER_CONTAINER_URL_LIVE ); return (