Skip to content

feat: [SDK-5377] add SessionRequests IndexedDB store (1/4) - #1571

Merged
fadi-george merged 2 commits into
new-session-eventsfrom
fadi/sdk-5377
Nov 13, 2026
Merged

fadi-george merged 2 commits into
new-session-eventsfrom
fadi/sdk-5377

Conversation

@fadi-george

@fadi-george fadi-george commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Description

1 Line Summary

Adds SessionRequests and SessionRequestStates IndexedDB stores (DB v8) for queued sessions API requests.

Details

Session requests need to survive service worker restarts and offline periods. The service worker owns this store; the page never writes to it.

  • DB version 7 to 8; upgrade creates SessionRequests keyed by id and SessionRequestStates keyed by local session ID.
  • SessionRequestRecord: create and update records with the idempotency key, queue order, attempts and next send time.
  • SessionRequestState: the server session ID and create time, written when a create succeeds. It outlives the create record so later updates and ends find the server ID (like Android SessionStateModel / iOS SessionState).
  • No behavior change on its own.
  • Size limits: OneSignalSDK.page.es6.js to 47.09 kB and OneSignalSDK.sw.js to 13.72 kB for the DB upgrade.

Stack

Built on #1569 (SDK-5373 sessions API client).

  1. feat: [SDK-5377] add SessionRequests IndexedDB store (1/4) #1571 (this PR) SessionRequests IndexedDB store
  2. feat: [SDK-5377] enqueue policy for session requests (2/4) #1572 enqueue policy
  3. feat: [SDK-5377] send queued session requests with retry (3/4) #1573 send with retry
  4. feat: [SDK-5377] drain session requests on worker start and online (4/4) #1574 drain on worker start and online

Systems Affected

  • WebSDK
  • Backend
  • Dashboard

Validation

Tests

Info

Upgrade test from v7 with existing Options and operations data, and writes to both new stores.

vp check clean (only existing warnings), full vp run test passes, each PR in the stack passes on its own. Not tested in a browser: nothing enqueues session requests until the lifecycle wiring (SDK-5381).

Checklist

  • All the automated tests pass or I explained why that is not possible
  • I have personally tested this on my machine or explained why that is not possible
  • I have included test coverage for these changes or explained why they are not needed

Programming Checklist
Interfaces:

  • Don't use default export
  • New interfaces are in model files

Functions:

  • Don't use default export
  • All function signatures have return types
  • Helpers should not access any data but rather be given the data to operate on.

Typescript:

  • No Typescript warnings
  • Avoid silencing null/undefined warnings with the exclamation point

Other:

  • Iteration: refrain from using elem of array syntax. Prefer forEach or use map. Uses for...of where IndexedDB writes must run in sequence.
  • Avoid using global OneSignal accessor for context if possible.

Screenshots

Info

No UI changes.

Checklist

  • I have included screenshots/recordings of the intended results or explained why they are not needed

Related Tickets

SDK-5377


🤖 Generated with Claude Code

@nan-li nan-li left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, approving.

fadi-george and others added 2 commits November 12, 2026 18:18
Bumps the database to v8 with a SessionRequests store for queued sessions
API requests, written only by the service worker.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@fadi-george
fadi-george merged commit 115fa46 into new-session-events Nov 13, 2026
1 check passed
@fadi-george
fadi-george deleted the fadi/sdk-5377 branch November 13, 2026 02:19

@sherwinski sherwinski left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flagging for awareness:

This bump starts an upgrade for every existing user. openDB does not close on versionchange. blocked() only logs, and the db.* functions await dbPromise before the guard starts its timer. So a tab on an older SDK then blocks the v8 open, and every db call will wait indefinitely.
It looks like #1575 fixes part of this, but tabs on the released SDK will still block so consider adding a timeout on open?

This might not be worth taking action over, I'll leave it up to you to decide.

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.

3 participants