From b8761c54e78d23571300a1501b4182816008f6cc Mon Sep 17 00:00:00 2001 From: Heather Date: Tue, 21 May 2024 16:35:42 -0400 Subject: [PATCH 1/4] don't load analytics scripts when not in prod --- src/pages/_app.tsx | 34 +++++++++------------------------- src/pages/_document.tsx | 10 ++++++---- 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index fbf461c76be..a4bba510e6b 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -52,6 +52,7 @@ function MyApp({ Component, pageProps }) { )); const favIconColor = router.route.startsWith('/gen1') ? 'teal' : 'purple'; + return ( <> @@ -138,15 +139,7 @@ function MyApp({ Component, pageProps }) { - {process.env.BUILD_ENV !== 'production' ? ( - <> - - - ) : ( + {process.env.BUILD_ENV === 'production' ? ( <> - )} + ) : null} {getLayout()} - {process.env.BUILD_ENV !== 'production' ? ( - <> - {/* eslint-disable-next-line @next/next/no-sync-scripts */} - - - - ) : ( + {process.env.BUILD_ENV === 'production' ? ( <> {/* eslint-disable-next-line @next/next/no-sync-scripts */} @@ -176,12 +160,12 @@ function MyApp({ Component, pageProps }) { src="https://d2c.aws.amazon.com/client/loader/v1/d2c-load.js" defer > + - )} - + ) : null} ); } diff --git a/src/pages/_document.tsx b/src/pages/_document.tsx index a447006c809..afbdf848edb 100644 --- a/src/pages/_document.tsx +++ b/src/pages/_document.tsx @@ -114,10 +114,12 @@ export default class MyDocument extends Document { httpEquiv="Content-Security-Policy" content={getCspContent(this.props)} /> - + {process.env.buildEnv === 'production' ? ( + + ) : null}
From 0676cd618fe73d2949aa4ecb60de19f6754853cf Mon Sep 17 00:00:00 2001 From: Heather Date: Tue, 21 May 2024 17:57:09 -0400 Subject: [PATCH 2/4] test --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 58eee179959..4388898bb90 100644 --- a/package.json +++ b/package.json @@ -100,11 +100,12 @@ "refresh": "yarn clean && yarn", "test": "jest --coverage", "dev": "yarn prebuild && next dev", + "image": "next-image-export-optimizer --exportFolderPath client/www/next-build", "spellcheck": "cspell \"src/**/*.mdx\" --no-progress", "spellcheck-diff": "git diff --name-only --cached | awk \"/src.*\\.mdx/{print}\" | npx cspell --no-must-find-files --file-list stdin", "build": "next build", "postbuild": "node tasks/postBuildTasks.mjs", - "build:release": "yarn build && next-image-export-optimizer --exportFolderPath client/www/next-build", + "build:release": "yarn build && yarn image", "next-build": "next build", "next-start": "next start", "prepare": "husky install", From 87c089a7a79891a26403869a50e720719ef138ff Mon Sep 17 00:00:00 2001 From: Heather Date: Tue, 21 May 2024 18:07:38 -0400 Subject: [PATCH 3/4] revert package changes --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 4388898bb90..58eee179959 100644 --- a/package.json +++ b/package.json @@ -100,12 +100,11 @@ "refresh": "yarn clean && yarn", "test": "jest --coverage", "dev": "yarn prebuild && next dev", - "image": "next-image-export-optimizer --exportFolderPath client/www/next-build", "spellcheck": "cspell \"src/**/*.mdx\" --no-progress", "spellcheck-diff": "git diff --name-only --cached | awk \"/src.*\\.mdx/{print}\" | npx cspell --no-must-find-files --file-list stdin", "build": "next build", "postbuild": "node tasks/postBuildTasks.mjs", - "build:release": "yarn build && yarn image", + "build:release": "yarn build && next-image-export-optimizer --exportFolderPath client/www/next-build", "next-build": "next build", "next-start": "next start", "prepare": "husky install", From 0ed6853fa91fd3bac5d8c85522d3550b1121cf96 Mon Sep 17 00:00:00 2001 From: Heather Date: Wed, 22 May 2024 14:02:15 -0400 Subject: [PATCH 4/4] use staging env --- src/pages/_app.tsx | 34 +++++++++++++++++++++++++++------- src/pages/_document.tsx | 3 ++- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index a4bba510e6b..af6c624bd5c 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -20,6 +20,7 @@ function MyApp({ Component, pageProps }) { } = pageProps; const router = useRouter(); + const { BUILD_ENV } = process.env; useEffect(() => { const handleRouteChange = () => { @@ -52,7 +53,6 @@ function MyApp({ Component, pageProps }) { )); const favIconColor = router.route.startsWith('/gen1') ? 'teal' : 'purple'; - return ( <> @@ -139,7 +139,7 @@ function MyApp({ Component, pageProps }) { - {process.env.BUILD_ENV === 'production' ? ( + {BUILD_ENV === 'production' ? ( <> + ) : BUILD_ENV === 'staging' ? ( + <> + + ) : null} {getLayout()} - {process.env.BUILD_ENV === 'production' ? ( + {BUILD_ENV === 'production' ? ( <> {/* eslint-disable-next-line @next/next/no-sync-scripts */} @@ -160,11 +168,23 @@ function MyApp({ Component, pageProps }) { src="https://d2c.aws.amazon.com/client/loader/v1/d2c-load.js" defer > - + ) : BUILD_ENV === 'staging' ? ( + <> + {/* eslint-disable-next-line @next/next/no-sync-scripts */} + + + + ) : null} + + {BUILD_ENV === 'staging' || BUILD_ENV === 'production' ? ( + ) : null} ); diff --git a/src/pages/_document.tsx b/src/pages/_document.tsx index afbdf848edb..51c80b46482 100644 --- a/src/pages/_document.tsx +++ b/src/pages/_document.tsx @@ -114,7 +114,8 @@ export default class MyDocument extends Document { httpEquiv="Content-Security-Policy" content={getCspContent(this.props)} /> - {process.env.buildEnv === 'production' ? ( + {process.env.BUILD_ENV === 'production' || + process.env.BUILD_ENV === 'staging' ? (