amplitude / amplitude/Amplitude-TypeScript

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

未關閉
#549 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
bug
主要語言
TypeScript
星號
180
分支
68
平均合併
3 天 1 小時
30 天內合併 PR
29

描述

## 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

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。