diff --git a/app/metrics.yaml b/app/metrics.yaml index f049e6fa8..6b37e9d31 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -4769,3 +4769,104 @@ awesomebar: notification_emails: - fenix-core@mozilla.com expires: "2021-08-01" + +android_keystore_experiment: + experiment_failure: + type: event + description: | + Records an instance of an unexpected failure during the experiment + extra_keys: + failure_exception: + description: | + Exception class associated with an unexpected failure of this + experiment, not caught by the other failure handlers. + bugs: + - https://github.com/mozilla-mobile/fenix/issues/17869 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/18333#pullrequestreview-612447395 + data_sensitivity: + - technical + notification_emails: + - fenix-core@mozilla.com + expires: "2021-09-01" + get_failure: + type: event + description: | + Unexpected failure when trying to read from secure prefs. + extra_keys: + failure_exception: + description: | + Exception class associated with an unexpected failure of this + experiment. + bugs: + - https://github.com/mozilla-mobile/fenix/issues/17869 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/18333#pullrequestreview-612447395 + data_sensitivity: + - technical + notification_emails: + - fenix-core@mozilla.com + expires: "2021-09-01" + get_result: + type: event + description: | + Success when trying to read from secure prefs. + extra_keys: + result: + description: | + Result code identifying whether the read operation returned the + expected value or not. + bugs: + - https://github.com/mozilla-mobile/fenix/issues/17869 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/18333#pullrequestreview-612447395 + data_sensitivity: + - technical + notification_emails: + - fenix-core@mozilla.com + expires: "2021-09-01" + write_failure: + type: event + description: | + Unexpected failure when trying to write to secure prefs. + extra_keys: + failure_exception: + description: | + Exception class associated with an unexpected failure of this + experiment. + bugs: + - https://github.com/mozilla-mobile/fenix/issues/17869 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/18333#pullrequestreview-612447395 + data_sensitivity: + - technical + notification_emails: + - fenix-core@mozilla.com + expires: "2021-09-01" + write_success: + type: event + description: | + Success in writing to secure prefs. + bugs: + - https://github.com/mozilla-mobile/fenix/issues/17869 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/18333#pullrequestreview-612447395 + data_sensitivity: + - technical + notification_emails: + - fenix-core@mozilla.com + expires: "2021-09-01" + reset: + type: event + description: | + An experiment failed, and was reset to run again in the future from a + blank state. + bugs: + - https://github.com/mozilla-mobile/fenix/issues/17869 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/18333#pullrequestreview-612447395 + data_sensitivity: + - technical + notification_emails: + - fenix-core@mozilla.com + expires: "2021-09-01" diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt index d211af7de..b0f0f32d7 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt @@ -9,6 +9,7 @@ import mozilla.components.browser.errorpages.ErrorType import mozilla.components.browser.state.search.SearchEngine import mozilla.components.feature.top.sites.TopSite import org.mozilla.fenix.GleanMetrics.Addons +import org.mozilla.fenix.GleanMetrics.AndroidKeystoreExperiment import org.mozilla.fenix.GleanMetrics.AppTheme import org.mozilla.fenix.GleanMetrics.Autoplay import org.mozilla.fenix.GleanMetrics.Collections @@ -233,6 +234,25 @@ sealed class Event { get() = hashMapOf(TopSites.swipeCarouselKeys.page to page.toString()) } + data class SecurePrefsExperimentFailure(val failureException: String) : Event() { + override val extras = + mapOf(AndroidKeystoreExperiment.experimentFailureKeys.failureException to failureException) + } + data class SecurePrefsGetFailure(val failureException: String) : Event() { + override val extras = + mapOf(AndroidKeystoreExperiment.getFailureKeys.failureException to failureException) + } + data class SecurePrefsGetSuccess(val successCode: String) : Event() { + override val extras = + mapOf(AndroidKeystoreExperiment.getResultKeys.result to successCode) + } + data class SecurePrefsWriteFailure(val failureException: String) : Event() { + override val extras = + mapOf(AndroidKeystoreExperiment.writeFailureKeys.failureException to failureException) + } + object SecurePrefsWriteSuccess : Event() + object SecurePrefsReset : Event() + data class TopSiteLongPress(val type: TopSite.Type) : Event() { override val extras: Map? get() = hashMapOf(TopSites.longPressKeys.type to type.name) diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt index f62d8c17c..f0cbcfaa0 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt @@ -14,6 +14,7 @@ import mozilla.components.service.glean.private.NoExtraKeys import mozilla.components.support.base.log.logger.Logger import org.mozilla.fenix.GleanMetrics.AboutPage import org.mozilla.fenix.GleanMetrics.Addons +import org.mozilla.fenix.GleanMetrics.AndroidKeystoreExperiment import org.mozilla.fenix.GleanMetrics.AppTheme import org.mozilla.fenix.GleanMetrics.Autoplay import org.mozilla.fenix.GleanMetrics.Awesomebar @@ -788,6 +789,29 @@ private val Event.wrapper: EventWrapper<*>? { Awesomebar.openedTabSuggestionClicked.record(it) } ) + is Event.SecurePrefsExperimentFailure -> EventWrapper( + { AndroidKeystoreExperiment.experimentFailure.record(it) }, + { AndroidKeystoreExperiment.experimentFailureKeys.valueOf(it) } + ) + is Event.SecurePrefsGetFailure -> EventWrapper( + { AndroidKeystoreExperiment.getFailure.record(it) }, + { AndroidKeystoreExperiment.getFailureKeys.valueOf(it) } + ) + is Event.SecurePrefsGetSuccess -> EventWrapper( + { AndroidKeystoreExperiment.getResult.record(it) }, + { AndroidKeystoreExperiment.getResultKeys.valueOf(it) } + ) + is Event.SecurePrefsWriteFailure -> EventWrapper( + { AndroidKeystoreExperiment.writeFailure.record(it) }, + { AndroidKeystoreExperiment.writeFailureKeys.valueOf(it) } + ) + is Event.SecurePrefsWriteSuccess -> EventWrapper( + { AndroidKeystoreExperiment.writeSuccess.record(it) } + ) + is Event.SecurePrefsReset -> EventWrapper( + { AndroidKeystoreExperiment.reset.record(it) } + ) + // Don't record other events in Glean: is Event.AddBookmark -> null is Event.OpenedAppFirstRun -> null diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/MetricController.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/MetricController.kt index 649ace833..27fec25a7 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/MetricController.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/MetricController.kt @@ -25,6 +25,7 @@ import mozilla.components.feature.prompts.dialog.LoginDialogFacts import mozilla.components.feature.pwa.ProgressiveWebAppFacts import mozilla.components.feature.syncedtabs.facts.SyncedTabsFacts import mozilla.components.feature.top.sites.facts.TopSitesFacts +import mozilla.components.lib.dataprotect.SecurePrefsReliabilityExperiment import mozilla.components.support.base.Component import mozilla.components.support.base.facts.Action import mozilla.components.support.base.facts.Fact @@ -78,6 +79,7 @@ internal class DebugMetricController( } @VisibleForTesting +@Suppress("LargeClass") internal class ReleaseMetricController( private val services: List, private val isDataTelemetryEnabled: () -> Boolean, @@ -290,6 +292,28 @@ internal class ReleaseMetricController( Component.FEATURE_AWESOMEBAR to AwesomeBarFacts.Items.OPENED_TAB_SUGGESTION_CLICKED -> { Event.OpenedTabSuggestionClicked } + + Component.LIB_DATAPROTECT to SecurePrefsReliabilityExperiment.Companion.Actions.EXPERIMENT -> { + Event.SecurePrefsExperimentFailure(metadata?.get("javaClass") as String? ?: "null") + } + Component.LIB_DATAPROTECT to SecurePrefsReliabilityExperiment.Companion.Actions.GET -> { + if (SecurePrefsReliabilityExperiment.Companion.Values.FAIL.v == value?.toInt()) { + Event.SecurePrefsGetFailure(metadata?.get("javaClass") as String? ?: "null") + } else { + Event.SecurePrefsGetSuccess(value ?: "") + } + } + Component.LIB_DATAPROTECT to SecurePrefsReliabilityExperiment.Companion.Actions.WRITE -> { + if (SecurePrefsReliabilityExperiment.Companion.Values.FAIL.v == value?.toInt()) { + Event.SecurePrefsWriteFailure(metadata?.get("javaClass") as String? ?: "null") + } else { + Event.SecurePrefsWriteSuccess + } + } + Component.LIB_DATAPROTECT to SecurePrefsReliabilityExperiment.Companion.Actions.RESET -> { + Event.SecurePrefsReset + } + else -> null } diff --git a/docs/metrics.md b/docs/metrics.md index 7d5bd9ede..3ccfdb27f 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -56,6 +56,12 @@ In addition to those built-in metrics, the following metrics are added to the pi | about_page.support_tapped |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user tapped on "Support" item from About page |[mozilla-mobile/fenix#8047](https://github.com/mozilla-mobile/fenix/pull/8047), [mozilla-mobile/fenix#13958](https://github.com/mozilla-mobile/fenix/pull/13958#issuecomment-676857877), [mozilla-mobile/fenix#18143](https://github.com/mozilla-mobile/fenix/pull/18143)||2021-07-01 |2 | | addons.open_addon_in_toolbar_menu |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user interacted with an installed add-on in the toolbar menu |[mozilla-mobile/fenix#8318](https://github.com/mozilla-mobile/fenix/pull/8318), [mozilla-mobile/fenix#13958](https://github.com/mozilla-mobile/fenix/pull/13958#issuecomment-676857877), [mozilla-mobile/fenix#18143](https://github.com/mozilla-mobile/fenix/pull/18143)|
  • addon_id: The id of the add-on that was interacted with in the toolbar menu
|2021-07-01 |2 | | addons.open_addons_in_settings |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user accessed "Add-ons" from the Settings |[mozilla-mobile/fenix#8318](https://github.com/mozilla-mobile/fenix/pull/8318), [mozilla-mobile/fenix#13958](https://github.com/mozilla-mobile/fenix/pull/13958#issuecomment-676857877), [mozilla-mobile/fenix#18143](https://github.com/mozilla-mobile/fenix/pull/18143)||2021-07-01 |2 | +| android_keystore_experiment.experiment_failure |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |Records an instance of an unexpected failure during the experiment |[mozilla-mobile/fenix#18333](https://github.com/mozilla-mobile/fenix/pull/18333#pullrequestreview-612447395)|
  • failure_exception: Exception class associated with an unexpected failure of this experiment, not caught by the other failure handlers.
|2021-09-01 |1 | +| android_keystore_experiment.get_failure |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |Unexpected failure when trying to read from secure prefs. |[mozilla-mobile/fenix#18333](https://github.com/mozilla-mobile/fenix/pull/18333#pullrequestreview-612447395)|
  • failure_exception: Exception class associated with an unexpected failure of this experiment.
|2021-09-01 |1 | +| android_keystore_experiment.get_result |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |Success when trying to read from secure prefs. |[mozilla-mobile/fenix#18333](https://github.com/mozilla-mobile/fenix/pull/18333#pullrequestreview-612447395)|
  • result: Result code identifying whether the read operation returned the expected value or not.
|2021-09-01 |1 | +| android_keystore_experiment.reset |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |An experiment failed, and was reset to run again in the future from a blank state. |[mozilla-mobile/fenix#18333](https://github.com/mozilla-mobile/fenix/pull/18333#pullrequestreview-612447395)||2021-09-01 |1 | +| android_keystore_experiment.write_failure |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |Unexpected failure when trying to write to secure prefs. |[mozilla-mobile/fenix#18333](https://github.com/mozilla-mobile/fenix/pull/18333#pullrequestreview-612447395)|
  • failure_exception: Exception class associated with an unexpected failure of this experiment.
|2021-09-01 |1 | +| android_keystore_experiment.write_success |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |Success in writing to secure prefs. |[mozilla-mobile/fenix#18333](https://github.com/mozilla-mobile/fenix/pull/18333#pullrequestreview-612447395)||2021-09-01 |1 | | app_theme.dark_theme_selected |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user selected Dark Theme |[mozilla-mobile/fenix#7968](https://github.com/mozilla-mobile/fenix/pull/7968), [mozilla-mobile/fenix#13958](https://github.com/mozilla-mobile/fenix/pull/13958#issuecomment-676857877), [mozilla-mobile/fenix#18143](https://github.com/mozilla-mobile/fenix/pull/18143)|
  • source: The source from where dark theme was selected. The source can be 'SETTINGS' or 'ONBOARDING'
|2021-07-01 |2 | | autoplay.setting_changed |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user changed their autoplay setting to either block_cellular, block_audio, or block_all. |[mozilla-mobile/fenix#13041](https://github.com/mozilla-mobile/fenix/pull/13041#issuecomment-665777411)|
  • autoplay_setting: The new setting for autoplay: block_cellular, block_audio, or block_all.
|2021-08-01 |2 | | autoplay.visited_setting |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user visited the autoplay settings screen |[mozilla-mobile/fenix#13041](https://github.com/mozilla-mobile/fenix/pull/13041#issuecomment-665777411)||2021-08-01 |2 |