Skip to content

Commit

Permalink
For mozilla-mobile#5705 - Adds telemetry for media state
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielluong committed Nov 11, 2019
1 parent 18bfe8c commit 0c16e76
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 1 deletion.
35 changes: 35 additions & 0 deletions app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -391,6 +392,15 @@ private val Event.wrapper: EventWrapper<*>?
is Event.TabMediaPause -> EventWrapper<NoExtraKeys>(
{ Tab.mediaPause.record(it) }
)
is Event.MediaPlayState -> EventWrapper<NoExtraKeys>(
{ MediaState.play.record(it) }
)
is Event.MediaPauseState -> EventWrapper<NoExtraKeys>(
{ MediaState.pause.record(it) }
)
is Event.MediaStopState -> EventWrapper<NoExtraKeys>(
{ MediaState.stop.record(it) }
)
is Event.NotificationMediaPlay -> EventWrapper<NoExtraKeys>(
{ MediaNotification.play.record(it) }
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand All @@ -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
}

Expand Down
3 changes: 3 additions & 0 deletions docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)|<ul><li>item: The library item the user selected</li></ul>|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.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.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.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 |
Expand Down

0 comments on commit 0c16e76

Please sign in to comment.