DavidWells / DavidWells/analytics
anonymousId coming back as undefined on iOS
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 2.7k
- Forks
- 267
- PR merge metrics
- No merged PRs in 30d
Description
On certain iOS devices I'm noticing that when we call:
const { anonymousId, userId } = analytics.user()
both are coming back as undefined. We don't have this problem on any other device (Android, desktop, etc).
I'm guessing it has to do with not being able to access localStorage for some reason?
Curious if somehow the hasLocalStorage definition could return true even though iOS is still somehow restricting access to write or read from localStorage.
Does the analytics library depend on localStorage being available? Based on this doc, I assumed that it would fall back to cookies and then global.
Any clues as to why this might happen or how to work around it?
(Side note: I noticed this issue that I thought might be related, but it seems to be related to the GTM plugin, which we're not using.)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with packages/analytics-util-storage/src/hasLocalStorage/index.js and the storage fallback behavior described in packages/analytics-util-storage/README.md. Reproduce the anonymousId and userId failure on the affected iOS devices, then verify that analytics.user() returns identifiers when localStorage is unavailable or restricted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100