amplitude / amplitude/Amplitude-TypeScript
Handling localStorage Access Restrictions in Iframe for Amplitude
- 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 Amplitude JavaScript SDK should handle environments where localStorage access is restricted (such as within certain iframes) without causing uncaught exceptions or crashes in the application.
## Current Behavior
When the Amplitude SDK is used in an environment where localStorage is restricted (like in a cross-origin iframe), it attempts to access localStorage and triggers a SecurityError. This issue causes the application to crash or behave unexpectedly due to unhandled exceptions.
Error path: node_modules/@amplitude/analytics-browser/lib/esm/storage/local-storage.js
## Possible Solution
Implement a check within the SDK to gracefully handle scenarios where localStorage access is not available. This could include try-catch blocks around localStorage access or alternative storage mechanisms when localStorage is not accessible.
## Steps to Reproduce
1. Embed a webpage in a cross-origin iframe.
2. Integrate the Amplitude into the webpage.
3. Load the webpage within the iframe and observe the JavaScript console for errors related to localStorage access.
4. Notice that the application crashes or behaves unexpectedly.
## Environment
- JS SDK Version: 2.1.2
- Installation Method: Yarn
- Browser and Version: Chrome - Version 119.0.6045.199
Hướng dẫn đóng góp
Đánh giá
Issue này chưa được đánh giá.