diff --git a/app/metrics.yaml b/app/metrics.yaml index 821993f7b..7bbd7fc79 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -1446,6 +1446,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" + logins: open_logins: type: event 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 24ca0b9cd..324baf211 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 @@ -27,6 +27,7 @@ import org.mozilla.fenix.GleanMetrics.History import org.mozilla.fenix.GleanMetrics.Library import org.mozilla.fenix.GleanMetrics.Logins 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 @@ -373,6 +374,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 712dee418..122da7a52 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 @@ -113,6 +114,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 218e57a61..24516ec04 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -100,6 +100,9 @@ The following metrics are added to the ping: | logins.view_password_login |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user viewed a password in an individual saved login |[1](https://github.com/mozilla-mobile/fenix/pull/6352)||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 |