fix(sentry): reset exit-telemetry anchors on toggle re-enable#198
Merged
Conversation
When diagnosticsEnabled or applicationUsageData flips off -> on, the setter now resets the app-exit telemetry anchors to "now" so exit records generated while the user had opted out are never reported after re-enable (plan section 9b.9). Android: ComapeoPrefs.write* reports the off -> on transition and the module setter calls BackgroundAnchors.resetExitTelemetryAnchors, which resets the per-process exit-reason high-water marks plus the duration anchors (process_started_at for both slots, main's foregrounded_at — the fresh foreground stamp neutralises an off-window backgrounded_at). iOS: ComapeoPrefs stamps sentry.exitTelemetryResetAtMs on the transition and AppExitMetricsCollector drops MetricKit payloads whose 24h window began before the stamp, since an aggregate window can't be split. Redundant on -> on sets and disables leave the anchors untouched.
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Jul 8, 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.
Closes #78.
When
diagnosticsEnabledorapplicationUsageDataflips off → on, the app-exit telemetry anchors were left untouched, so a re-enable could report exit records generated during the window the user had opted out — breaking the opt-out promise. Both setters now reset the anchors to "now" on that transition, and only on that transition: redundant on → on sets and disables leave the anchors alone.On Android,
ComapeoPrefs.writeDiagnosticsEnabled/writeApplicationUsageDatareport the off → on flip and the module setter calls the newBackgroundAnchors.resetExitTelemetryAnchors, which resets the per-process exit-reason high-water marks and the duration anchors (process_started_atfor both slots, main'sforegrounded_at). The fresh foreground stamp neutralises an off-windowbackgrounded_atfor later exits, so post-re-enable exits can't report durations spanning the opted-out period. This is the one place the main process writes thefgsanchors file; the FGS only writes its own file in a burst at its cold start, so a reset racing that narrow window is a tolerable best-effort gap (noted in the class doc).On iOS there is no stored high-water mark — MetricKit delivers 24h aggregate windows — so
ComapeoPrefsstampssentry.exitTelemetryResetAtMson the transition andAppExitMetricsCollectordrops payloads whose window began before the stamp. An aggregate window can't be split, so a window overlapping the opted-out period is dropped whole.Unit tests on both platforms cover: off-window records are not reported after re-enable, records after re-enable are, durations truncate to the re-enable time, and redundant sets don't reset. Docs updated (
sentry-integration.md§7.5, plan §9b.9 marked done).