amplitude / amplitude/Amplitude-TypeScript

Initiating Amplitude SDK in _app.js Breaks Pages with SSR (Next js)

Aperta
#549 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
bug
Lingua principale
TypeScript
Stelle
180
Fork
68
Merge medio
3g 1h
PR unite (30g)
29

Descrizione

## Expected Behavior:
The Next App example for shows that users should be able to be initiate amplitude in the _app.js file using the following code:
`amplitude.init(AMPLITUDE_API_KEY);`

## Current Behavior
If you have pages that use the `getServerSideProps` function, calling amplitude.init() in the root file causes these pages to throw a 500 error when accessing them. I suspect this is because of an incompatibility with Server Side Rendering.

Steps to reproduce:
1. Add the init function call to _app.js file. `amplitude.init(AMPLITUDE_API_KEY);`
2. Create a page that uses the getServerSideProps function.
3. Run the Next.js development server and observe the behavior when navigating to the page from step 2.

## Environment
- JS SDK Version: "@amplitude/analytics-browser": "^2.2.0",
- Installation Method: npm

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.