fix: [SDK-4737] persist user consent in localStorage to survive iOS PWA wedge#1474
Merged
Conversation
…WA wedge setConsentGiven wrote consent to IndexedDB. On a wedged iOS Safari PWA the circuit breaker silently drops that write, so a revoked consent reverts to the stale value on the next load -- a privacy/legal opt-out lost across reloads with no error. Unlike every other guarded Options key, userConsent isn't re-derivable from another source of truth. Persist consent in localStorage instead (synchronous, immune to the wedge), mirroring how requiresPrivacyConsent is stored. getConsentGiven reads localStorage first and falls back once to the legacy Options.userConsent row, migrating it forward so existing consent isn't lost on upgrade. Bumps the page.es6 size-limit 42.57 -> 42.65 kB for the added migration path.
fadi-george
approved these changes
Jun 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
1 Line Summary
Persist user consent in
localStorageinstead of IndexedDB so a revoked opt-out isn't silently lost on a wedged iOS Safari PWA.Details
Follow-up hardening to SDK-4336 / SDK-4754.
OneSignal.setConsentGiven()wrote consent to the IndexedDBOptionsstore. On a wedged iOS Safari PWA, the circuit breaker added for SDK-4336/4754 silently drops that write — so on the next load the SDK reads the staleuserConsentrow back and re-hydrates consent as still granted. A user's privacy/legal opt-out is lost across reloads with no error, rejection, or log.userConsentis the only guardedOptionskey that is not re-derivable from another source of truth, which is what makes this privacy-/legal-critical (the trigger itself is narrow: iOS Safari PWA + active wedge + a same-sessionsetConsentGivencall).This change:
setConsentGiven/getConsentGivenaccessors inshared/helpers/localStorage.ts, mirroring howrequiresPrivacyConsentis already persisted viasetConsentRequired/getConsentRequired.localStorageis synchronous and immune to the IndexedDB wedge.OneSignal.setConsentGiven()now writes tolocalStorageinstead ofdb.put('Options', { key: 'userConsent', ... }).config.getConsentGiven()readslocalStoragefirst and falls back once to the legacyOptions.userConsentrow, migrating it forward so existing consenting users don't lose their stored consent on upgrade.Not a regression — before SDK-4336 the page hung ~30 min, so a user could never reach the revoke step. SDK-4754 (now merged) made init reliably complete during a wedge, which is what makes this path reachable.
Systems Affected
Validation
Tests
Info
vp check: 0 errors (5 pre-existingno-floating-promiseswarnings in unrelated test files).vp test --run: 523 passed. Newsrc/shared/database/config.test.tscoversgetConsentGiven: defaultfalse, reads thelocalStoragevalue, migrates a legacy IndexedDB value forward (and survives the IDB row being dropped), and preferslocalStorageover a stale legacy IndexedDB value.vp run build:prod: passes. Bumped theOneSignalSDK.page.es6.jssize-limit 42.57 kB → 42.65 kB to cover the added migration path. Note this limit was 42.7 kB until 4 days ago (b7bb0cf6), so 42.65 kB is still tighter than the recent ceiling.Checklist
Screenshots
Info
N/A — behavior is covered by unit tests.
Checklist
Related Tickets