Skip to content

fix(sentry): reset exit-telemetry anchors on toggle re-enable#198

Merged
gmaclennan merged 1 commit into
mainfrom
claude/sentry-exit-anchor-reset
Jul 8, 2026
Merged

fix(sentry): reset exit-telemetry anchors on toggle re-enable#198
gmaclennan merged 1 commit into
mainfrom
claude/sentry-exit-anchor-reset

Conversation

@gmaclennan

Copy link
Copy Markdown
Member

Closes #78.

When diagnosticsEnabled or applicationUsageData flips 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 / writeApplicationUsageData report the off → on flip and the module setter calls the new BackgroundAnchors.resetExitTelemetryAnchors, which resets the per-process exit-reason high-water marks and the duration anchors (process_started_at for both slots, main's foregrounded_at). The fresh foreground stamp neutralises an off-window backgrounded_at for 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 the fgs anchors 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 ComapeoPrefs stamps sentry.exitTelemetryResetAtMs on the transition and AppExitMetricsCollector drops 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).

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-actions github-actions Bot added the fix Bug fix (changelog) label Jul 7, 2026
@gmaclennan
gmaclennan added this pull request to the merge queue Jul 8, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 8, 2026
@gmaclennan
gmaclennan added this pull request to the merge queue Jul 8, 2026
Merged via the queue into main with commit 20abfc6 Jul 8, 2026
21 checks passed
@gmaclennan
gmaclennan deleted the claude/sentry-exit-anchor-reset branch July 8, 2026 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug fix (changelog)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sentry: reset exit-telemetry anchors on toggle cycle (§9b.9)

1 participant