Last active
April 12, 2022 10:46
-
-
Save kenakingkong/3421735068e3ccc8a552ed33cb19284c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import type { AppProps } from 'next/app' | |
import Script from 'next/script' | |
import * as snippet from '@segment/snippet' | |
function App({ Component, pageProps }: AppProps) { | |
const loadSegment = () => { | |
const options = { | |
apiKey: process.env.NEXT_PUBLIC_SEGMENT_WRITE_KEY | |
} | |
if (process.env.NEXT_PUBLIC_NODE_ENV) { | |
return snippet.max(options) | |
} else { | |
return snippet.min(options) | |
} | |
} | |
return ( | |
<> | |
<Script dangerouslySetInnerHTML={{ __html: loadSegment() }} id="segmentScript" /> | |
<Component {...pageProps} /> | |
</> | |
) | |
} | |
export default App |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment