fix: update unattributed outcomes to match attributed outcomes and Android SDK#1655
Open
fix: update unattributed outcomes to match attributed outcomes and Android SDK#1655
Conversation
Both attributed and unattributed focus time processors now behave like the Android SDK: session time accumulates silently across background events, and both the user property update and the outcomes/measure call are sent together only after a 30-second timer fires (confirming the user has left). If the user returns within 30 seconds, the timer is cancelled and no calls are made. Changes to OSAttributedFocusTimeProcessor: - Move sendSessionTime from sendOnFocusCall to the actual send method so it only fires when the 30s timer fires or the session ends, sending the full accumulated total instead of each interval Changes to OSUnattributedFocusTimeProcessor: - Add 30s NSTimer delay before sending to outcomes/measure - Send immediately (no delay) when session ends via influence change - Implement cancelDelayedJob to invalidate timer on foreground return - Clear unsent time only on outcomes success (retry on failure) - Move sendSessionTime to the actual send method (same as attributed) - Reduce min session threshold from 60s to 1s to match attributed Made-with: Cursor
Both processors now use a unified `< 1` guard in sendOnFocusCallWithParams: instead of the old getMinSessionTime/hasMinSyncTime dispatch through the base class.
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
Align iOS session duration reporting (both attributed and unattributed) with Android SDK behavior by deferring all sends behind a 30-second timer.
Details
Motivation
Previously, attributed and unattributed session processors behaved differently:
outcomes/measurecall behind a 30-second timer. This is so the outcome event only sends at the end of a session rather than on every background.outcomes/measurecall immediately with no delay. This means outcomes can be sent multiple times for a single session. Analytics would be overcounted for unattributed session counts.This caused inconsistency between attribution types and also it diverged from the Android SDK, which uses a single model: send both the user property update and the outcomes call together once after a 30-second timer confirms the user has left the app, with no minimum accumulation time required.
Scope
What changed:
OSUnattributedFocusTimeProcessor:NSTimerdelay before sending tooutcomes/measure(matching attributed)onSessionEnded)cancelDelayedJobto invalidate the timer when the user returns to foreground within 30 secondssendSessionTimefromsendOnFocusCall:to the final send method, so it fires once with the full accumulated total (not on every background)OSAttributedFocusTimeProcessor:sendSessionTimefromsendOnFocusCall:tosendBackgroundAttributedSessionTimeWithParams:, so it fires once with the full accumulated total when the 30-second timer fires or the session endsResulting behavior (same for both attributed and unattributed)
sendSessionTime(user property update) andoutcomes/measureare sent together with the full accumulated session totalTesting
Unit testing
Manual testing
Tested attributed and unattributed session flows by foregrounding/backgrounding the app and verifying:
sendSessionTimeandoutcomes/measurefire together after 30 seconds with the correct accumulated totalAffected code checklist
Checklist
Overview
Testing
Final pass