Hello, I am attempting to update the SDK to the latest version to begin using sticky bucketing and payload encryption. However, I am encountering an error. The app in question is a NextJS app (page router). I am unsure of what I might be missing. Can you please help me with this issue?
This is the code in my
_app.js
file:
const growthbook = new GrowthBook({
apiHost: "<https://cdn.growthbook.io>",
clientKey: growthbookClientKey,
enableDevMode: true,
subscribeToChanges: true,
decryptionKey: growthbookDecryptionKey,
trackingCallback: (experiment, result) => {
analytics.track(GA4_EXPERIMENT_VIEW, {
experiment_id: experiment.key,
variation_id: result.key,
});
},
});
function MyApp({ Component, pageProps }) {
//... Code omitted for brevity
useEffect(() => {
// Load features async
let isMounted = true;
if (isMounted && isReady && gaClientId) {
growthbook.setAttributes({
id: gaClientId,
url: window.location.href,
});
}
if (isMounted && isReady) {
growthbook.loadFeatures({ autoRefresh: true });
}
return () => {
isMounted = false;
};
}, [isReady, gaClientId]);
//... Code omitted for brevity
}
export default MyApp;
I understand that for react native and nodejs SDKs I need to add the
node:crypto
polyfill, but this is not my case here, any ideas on what I am doing wrong?
SDK version:
"<@U052WVA1MH6>/growthbook-react": "^0.24.0"