Last active
April 20, 2023 09:35
-
-
Save archieedwards/18287fceb2abd37bd186cd0ca62c8a23 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
// Example app.tsx file in a Next.js project | |
export default function App(){ | |
useEffect(() => { | |
analytics.init(process.env.NEXT_PUBLIC_AMPLITUDE_API_KEY); | |
}, []); | |
return ( | |
<FeatureFlagsProvider | |
amplitudeExperimentApiKey={ | |
process.env.NEXT_PUBLIC_AMPLITUDE_EXPERIMENTS_API_KEY | |
} | |
> | |
<Component /> | |
</FeatureFlagsProvider> | |
); | |
} | |
// Analtyics is initialised like so: | |
const init = (key: string) => { | |
if (!initialised) { | |
amplitudeSDK.init(key); | |
setInitialUserId(); | |
initialised = true; | |
} | |
}; | |
// Inside FeatureFlagsProvider we initialise the experiments client like so: | |
Experiment.initializeWithAmplitudeAnalytics(amplitudeExperimentApiKey, { | |
automaticFetchOnAmplitudeIdentityChange: true, | |
automaticExposureTracking: false, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment