Skip to content

Commit

Permalink
Append NEXT_PUBLIC before env vars
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
aburke07 committed Jul 5, 2023
1 parent f7f2573 commit 22d5fd9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
11 changes: 5 additions & 6 deletions frontend/templates/troubleshooting/components/TagManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}";
Expand Down
3 changes: 2 additions & 1 deletion frontend/templates/troubleshooting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down

0 comments on commit 22d5fd9

Please sign in to comment.