diff --git a/app/metrics.yaml b/app/metrics.yaml index b463a866074c..5d3742c63b17 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -1560,3 +1560,60 @@ experiments.metrics: notification_emails: - mcooper@mozilla.com expires: 2019-11-01 + +download_notification: + resume: + type: event + description: > + A user resumed a download in the download notification + bugs: + - https://github.com/mozilla-mobile/fenix/issue/5583 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/5520 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" + pause: + type: event + description: > + A user paused a download in the download notification + bugs: + - https://github.com/mozilla-mobile/fenix/issue/5583 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/5520 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" + cancel: + type: event + description: > + A user cancelled a download in the download notification + bugs: + - https://github.com/mozilla-mobile/fenix/issue/5583 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/5520 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" + try_again: + type: event + description: > + A user tapped on try again when a download fails in the download notification + bugs: + - https://github.com/mozilla-mobile/fenix/issue/5583 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/5520 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" + open: + type: event + description: > + A user opened a downloaded file in the download notification + bugs: + - https://github.com/mozilla-mobile/fenix/issue/5583 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/5520 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" 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 5f2cb10983c8..4a0d89243514 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 @@ -20,6 +20,7 @@ import org.mozilla.fenix.GleanMetrics.Collections import org.mozilla.fenix.GleanMetrics.ContextMenu import org.mozilla.fenix.GleanMetrics.CrashReporter import org.mozilla.fenix.GleanMetrics.CustomTab +import org.mozilla.fenix.GleanMetrics.DownloadNotification import org.mozilla.fenix.GleanMetrics.ErrorPage import org.mozilla.fenix.GleanMetrics.Events import org.mozilla.fenix.GleanMetrics.FindInPage @@ -401,6 +402,21 @@ private val Event.wrapper: EventWrapper<*>? is Event.MediaStopState -> EventWrapper( { MediaState.stop.record(it) } ) + is Event.NotificationDownloadCancel -> EventWrapper( + { DownloadNotification.cancel.record(it) } + ) + is Event.NotificationDownloadOpen -> EventWrapper( + { DownloadNotification.open.record(it) } + ) + is Event.NotificationDownloadPause -> EventWrapper( + { DownloadNotification.pause.record(it) } + ) + is Event.NotificationDownloadResume -> EventWrapper( + { DownloadNotification.resume.record(it) } + ) + is Event.NotificationDownloadTryAgain -> EventWrapper( + { DownloadNotification.tryAgain.record(it) } + ) is Event.NotificationMediaPlay -> EventWrapper( { MediaNotification.play.record(it) } ) diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt index be70457d8161..0a4ef85f8a6d 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt @@ -10,6 +10,7 @@ import mozilla.components.browser.search.SearchEngine import mozilla.components.browser.toolbar.facts.ToolbarFacts import mozilla.components.feature.contextmenu.facts.ContextMenuFacts import mozilla.components.feature.customtabs.CustomTabsFacts +import mozilla.components.feature.downloads.facts.DowloadsFacts import mozilla.components.feature.findinpage.facts.FindInPageFacts import mozilla.components.feature.media.facts.MediaFacts import mozilla.components.support.base.Component @@ -123,6 +124,11 @@ sealed class Event { object MediaPlayState : Event() object MediaPauseState : Event() object MediaStopState : Event() + object NotificationDownloadCancel : Event() + object NotificationDownloadOpen : Event() + object NotificationDownloadPause : Event() + object NotificationDownloadResume : Event() + object NotificationDownloadTryAgain : Event() object NotificationMediaPlay : Event() object NotificationMediaPause : Event() object TrackingProtectionTrackerList : Event() @@ -332,28 +338,29 @@ private fun Fact.toEvent(): Event? = when (Pair(component, item)) { Component.FEATURE_CUSTOMTABS to CustomTabsFacts.Items.CLOSE -> Event.CustomTabsClosed Component.FEATURE_CUSTOMTABS to CustomTabsFacts.Items.ACTION_BUTTON -> Event.CustomTabsActionTapped + Component.FEATURE_DOWNLOADS to DownloadsFacts.Items.NOTIFICATION -> { + when (action) { + Action.CANCEL -> Event.NotificationDownloadCancel + Action.OPEN -> Event.NotificationDownloadOpen + Action.PAUSE -> Event.NotificationDownloadPause + Action.RESUME -> Event.NotificationDownloadResume + Action.TRY_AGAIN -> Event.NotificationDownloadTryAgain + else -> null + } + } + Component.FEATURE_MEDIA to MediaFacts.Items.NOTIFICATION -> { when (action) { - Action.PLAY -> { - Event.NotificationMediaPlay - } - Action.PAUSE -> { - Event.NotificationMediaPause - } + Action.PLAY -> Event.NotificationMediaPlay + Action.PAUSE -> Event.NotificationMediaPause else -> null } } Component.FEATURE_MEDIA to MediaFacts.Items.STATE -> { when (action) { - Action.PLAY -> { - Event.MediaPlayState - } - Action.PAUSE -> { - Event.MediaPauseState - } - Action.STOP -> { - Event.MediaStopState - } + Action.PLAY -> Event.MediaPlayState + Action.PAUSE -> Event.MediaPauseState + Action.STOP -> Event.MediaStopState else -> null } }