Repository navigation
feat: [SDK-5814] split or move the session on a user switch (3/3) - #1820
Merged
Merged
Conversation
This was referenced Nov 20, 2026
fadi-george
force-pushed
the
fadi-SDK-5814-wiring
branch
from
November 21, 2026 05:38
d811c0b to
3d179ca
Compare
fadi-george
force-pushed
the
fadi-SDK-5814-wiring
branch
from
November 23, 2026 22:27
3d179ca to
782094e
Compare
fadi-george
force-pushed
the
fadi-SDK-5814-wiring
branch
from
November 23, 2026 22:32
782094e to
fd47a4e
Compare
On login or logout, move a held session to the new user and queue its create if that user is identified, or split a logged-in user's session. An anonymous user's login after the create was sent keeps the session and records the external ID, so a later switch splits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fadi-george
force-pushed
the
fadi-SDK-5814-wiring
branch
from
November 23, 2026 22:42
fd47a4e to
4de008a
Compare
nan-li
approved these changes
Nov 23, 2026
login() and logout() read the current user when they report the switch, so two switches on different threads can both read the later user and split twice. Each login gets a new identity model, so a switch reading the one the last switch read is skipped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
One Line Summary
On login or logout, move a held session to the new user, or split a logged-in user's session.
Details
Motivation
Part of SDK-5814, the iOS port of OneSignal/OneSignal-Android-SDK#2856. Wires 1/3 (hold) and 2/3 (split) to user switches, so time after a switch goes to the new user and requests never mix one user's onesignal_id with another user's push sub.
Scope
login()(only when the user actually changes) and_logout()callOSSessionService.onUserSwitched(). For a sessions API session:OSSessionRecord.identityModelIdbecomes settable for the move.splitSession(); the split is only reachable from a user switch._logout()also runs as 404 recovery, which now splits too.Note: a session saved before this change has no
externalId, so its first switch doesn't split. Fine sincenew-session-eventshasn't shipped.Stack
Testing
Unit testing
OSSessionSplitTestsnow go throughonUserSwitched(). New: login while held moves and sends the create with attribution; Identity Verification login sends a create that couldn't be sent; switch to another anonymous user keeps holding; anonymous login after the create was sent keeps the session, then a later login splits; switch after a focus that will start a new session, or before a launch's first session, changes nothing.SessionRecordUserTests: login while held queues the create for the new user; login as B splits; logout splits and holds S2; login as the same user doesn't split.Reduced test plan passes locally.
Manual testing
Not tested on device yet.
Affected code checklist
Checklist
Overview
Testing
Final pass
🤖 Generated with Claude Code