Skip to content

Commit

Permalink
For mozilla-mobile#5197: Adds telemetry for media notification (mozil…
Browse files Browse the repository at this point in the history
  • Loading branch information
sblatz committed Sep 27, 2019
1 parent 365936b commit 8c8919a
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
24 changes: 24 additions & 0 deletions app/metrics.yaml
Expand Up @@ -1451,6 +1451,30 @@ tab:
- fenix-core@mozilla.com
expires: "2020-03-01"

media_notification:
play:
type: event
description: >
A user pressed the play icon on the media notification
bugs:
- 5197
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/5520
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
pause:
type: event
description: >
A user pressed the pause icon on the media notification
bugs:
- 5197
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/5520
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"

experiments.metrics:
active_experiment:
type: string
Expand Down
Expand Up @@ -24,6 +24,7 @@ import org.mozilla.fenix.GleanMetrics.Events
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.Metrics
import org.mozilla.fenix.GleanMetrics.Pings
import org.mozilla.fenix.GleanMetrics.PrivateBrowsingMode
Expand Down Expand Up @@ -378,6 +379,12 @@ private val Event.wrapper: EventWrapper<*>?
is Event.TabMediaPause -> EventWrapper<NoExtraKeys>(
{ Tab.mediaPause.record(it) }
)
is Event.NotificationMediaPlay -> EventWrapper<NoExtraKeys>(
{ MediaNotification.play.record(it) }
)
is Event.NotificationMediaPause -> EventWrapper<NoExtraKeys>(
{ MediaNotification.pause.record(it) }
)
is Event.TrackingProtectionTrackerList -> EventWrapper<NoExtraKeys>(
{ TrackingProtection.etpTrackerList.record(it) }
)
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt
Expand Up @@ -8,6 +8,7 @@ import android.content.Context
import mozilla.components.browser.errorpages.ErrorType
import mozilla.components.browser.search.SearchEngine
import mozilla.components.support.base.Component
import mozilla.components.support.base.facts.Action
import mozilla.components.support.base.facts.Fact
import mozilla.components.support.base.facts.FactProcessor
import mozilla.components.support.base.facts.Facts
Expand Down Expand Up @@ -116,6 +117,8 @@ sealed class Event {
object PrivateBrowsingStaticShortcutPrivateTab : Event()
object TabMediaPlay : Event()
object TabMediaPause : Event()
object NotificationMediaPlay : Event()
object NotificationMediaPause : Event()
object TrackingProtectionTrackerList : Event()
object TrackingProtectionIconPressed : Event()
object TrackingProtectionSettingsPanel : Event()
Expand Down Expand Up @@ -312,6 +315,17 @@ private fun Fact.toEvent(): Event? = when (Pair(component, item)) {
Component.FEATURE_CUSTOMTABS to "close" -> Event.CustomTabsClosed
Component.FEATURE_CUSTOMTABS to "action_button" -> Event.CustomTabsActionTapped

Component.FEATURE_MEDIA to "notification" -> {
when (action) {
Action.PLAY -> {
Event.NotificationMediaPlay
}
Action.PAUSE -> {
Event.NotificationMediaPause
}
else -> null
}
}
else -> null
}

Expand Down
2 changes: 2 additions & 0 deletions docs/metrics.md
Expand Up @@ -93,6 +93,8 @@ The following metrics are added to the ping:
| library.closed |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user closed the library |[1](https://github.com/mozilla-mobile/fenix/pull/2538#issuecomment-492830242)||2020-03-01 |
| library.opened |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opened the library |[1](https://github.com/mozilla-mobile/fenix/pull/2538#issuecomment-492830242)||2020-03-01 |
| 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 |
| 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 8c8919a

Please sign in to comment.