amplitude / amplitude/Amplitude-TypeScript

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

Đang mở
#549 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug
Ngôn ngữ chính
TypeScript
Star
180
Fork
68
Merge trung bình
3 ngày 1 giờ
Pull request đã merge (30 ngày)
29

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.