Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
For #5197: Adds telemetry for media controls
Browse files Browse the repository at this point in the history
  • Loading branch information
sblatz committed Sep 20, 2019
1 parent 89a9b50 commit 57edd3b
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 0 deletions.
24 changes: 24 additions & 0 deletions app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,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<T : Enum<T>>(
Expand Down Expand Up @@ -371,6 +372,12 @@ private val Event.wrapper: EventWrapper<*>?
{ Events.whatsNewTapped.record(it) },
{ Events.whatsNewTappedKeys.valueOf(it) }
)
is Event.TabMediaPlay -> EventWrapper<NoExtraKeys>(
{ Tab.mediaPlay.record(it) }
)
is Event.TabMediaPause -> EventWrapper<NoExtraKeys>(
{ Tab.mediaPause.record(it) }
)

// Don't record other events in Glean:
is Event.AddBookmark -> null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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!!))
}
}
Expand Down
2 changes: 2 additions & 0 deletions docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 57edd3b

Please sign in to comment.