Crash Reporting Settings
Branch: feat/crash-reporting-settings
Merged into: develop
Date: March 2026
Overview
Added a user-controlled toggle for crash reporting in Settings → Privacy → Segnalazione Errori, and introduced automatic opt-in for developer accounts. Previously, crash reporting was gated by a SharedPreferences flag but there was no UI to change it.
Why It Was Built
The observability system sends automatic error reports to Supabase, but users had no way to opt out from within the app. GDPR and good UX practice require that automatic data collection is disclosed and controllable. Additionally, developer accounts need reporting always on to surface issues during testing.
What Changed
crash_reporting_notifier.dart (new)
class CrashReportingNotifier extends AsyncNotifier<bool> {
@override
Future<bool> build() async {
final prefs = await SharedPreferences.getInstance();
return prefs.getBool('feature_crashReporting') ?? false;
}
Future<void> setEnabled(bool enabled) async { ... }
Future<void> initDefaultForEmail(String? email) async {
// If first time and email is in developer list, default to true
}
}Developer emails that auto-enable:
const _defaultEnabledEmails = {'elia-c@outlook.it'};auth_notifier.dart
AuthNotifier now accepts Ref to access providers:
AuthNotifier(this._repo, this._ref) : super(const AuthState());After initialize() and login() succeed, it calls:
await _ref.read(crashReportingProvider.notifier).initDefaultForEmail(email);This sets the default on first login for developer accounts without overriding an explicit user choice.
privacy_settings_screen.dart
New “Segnalazione Errori” section with a reactive toggle:
ref.watch(crashReportingProvider).when(
data: (enabled) => _buildToggleRow(
title: 'Segnalazione Crash',
subtitle: 'Invia report anonimi degli errori',
value: enabled,
onChanged: (v) => ref.read(crashReportingProvider.notifier).setEnabled(v),
),
...
)The toggle reads from SharedPreferences via the crashReportingProvider and persists immediately on change.
Architecture Notes
crashReportingProvideris anAsyncNotifier<bool>becauseSharedPreferences.getInstance()is async. The UI uses.when()to handle the loading state gracefully.- The preference key
feature_crashReportingis shared withIssueReportService, which reads it before sending automatic reports. force: trueinIssueReportService.reportIssue()bypasses this preference for manual user-submitted reports (the user already consented by clicking “Invia Report”).