Skip to content

Add localStorage feature detection to prevent throws in restricted environments#573

Closed
franco-zalamena-iterable wants to merge 1 commit intoIterable:mainfrom
franco-zalamena-iterable:fix/524-localstorage-access-guard
Closed

Add localStorage feature detection to prevent throws in restricted environments#573
franco-zalamena-iterable wants to merge 1 commit intoIterable:mainfrom
franco-zalamena-iterable:fix/524-localstorage-access-guard

Conversation

@franco-zalamena-iterable
Copy link
Copy Markdown

@franco-zalamena-iterable franco-zalamena-iterable commented Apr 7, 2026

Summary

  • Add safe localStorage wrapper with feature detection
  • Falls back to in-memory storage when localStorage is unavailable
  • Prevents throws in mobile webviews and iOS Safari private browsing

Test plan

  • Test in normal browser (localStorage works)
  • Test in private browsing mode
  • Verify setUserId and setEmail work in both scenarios

🤖 Generated with Claude Code

…ments

Introduces safeStorage utility with feature detection that falls back to
in-memory storage when localStorage is unavailable (mobile webviews, iOS
Safari private browsing). Replaces all direct localStorage calls in
source files with safe wrappers.

Fixes Iterable#524

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.19048% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.12%. Comparing base (190a168) to head (d88b9b7).

Files with missing lines Patch % Lines
src/utils/safeStorage.ts 55.31% 18 Missing and 3 partials ⚠️
src/utils/functions.ts 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #573      +/-   ##
==========================================
- Coverage   74.45%   74.12%   -0.33%     
==========================================
  Files          57       58       +1     
  Lines        2736     2787      +51     
  Branches      798      826      +28     
==========================================
+ Hits         2037     2066      +29     
+ Misses        698      677      -21     
- Partials        1       44      +43     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@franco-zalamena-iterable franco-zalamena-iterable deleted the fix/524-localstorage-access-guard branch April 8, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants