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 摘要。