DavidWells / DavidWells/analytics

anonymousId coming back as undefined on iOS

Open
#129 1 comment 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.