diff --git a/app/metrics.yaml b/app/metrics.yaml index d628f9860..666325d1f 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -1356,6 +1356,30 @@ private_browsing_shortcut: - fenix-core@mozilla.com expires: "2020-03-01" +tab: + media_play: + type: event + description: > + A user pressed the play icon on a tab from the home screen + bugs: + - 5197 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/5266 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" + media_pause: + type: event + description: > + A user pressed the pause icon on a tab from the home screen + bugs: + - 5197 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/5266 + 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 c19d09589..ddcfaf29a 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 @@ -36,6 +36,7 @@ import org.mozilla.fenix.GleanMetrics.SearchShortcuts import org.mozilla.fenix.GleanMetrics.SearchWidget import org.mozilla.fenix.GleanMetrics.SyncAccount import org.mozilla.fenix.GleanMetrics.SyncAuth +import org.mozilla.fenix.GleanMetrics.Tab import org.mozilla.fenix.ext.components private class EventWrapper>( @@ -370,6 +371,12 @@ private val Event.wrapper: EventWrapper<*>? { Events.whatsNewTapped.record(it) }, { Events.whatsNewTappedKeys.valueOf(it) } ) + is Event.TabMediaPlay -> EventWrapper( + { Tab.mediaPlay.record(it) } + ) + is Event.TabMediaPause -> EventWrapper( + { Tab.mediaPause.record(it) } + ) // Don't record other events in Glean: is Event.AddBookmark -> null 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 3c86d15c8..50eab0bb1 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 @@ -113,6 +113,8 @@ sealed class Event { object PrivateBrowsingPinnedShortcutPrivateTab : Event() object PrivateBrowsingStaticShortcutTab : Event() object PrivateBrowsingStaticShortcutPrivateTab : Event() + object TabMediaPlay : Event() + object TabMediaPause : Event() // Interaction events with extras diff --git a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/TabViewHolder.kt b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/TabViewHolder.kt index 8292411f3..20fad20a9 100644 --- a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/TabViewHolder.kt +++ b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/TabViewHolder.kt @@ -63,10 +63,12 @@ class TabViewHolder( play_pause_button.setOnClickListener { when (tab?.mediaState) { is MediaState.Playing -> { + it.context.components.analytics.metrics.track(Event.TabMediaPlay) actionEmitter.onNext(TabAction.PauseMedia(tab?.sessionId!!)) } is MediaState.Paused -> { + it.context.components.analytics.metrics.track(Event.TabMediaPause) actionEmitter.onNext(TabAction.PlayMedia(tab?.sessionId!!)) } } diff --git a/docs/metrics.md b/docs/metrics.md index b62cf1418..e40bca1b5 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -138,6 +138,8 @@ The following metrics are added to the ping: | sync_auth.sign_in |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user pressed the sign in button on the sync authentication page and was successfully signed in to FxA |[1](https://github.com/mozilla-mobile/fenix/pull/2745#issuecomment-494918532)||2020-03-01 | | sync_auth.sign_out |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user pressed the sign out button on the sync account page and was successfully signed out of FxA |[1](https://github.com/mozilla-mobile/fenix/pull/2745#issuecomment-494918532)||2020-03-01 | | sync_auth.sign_up |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |User registered a new Firefox Account, and was signed into it |[1](https://github.com/mozilla-mobile/fenix/pull/4931#issuecomment-529740300)||2020-03-01 | +| tab.media_pause |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user pressed the pause icon on a tab from the home screen |[1](https://github.com/mozilla-mobile/fenix/pull/5266)||2020-03-01 | +| tab.media_play |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user pressed the play icon on a tab from the home screen |[1](https://github.com/mozilla-mobile/fenix/pull/5266)||2020-03-01 | ## metrics This is a built-in ping that is assembled out of the box by the Glean SDK.