[fenix] For https://github.com/mozilla-mobile/fenix/issues/24210: Remove wrapper from uri opened count.

pull/600/head
mcarare 3 years ago committed by mergify[bot]
parent 16ea15941a
commit 92cca361d4

@ -32,7 +32,6 @@ sealed class Event {
object CustomTabsClosed : Event()
object CustomTabsActionTapped : Event()
object CustomTabsMenuOpened : Event()
object NormalAndPrivateUriOpened : Event()
object HistoryOpened : Event()
object HistoryItemShared : Event()
object HistoryItemOpened : Event()

@ -129,9 +129,6 @@ private val Event.wrapper: EventWrapper<*>?
is Event.CustomTabsClosed -> EventWrapper<NoExtraKeys>(
{ CustomTab.closed.record(it) }
)
is Event.NormalAndPrivateUriOpened -> EventWrapper<NoExtraKeys>(
{ Events.normalAndPrivateUriCount.add(1) }
)
is Event.HistoryOpened -> EventWrapper<NoExtraKeys>(
{ History.opened.record(it) }
)

@ -20,6 +20,7 @@ import mozilla.components.lib.state.Middleware
import mozilla.components.lib.state.MiddlewareContext
import mozilla.components.support.base.android.Clock
import mozilla.components.support.base.log.logger.Logger
import org.mozilla.fenix.GleanMetrics.Events
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.components.metrics.MetricController
import org.mozilla.fenix.utils.Settings
@ -51,7 +52,7 @@ class TelemetryMiddleware(
context.state.findTab(action.sessionId)?.let { tab ->
// Record UriOpened event when a non-private page finishes loading
if (tab.content.loading && !action.loading) {
metrics.track(Event.NormalAndPrivateUriOpened)
Events.normalAndPrivateUriCount.add()
}
}
}

@ -30,6 +30,7 @@ import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.fenix.GleanMetrics.Events
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.components.metrics.MetricController
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
@ -183,23 +184,30 @@ class TelemetryMiddlewareTest {
@Test
fun `GIVEN a normal page is loading WHEN loading is complete THEN we record a UriOpened event`() {
val tab = createTab(id = "1", url = "https://mozilla.org")
assertFalse(Events.normalAndPrivateUriCount.testHasValue())
store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking()
store.dispatch(ContentAction.UpdateLoadingStateAction(tab.id, true)).joinBlocking()
verify(exactly = 0) { metrics.track(Event.NormalAndPrivateUriOpened) }
assertFalse(Events.normalAndPrivateUriCount.testHasValue())
store.dispatch(ContentAction.UpdateLoadingStateAction(tab.id, false)).joinBlocking()
verify(exactly = 1) { metrics.track(Event.NormalAndPrivateUriOpened) }
assertTrue(Events.normalAndPrivateUriCount.testHasValue())
val count = Events.normalAndPrivateUriCount.testGetValue()
assertEquals(1, count)
}
@Test
fun `GIVEN a private page is loading WHEN loading is complete THEN we record a UriOpened event`() {
val tab = createTab(id = "1", url = "https://mozilla.org", private = true)
assertFalse(Events.normalAndPrivateUriCount.testHasValue())
store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking()
store.dispatch(ContentAction.UpdateLoadingStateAction(tab.id, true)).joinBlocking()
verify(exactly = 0) { metrics.track(Event.NormalAndPrivateUriOpened) }
assertFalse(Events.normalAndPrivateUriCount.testHasValue())
store.dispatch(ContentAction.UpdateLoadingStateAction(tab.id, false)).joinBlocking()
verify(exactly = 1) { metrics.track(Event.NormalAndPrivateUriOpened) }
val count = Events.normalAndPrivateUriCount.testGetValue()
assertEquals(1, count)
}
@Test

Loading…
Cancel
Save