Repository navigation
feat: [SDK-5369] session model and sessions v2 feature flag - #2774
Conversation
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
📊 Diff Coverage ReportDiff Coverage Report (Changed Lines Only)Gate: aggregate coverage on changed executable lines must be ≥ 80% (JaCoCo line data for lines touched in the diff). Changed Files Coverage
Overall (aggregate gate)70/72 touched executable lines covered (97.2% — requires ≥ 80%) Per-file detail (informational; gate is aggregate above):
|
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…essions API sessions Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
abdulraqeeb33
left a comment
There was a problem hiding this comment.
Two blockers.
Login before the anonymous user is created can retarget the subscription pin while the OneSignal pin stays on the anonymous local ID. The KMP gitlink is still the unmerged PR branch.
abdulraqeeb33
left a comment
There was a problem hiding this comment.
Reviewed on top of new-session-events.
No change requested. The flag is still captured once per new session, and v2 duration still uses the monotonic clock.
Threading looks sound. Focus, unfocus, and the local-to-backend pin update all apply on the serial IO queue. The clocks are captured on the caller thread before that hop, same as the existing focus timestamp. featureManager.isEnabled is safe to call from that queue. endSession from backgroundRun still runs off the queue and does not read the new fields. The hasProperty check and the onesignalId read take the model lock separately, but a replace holds that lock across the clear and the refill, and the replacement always includes onesignal_id, so the getter does not observe a missing key.
SessionModel.kt: the serverSessionId note restates the property name.
- Point the KMP submodule at the merged commit on new-session-events - Skip pinned subscription ID updates once the session's user is no longer current - Drop cached remote feature flags when the appId changes - Cover the sessions API resume path Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
abdulraqeeb33
left a comment
There was a problem hiding this comment.
All three findings from my last pass are fixed and verified at this head. Thanks.
Nit, non-blocking: the AppIdResolution KDoc reads as if every flag switches with the app. APP_STARTUP flags keep the previous app's value until next launch, so worth saying that, and a OneSignalImp level test for the app id change path would lock it in.
Description
One Line Summary
Capture the
sdk_sessions_v2_api_cutoverflag and pinned user/subscription IDs onSessionModelat session start, and measure v2 session duration with a monotonic clock.Details
Motivation
First Android PR in the SDK Sessions stack (SDK-5368). Later PRs need a persisted per-session record that knows which path the session is on and which user/subscription it belongs to, even after login.
Scope
OneSignal-KMP-SDKsubmodule to addFeatureFlag.SDK_SESSIONS_V2_API_CUTOVER(feat: [SDK-5369] add sdk_sessions_v2_api_cutover feature flag OneSignal-KMP-SDK#27). Bump to the merged commit before this lands.ITime.elapsedRealtimeMillisbacked bySystemClock.elapsedRealtime().SessionModeladdsusesSessionsApi,onesignalId,subscriptionId,serverSessionId,focusElapsedRealtime.SessionServiceon new session: setsusesSessionsApifrom the flag once, pins the current OneSignal ID and push subscription ID, and clearsserverSessionId. The choice stays fixed for the session, so a session ended in a new process (e.g. fromSyncJobService) still takes the same path.activeDurationuses the monotonic clock; an interval spanning a reboot counts as 0.Other
A session that starts before the user is created pins local IDs. When the backend replaces a local OneSignal ID or push subscription ID in place,
SessionServicecarries the backend ID over to the pinned copy. Logins, user switches, and local-to-local changes leave pinned IDs alone. The operation repo's ID translation does not cover this, since it only rewrites operations queued at response time.Testing
Unit testing
New
SessionServiceTests: flag capture on/off, flag fixed mid-session, IDs pinned after login, local IDs replaced by backend IDs (and not by later or other local IDs), monotonic duration, reboot interval, and all model fields surviving a reload from preferences. Full core unit suite,spotlessCheck,detekt, andassembleReleasepass.Manual testing
Not tested on a device. No user-facing behavior changes with the flag off.
Affected code checklist
Checklist
Overview
Testing
Final pass
🤖 Generated with Claude Code