From 6babf72352c1f15b2f2d6ed54e4eccdb41c39fe1 Mon Sep 17 00:00:00 2001 From: Sawyer Blatz Date: Fri, 27 Sep 2019 08:02:29 -0700 Subject: [PATCH] For #5197: Adds telemetry for media notification (#5520) --- app/metrics.yaml | 24 +++++++++++++++++++ .../components/metrics/GleanMetricsService.kt | 7 ++++++ .../fenix/components/metrics/Metrics.kt | 14 +++++++++++ docs/metrics.md | 2 ++ 4 files changed, 47 insertions(+) diff --git a/app/metrics.yaml b/app/metrics.yaml index 5b82b2ecd..318e75deb 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -1451,6 +1451,30 @@ tab: - fenix-core@mozilla.com expires: "2020-03-01" +media_notification: + play: + type: event + description: > + A user pressed the play icon on the media notification + bugs: + - 5197 + 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 pressed the pause icon on the media notification + bugs: + - 5197 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/5520 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" + experiments.metrics: active_experiment: type: string 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 8b69e2ad4..d31c26ec4 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 @@ -24,6 +24,7 @@ import org.mozilla.fenix.GleanMetrics.Events import org.mozilla.fenix.GleanMetrics.FindInPage import org.mozilla.fenix.GleanMetrics.History import org.mozilla.fenix.GleanMetrics.Library +import org.mozilla.fenix.GleanMetrics.MediaNotification import org.mozilla.fenix.GleanMetrics.Metrics import org.mozilla.fenix.GleanMetrics.Pings import org.mozilla.fenix.GleanMetrics.PrivateBrowsingMode @@ -378,6 +379,12 @@ private val Event.wrapper: EventWrapper<*>? is Event.TabMediaPause -> EventWrapper( { Tab.mediaPause.record(it) } ) + is Event.NotificationMediaPlay -> EventWrapper( + { MediaNotification.play.record(it) } + ) + is Event.NotificationMediaPause -> EventWrapper( + { MediaNotification.pause.record(it) } + ) is Event.TrackingProtectionTrackerList -> EventWrapper( { TrackingProtection.etpTrackerList.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 81b5f90c5..22c6a213c 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 @@ -12,6 +12,7 @@ import mozilla.components.feature.contextmenu.facts.ContextMenuFacts import mozilla.components.feature.customtabs.CustomTabsFacts import mozilla.components.feature.findinpage.facts.FindInPageFacts import mozilla.components.support.base.Component +import mozilla.components.support.base.facts.Action import mozilla.components.support.base.facts.Fact import mozilla.components.support.base.facts.FactProcessor import mozilla.components.support.base.facts.Facts @@ -120,6 +121,8 @@ sealed class Event { object PrivateBrowsingStaticShortcutPrivateTab : Event() object TabMediaPlay : Event() object TabMediaPause : Event() + object NotificationMediaPlay : Event() + object NotificationMediaPause : Event() object TrackingProtectionTrackerList : Event() object TrackingProtectionIconPressed : Event() object TrackingProtectionSettingsPanel : Event() @@ -316,6 +319,17 @@ 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_MEDIA to "notification" -> { + when (action) { + Action.PLAY -> { + Event.NotificationMediaPlay + } + Action.PAUSE -> { + Event.NotificationMediaPause + } + else -> null + } + } else -> null } diff --git a/docs/metrics.md b/docs/metrics.md index c3b72ac06..24c8a2aa2 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -93,6 +93,8 @@ The following metrics are added to the ping: | library.closed |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user closed the library |[1](https://github.com/mozilla-mobile/fenix/pull/2538#issuecomment-492830242)||2020-03-01 | | library.opened |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opened the library |[1](https://github.com/mozilla-mobile/fenix/pull/2538#issuecomment-492830242)||2020-03-01 | | library.selected_item |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user selected a library item |[1](https://github.com/mozilla-mobile/fenix/pull/2538#issuecomment-492830242)|
  • item: The library item the user selected
|2020-03-01 | +| media_notification.pause |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user pressed the pause icon on the media notification |[1](https://github.com/mozilla-mobile/fenix/pull/5520)||2020-03-01 | +| media_notification.play |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user pressed the play icon on the media notification |[1](https://github.com/mozilla-mobile/fenix/pull/5520)||2020-03-01 | | private_browsing_mode.garbage_icon |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user pressed the garbage can icon on the private browsing home page, deleting all private tabs. |[1](https://github.com/mozilla-mobile/fenix/pull/4968)||2020-03-01 | | private_browsing_mode.notification_delete |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user pressed the private browsing mode notification's "Delete and Open" button. |[1](https://github.com/mozilla-mobile/fenix/pull/4968)||2020-03-01 | | private_browsing_mode.notification_open |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user pressed the private browsing mode notification's "Open" button. |[1](https://github.com/mozilla-mobile/fenix/pull/4968)||2020-03-01 |