diff --git a/app/metrics.yaml b/app/metrics.yaml index 1c3ba9973ef3..b463a866074c 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -1509,6 +1509,41 @@ media_notification: - fenix-core@mozilla.com expires: "2020-03-01" +media_state: + play: + type: event + description: > + Media started playing. + bugs: + - https://github.com/mozilla-mobile/fenix/issues/5705 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/6463 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" + pause: + type: event + description: > + Media playback was paused. + bugs: + - https://github.com/mozilla-mobile/fenix/issues/5705 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/6463 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" + stop: + type: event + description: > + Media playback has ended. + bugs: + - https://github.com/mozilla-mobile/fenix/issues/5705 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/6463 + 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 a73cf3233dd0..5f2cb10983c8 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 @@ -26,6 +26,7 @@ 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.MediaState import org.mozilla.fenix.GleanMetrics.Metrics import org.mozilla.fenix.GleanMetrics.Pings import org.mozilla.fenix.GleanMetrics.PrivateBrowsingMode @@ -391,6 +392,15 @@ private val Event.wrapper: EventWrapper<*>? is Event.TabMediaPause -> EventWrapper( { Tab.mediaPause.record(it) } ) + is Event.MediaPlayState -> EventWrapper( + { MediaState.play.record(it) } + ) + is Event.MediaPauseState -> EventWrapper( + { MediaState.pause.record(it) } + ) + is Event.MediaStopState -> EventWrapper( + { MediaState.stop.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 92cd478c3e4d..be70457d8161 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 @@ -11,6 +11,7 @@ import mozilla.components.browser.toolbar.facts.ToolbarFacts import mozilla.components.feature.contextmenu.facts.ContextMenuFacts import mozilla.components.feature.customtabs.CustomTabsFacts import mozilla.components.feature.findinpage.facts.FindInPageFacts +import mozilla.components.feature.media.facts.MediaFacts import mozilla.components.support.base.Component import mozilla.components.support.base.facts.Action import mozilla.components.support.base.facts.Fact @@ -119,6 +120,9 @@ sealed class Event { object PrivateBrowsingStaticShortcutPrivateTab : Event() object TabMediaPlay : Event() object TabMediaPause : Event() + object MediaPlayState : Event() + object MediaPauseState : Event() + object MediaStopState : Event() object NotificationMediaPlay : Event() object NotificationMediaPause : Event() object TrackingProtectionTrackerList : Event() @@ -328,7 +332,7 @@ 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" -> { + Component.FEATURE_MEDIA to MediaFacts.Items.NOTIFICATION -> { when (action) { Action.PLAY -> { Event.NotificationMediaPlay @@ -339,6 +343,20 @@ private fun Fact.toEvent(): Event? = when (Pair(component, item)) { else -> null } } + Component.FEATURE_MEDIA to MediaFacts.Items.STATE -> { + when (action) { + Action.PLAY -> { + Event.MediaPlayState + } + Action.PAUSE -> { + Event.MediaPauseState + } + Action.STOP -> { + Event.MediaStopState + } + else -> null + } + } else -> null } diff --git a/docs/metrics.md b/docs/metrics.md index ae40ced469d9..8bfd99801245 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -96,6 +96,9 @@ The following metrics are added to the ping: | 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 | +| media_state.pause |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |Media playback was paused. |[1](https://github.com/mozilla-mobile/fenix/pull/6463)||2020-03-01 | +| media_state.play |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |Media started playing. |[1](https://github.com/mozilla-mobile/fenix/pull/6463)||2020-03-01 | +| media_state.stop |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |Media playback has ended. |[1](https://github.com/mozilla-mobile/fenix/pull/6463)||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 |