For #24603 - Remove Event.wrapper for MediaNotification telemetry

pull/543/head
Alexandru2909 2 years ago committed by mergify[bot]
parent dfdf41d9b1
commit eaaa5ddcdb

@ -42,8 +42,6 @@ sealed class Event {
object MediaStopState : Event()
object MediaFullscreenState : Event()
object MediaPictureInPictureState : Event()
object NotificationMediaPlay : Event()
object NotificationMediaPause : Event()
object TopSiteOpenDefault : Event()
object TopSiteOpenGoogle : Event()
object TopSiteOpenBaidu : Event()

@ -23,7 +23,6 @@ import org.mozilla.fenix.GleanMetrics.ExperimentsDefaultBrowser
import org.mozilla.fenix.GleanMetrics.HomeMenu
import org.mozilla.fenix.GleanMetrics.HomeScreen
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
@ -161,12 +160,6 @@ private val Event.wrapper: EventWrapper<*>?
is Event.MediaPictureInPictureState -> EventWrapper<NoExtraKeys>(
{ MediaState.pictureInPicture.record(it) }
)
is Event.NotificationMediaPlay -> EventWrapper<NoExtraKeys>(
{ MediaNotification.play.record(it) }
)
is Event.NotificationMediaPause -> EventWrapper<NoExtraKeys>(
{ MediaNotification.pause.record(it) }
)
is Event.OpenLogins -> EventWrapper<NoExtraKeys>(
{ Logins.openLogins.record(it) }
)

@ -37,6 +37,7 @@ import mozilla.components.support.webextensions.facts.WebExtensionFacts
import org.mozilla.fenix.BuildConfig
import org.mozilla.fenix.GleanMetrics.Events
import org.mozilla.fenix.GleanMetrics.LoginDialog
import org.mozilla.fenix.GleanMetrics.MediaNotification
import org.mozilla.fenix.GleanMetrics.PerfAwesomebar
import org.mozilla.fenix.search.awesomebar.ShortcutsSuggestionProvider
import org.mozilla.fenix.utils.Settings
@ -115,7 +116,13 @@ internal class ReleaseMetricController(
Component.FEATURE_PROMPTS to LoginDialogFacts.Items.SAVE -> {
LoginDialog.saved.record(NoExtras())
}
Component.FEATURE_MEDIA to MediaFacts.Items.NOTIFICATION -> {
when (action) {
Action.PLAY -> MediaNotification.play.record(NoExtras())
Action.PAUSE -> MediaNotification.pause.record(NoExtras())
else -> Unit
}
}
Component.BROWSER_TOOLBAR to ToolbarFacts.Items.MENU -> {
Events.toolbarMenuVisible.record(NoExtras())
}
@ -215,13 +222,6 @@ internal class ReleaseMetricController(
Component.FEATURE_CUSTOMTABS == component && CustomTabsFacts.Items.CLOSE == item -> Event.CustomTabsClosed
Component.FEATURE_CUSTOMTABS == component && CustomTabsFacts.Items.ACTION_BUTTON == item -> Event.CustomTabsActionTapped
Component.FEATURE_MEDIA == component && MediaFacts.Items.NOTIFICATION == item -> {
when (action) {
Action.PLAY -> Event.NotificationMediaPlay
Action.PAUSE -> Event.NotificationMediaPause
else -> null
}
}
Component.FEATURE_MEDIA == component && MediaFacts.Items.STATE == item -> {
when (action) {
Action.PLAY -> Event.MediaPlayState

@ -12,6 +12,7 @@ import io.mockk.verify
import io.mockk.verifyAll
import mozilla.components.feature.awesomebar.facts.AwesomeBarFacts
import mozilla.components.feature.customtabs.CustomTabsFacts
import mozilla.components.feature.media.facts.MediaFacts
import mozilla.components.feature.prompts.dialog.LoginDialogFacts
import mozilla.components.feature.prompts.facts.CreditCardAutofillDialogFacts
import mozilla.components.feature.pwa.ProgressiveWebAppFacts
@ -30,6 +31,7 @@ import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.fenix.GleanMetrics.LoginDialog
import org.mozilla.fenix.GleanMetrics.MediaNotification
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.utils.Settings
@ -452,6 +454,26 @@ class MetricControllerTest {
}
}
@Test
fun `WHEN processing a FEATURE_MEDIA NOTIFICATION fact THEN the right metric is recorded`() {
val controller = ReleaseMetricController(emptyList(), { true }, { true }, mockk())
val itemsToEvents = listOf(
Action.PLAY to MediaNotification.play,
Action.PAUSE to MediaNotification.pause,
)
itemsToEvents.forEach { (action, event) ->
val fact = Fact(Component.FEATURE_MEDIA, action, MediaFacts.Items.NOTIFICATION)
controller.run {
fact.process()
}
assertEquals(true, event.testHasValue())
assertEquals(1, event.testGetValue().size)
assertEquals(null, event.testGetValue().single().extra)
}
}
@Test
fun `search term group events should be sent to enabled service`() {
val controller = ReleaseMetricController(

Loading…
Cancel
Save