V3-12: crash reporting (code only)

shouldInitializeCrashReporting() and scrubExtra() are pure, fully unit-tested decision/scrubbing functions wired into sentry_flutter via beforeSend/beforeBreadcrumb. Config.crashReportingEnabled defaults off; the DSN is a compile-time --dart-define, not a preference. RecordingEngine gained an injected onUnexpectedStop callback, firing once when restoreAfterProcessDeath finds a trip still 'recording' at launch -- the process died without a user stop.

Marked partially done: the ticket's real acceptance criteria (a forced crash landing in a real Sentry project from a release build, inspecting a real payload) need a Sentry account and a release build this environment can't produce.
This commit is contained in:
2026-08-17 19:32:54 -05:00
parent 0e605ef174
commit be50448917
14 changed files with 443 additions and 9 deletions

View File

@@ -16,6 +16,7 @@ const _keyDeviceId = 'device_id';
const _keyMapEnabled = 'map_enabled';
const _keyUnitSystem = 'unit_system';
const _keyMountedMode = 'mounted_mode';
const _keyCrashReportingEnabled = 'crash_reporting_enabled';
/// Countries that did not adopt metric for everyday distances. Not exhaustive — a
/// best-effort default, not a claim of authority. Anyone can override it in Settings.
@@ -78,6 +79,15 @@ class Config {
Future<void> setMountedMode(bool enabled) =>
_prefs.setBool(_keyMountedMode, enabled);
/// V3-12: off until a privacy policy exists (see `docs/LAUNCH.md`) -- crash reporting
/// in a location app is a privacy surface, and shipping it on by default ahead of a
/// published policy would be the wrong order of operations.
bool get crashReportingEnabled =>
_prefs.getBool(_keyCrashReportingEnabled) ?? false;
Future<void> setCrashReportingEnabled(bool enabled) =>
_prefs.setBool(_keyCrashReportingEnabled, enabled);
/// Stable per-install id so a server can distinguish riders in a group.
String get deviceId {
final existing = _prefs.getString(_keyDeviceId);