:library:feature:diagnostics
Purpose
Lets a person choose what the app reports and shares: the usage and diagnostics switch, and the analytics and advertising consents behind it, on a settings page and on an onboarding page.
Owns
Feature event builders and their bounded keys in
ui/analytics; screens only report events.UsageAndDiagnosticsScreen,UsageAndDiagnosticsViewModel,UsageAndDiagnosticsUiState(whosesettingsis aLoadable) andUsageAndDiagnosticsEvent.UsageAndDiagnosticsScreenContent, the stateless switch, privacy choices row and privacy note, with its loading and failure states.FirebaseConsentDialog, the privacy choices dialog, and its pages.TelemetryOnboardingPage, the onboarding page that shows the switch and the dialog, with its own strings.UsageAndDiagnosticsSettings,UsageAndDiagnosticsRepository,DefaultUsageAndDiagnosticsRepositoryanddiagnosticsSettingsModule.diagnosticsSettingsPage(), the registration ofDiagnosticsSettingsRoute.
Does not own
Consent persistence, owned by
:library:integration:consent(UsageAndDiagnosticsPreferencesDataSource).The consent SDK calls, owned by
:library:integration:consent(ConsentRepository).The onboarding flow and its pager, owned by
:library:feature:onboarding; a host listsTelemetryOnboardingPagein itsOnboardingProvider.The privacy page that opens this one, owned by
:library:feature:privacy.
Depends on
:library:core:common,:library:core:datastore,:library:core:ui(which exposes navigation) and:library:integration:consent.No other feature module.
Used by
:library:apptoolkit, which callsdiagnosticsSettingsPage()and includesdiagnosticsSettingsModule.:sample:feature:onboarding, which listsTelemetryOnboardingPage.
Flow chart
flowchart TD
Page[diagnosticsSettingsPage: DiagnosticsSettingsRoute] --> Screen[UsageAndDiagnosticsScreen]
Onboarding[TelemetryOnboardingPage] --> VM
Screen --> VM[UsageAndDiagnosticsViewModel]
Screen --> Content[UsageAndDiagnosticsScreenContent]
Content -->|privacy choices row| Dialog[FirebaseConsentDialog]
Content -->|switch, dialog choices| VM
VM -->|observeSettings| Repo[UsageAndDiagnosticsRepository]
VM -->|set..., setAll| Repo
Repo --> Store[UsageAndDiagnosticsPreferencesDataSource]
Repo -->|after each write| Consent[ConsentRepository: consent SDKs]
VM -->|failed write| Messages[MessageHost snackbar]Architectural decisions
On
core.ui.screen.UsageAndDiagnosticsViewModelfollows the stored choices withcollectReport. A failed read isLoadable.Failedwith Retry, which restarts the collection; a failed write keeps the choices on screen and shows an error message throughMessageHost. Both use the module's "An error occurred" text when the failure has no text of its own.The repository applies consent.
DefaultUsageAndDiagnosticsRepositoryapplies the stored choices to the consent SDKs after every write, so a change reaches them whether or not a screen is still open. The ViewModel only reads and writes, and takes no dispatcher, since the repository is main-safe.One screen shape for both consent pages. The settings screen is the ads screen's layout: one switch over a single row that opens the consent surface it belongs to, here
FirebaseConsentDialog, the same dialog onboarding shows. The dialog and the onboarding page live here, with the state they read and write, so onboarding does not depend on this feature.Whole answers are one write.
AllowAllConsentandAllowEssentialConsentare events, so both places that show the dialog agree on what "everything" and "essentials" cover. Both turn reporting on, cancel single-choice writes still in flight, and store the answer withsetAll.The onboarding page waits for the stored choices. Its toggle shows off and its dialog stays closed until they arrive. It draws its messages through the page frame's snackbar host, or its own at the bottom of the page outside a frame.
Public contracts
UsageAndDiagnosticsScreen(),diagnosticsSettingsPage(),TelemetryOnboardingPage(isSelected),FirebaseConsentDialog(settings, ...),UsageAndDiagnosticsViewModel,UsageAndDiagnosticsUiState,UsageAndDiagnosticsEvent,UsageAndDiagnosticsSettings,UsageAndDiagnosticsRepositoryanddiagnosticsSettingsModule.UsageAndDiagnosticsScreenContentandTelemetryOnboardingPageContentare internal.Consent defaults: every choice is granted in release builds and refused in debug builds until the person answers.
Current risks
observeSettings()maps one complete consent snapshot. Bulk writes cannot expose a mixture of old and new choices to the screen or the consent SDKs.UsageAndDiagnosticsSettingsduplicatesConsentSettingsfrom:library:integration:consent.Changes affect both settings and onboarding, and must keep the consent defaults, the stored values and the order in which the SDKs receive them.
Migration notes
In 3.0.0-pre30, FirebaseOnboardingPage was renamed directly to TelemetryOnboardingPage (ui.onboarding). Hosts must update imports and calls; no compatibility alias is provided. The name covers the page's usage and diagnostics reporting and its analytics and advertising consent choices. Keep the existing page key and pass the same isSelected value. Consent state, defaults and SDK updates keep their existing behavior. See the 3.0.0 migration guide.