Skip to content

Commit

Permalink
added initial tooling (#570)
Browse files Browse the repository at this point in the history
* added initial tooling

* fix .gitignore

* fix the _document.tsx
  • Loading branch information
jeromehardaway authored Mar 17, 2024
1 parent 6b086f4 commit c87829a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
11 changes: 7 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ yarn-error.log*
# local env files
.env*.local
.env
.env*.production

# vercel
.vercel
Expand All @@ -46,7 +47,9 @@ public/workbox-*.js
# Sitemap
/public/robots.txt
/public/sitemap.xml
/public/sitemap-*.xml
/test-results/
/playwright-report/
/playwright/.cache/
/public/sitemap-*.xml
/test-results/
/playwright-report/
/playwright/.cache/


1 change: 1 addition & 0 deletions env.local
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NEXT_PUBLIC_GOOGLE_ANALYTICS_ID=G-WSXY307CRR
1 change: 1 addition & 0 deletions env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NEXT_PUBLIC_GOOGLE_ANALYTICS_ID=G-WSXY307CRR
19 changes: 18 additions & 1 deletion src/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,27 @@ import Document, { Html, Head, Main, NextScript } from "next/document";
export default class MyDocument extends Document {
render() {
const pageProps = this.props?.__NEXT_DATA__?.props?.pageProps;
const gaId = process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS_ID; // Get the GA ID from environment variables

return (
<Html lang="en">
<Head />
<Head>
{gaId && ( // Only include the script if the GA ID is present
<>
<script async src={`https://www.googletagmanager.com/gtag/js?id=${gaId}`} /> {/* Make self-closing */}
<script
dangerouslySetInnerHTML={{
__html: `
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${gaId}');
`,
}}
/> {/* Make self-closing */}
</>
)}
</Head>
<body className={pageProps.className}>
<Main />
<div id="portal" />
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1161,9 +1161,9 @@
dependencies:
"glob" "7.1.7"

"@next/swc-darwin-x64@12.2.2":
"integrity" "sha512-dztDtvfkhUqiqpXvrWVccfGhLe44yQ5tQ7B4tBfnsOR6vxzI9DNPHTlEOgRN9qDqTAcFyPxvg86mn4l8bB9Jcw=="
"resolved" "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-12.2.2.tgz"
"@next/swc-darwin-arm64@12.2.2":
"integrity" "sha512-JCoGySHKGt+YBk7xRTFGx1QjrnCcwYxIo3yGepcOq64MoiocTM3yllQWeOAJU2/k9MH0+B5E9WUSme4rOCBbpA=="
"resolved" "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-12.2.2.tgz"
"version" "12.2.2"

"@nodelib/[email protected]":
Expand Down

0 comments on commit c87829a

Please sign in to comment.