Skip to content

Sentry: iOS killed-in-background heuristic (Phase 7b, optional) #83

@gmaclennan

Description

@gmaclennan

Part of #74. Optional, independent.

Spec: docs/sentry-integration-plan.md Phase 7b.

iOS only tells us "why was the app killed" as 24-hour aggregate counts (Apple's MetricKit reports), with no timestamps. This workblock adds a simple heuristic for per-incident detail: record the app's lifecycle state on disk as it changes, and on the next launch, if the previous run didn't end cleanly, report one "ios kill inferred" event saying whether the app was in the background and roughly how long it had been there.

Deliverables

  • ios/AppKillHeuristic.swift: write background / foreground / terminated-cleanly plus a timestamp to on-device storage on each lifecycle change. On cold start, an unclean previous state produces one event tagged ios.killed_in_background, with last_known_state and time_since_last_state_ms
  • Refresh the marker every 30 seconds while the app is in the foreground, so the "how long" number doesn't badly understate
  • Document the limits honestly: this catches any unclean end — the system killing the app to free memory, iOS killing an unresponsive app, user force-quit, OS reboot, or a crash. The MetricKit counts and crash reports help tell those apart on dashboards

Tests

  • AppKillHeuristicTests.swift with a fake store + clock: a clean shutdown suppresses the event; a stale marker fires once then clears; foreground vs background drives the tag correctly
  • Manual check by forcing a low-memory kill

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions