SDK tracking ID helpers throw when Web Storage is unavailable
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- typescript
Research direction
Start in packages/sdk/src/core/tracker.ts by reading getAnonymousId(), getSessionId(), getTrackingIds(), getTrackingParams(), and the existing getProfileId() handling. Run the existing SDK tests for storage and URL-parameter precedence, then add coverage for storage reads that throw. Done means unavailable storage returns null or an empty string while an available storage ID and explicit URLSearchParams values are preserved.
Written by the indexing model from the issue text.
Description
Describe the bug
The public SDK helpers getAnonymousId() and getSessionId() read from localStorage and sessionStorage without handling storage access errors.
Web Storage access can throw a DOMException such as SecurityError when storage is restricted by browser settings or unavailable in a sandboxed context. When this happens, these helpers throw instead of treating the tracking ID as unavailable.
The error also propagates through:
getTrackingIds()getTrackingParams()
This differs from getProfileId(), which already catches storage errors and returns null.
This can affect user-facing flows that treat tracking information as optional metadata. For example, Stripe checkout metadata and contact-form submission both call getTrackingIds().
To Reproduce
- Load
@databuddy/sdkin a browser. - Override storage reads to simulate a restricted-storage environment:
const originalGetItem = Storage.prototype.getItem;
Storage.prototype.getItem = function () {
throw new DOMException("Access is denied", "SecurityError");
};
try {
getAnonymousId();
} finally {
Storage.prototype.getItem = originalGetItem;
}
- Observe that
getAnonymousId()throwsSecurityError.
The same behavior occurs when getSessionId() encounters an inaccessible sessionStorage. The exception also propagates from getTrackingIds() and getTrackingParams().
Expected behavior
Storage access failures should be treated as missing tracking IDs:
getAnonymousId(); // null
getSessionId(); // null
getTrackingIds(); // { anonId: null, sessionId: null }
getTrackingParams(); // ""
If only one storage mechanism is unavailable, getTrackingIds() and getTrackingParams() should preserve the ID available from the other mechanism.
Explicit URLSearchParams values should continue to take priority without accessing the corresponding storage mechanism.
Screenshots
Not applicable. The failure is a thrown DOMException.
Environment (please complete the following information):
- OS: windows 11
- Browser: firefox
- Version: 154.0
- SDK version:
@databuddy/sdk2.6.0
Additional context
The affected code is in packages/sdk/src/core/tracker.ts.
Existing tests cover empty storage, populated storage, and URL-parameter precedence, but do not cover storage reads throwing.
A fix could follow the existing getProfileId() pattern by catching errors around each individual storage read and returning null.
AI usage disclosure
This issue report was drafted with OpenAI Codex. Codex inspected the affected SDK implementation, its call sites, existing tests, repository history, contribution guidelines, and AI usage policy. I personally reviewed and edited the report and reproduced the behavior before submission.
- Dominant language
- TypeScript
- Stars
- 1.2k
- Forks
- 216
- Avg merge
- 14h 53m
- Merged PRs (30d)
- 154
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.
More from databuddy-analytics/Databuddy
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
databuddy-analytics/Databuddy#694 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
databuddy-analytics/Databuddy#666 · 1 comment ·
-
Flag list not refreshed after status toggle/archive when flag.websiteId doesn't match the query key Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
databuddy-analytics/Databuddy#664 · 1 comment ·
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
databuddy-analytics/Databuddy#649 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
databuddy-analytics/Databuddy#643 ·
All issues in databuddy-analytics/Databuddy
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
fullcalendar/fullcalendar#8106 ·