From da1419f3575bffc96efc403e4279cb84af269feb Mon Sep 17 00:00:00 2001 From: mcarare Date: Thu, 31 Mar 2022 12:49:22 +0300 Subject: [PATCH] For #24210: Remove wrapper from recently closed tabs opened event. --- .../main/java/org/mozilla/fenix/components/metrics/Event.kt | 1 - .../mozilla/fenix/components/metrics/GleanMetricsService.kt | 4 ---- .../org/mozilla/fenix/library/history/HistoryController.kt | 4 +++- .../java/org/mozilla/fenix/tabstray/NavigationInteractor.kt | 5 +++-- .../org/mozilla/fenix/tabstray/NavigationInteractorTest.kt | 5 +++++ 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt index e69d6cc6f434..3de24afbda88 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt @@ -128,7 +128,6 @@ sealed class Event { object SyncedTabOpened : Event() - object RecentlyClosedTabsOpenedOld : Event() object HaveOpenTabs : Event() object HaveNoOpenTabs : Event() diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt index c3f61e8fca1f..af44ff5e6c22 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt @@ -372,10 +372,6 @@ private val Event.wrapper: EventWrapper<*>? { Events.syncedTabOpened.record(it) } ) - is Event.RecentlyClosedTabsOpenedOld -> EventWrapper( - { Events.recentlyClosedTabsOpened.record(it) } - ) - is Event.TabSettingsOpened -> EventWrapper( { Tabs.settingOpened.record(it) } ) diff --git a/app/src/main/java/org/mozilla/fenix/library/history/HistoryController.kt b/app/src/main/java/org/mozilla/fenix/library/history/HistoryController.kt index e3ac797e314f..94ea01b94916 100644 --- a/app/src/main/java/org/mozilla/fenix/library/history/HistoryController.kt +++ b/app/src/main/java/org/mozilla/fenix/library/history/HistoryController.kt @@ -8,6 +8,8 @@ import androidx.navigation.NavController import androidx.navigation.NavOptions import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch +import mozilla.components.service.glean.private.NoExtras +import org.mozilla.fenix.GleanMetrics.Events import org.mozilla.fenix.R import org.mozilla.fenix.components.metrics.Event import org.mozilla.fenix.components.metrics.MetricController @@ -109,6 +111,6 @@ class DefaultHistoryController( HistoryFragmentDirections.actionGlobalRecentlyClosed(), NavOptions.Builder().setPopUpTo(R.id.recentlyClosedFragment, true).build() ) - metrics.track(Event.RecentlyClosedTabsOpenedOld) + Events.recentlyClosedTabsOpened.record(NoExtras()) } } diff --git a/app/src/main/java/org/mozilla/fenix/tabstray/NavigationInteractor.kt b/app/src/main/java/org/mozilla/fenix/tabstray/NavigationInteractor.kt index 39e74f00a741..e63e529947f0 100644 --- a/app/src/main/java/org/mozilla/fenix/tabstray/NavigationInteractor.kt +++ b/app/src/main/java/org/mozilla/fenix/tabstray/NavigationInteractor.kt @@ -15,9 +15,10 @@ import mozilla.components.browser.state.store.BrowserStore import mozilla.components.browser.storage.sync.Tab as SyncTab import mozilla.components.concept.engine.prompt.ShareData import mozilla.components.service.fxa.manager.FxaAccountManager -import mozilla.telemetry.glean.private.NoExtras +import mozilla.components.service.glean.private.NoExtras import org.mozilla.fenix.BrowserDirection import org.mozilla.fenix.GleanMetrics.Collections +import org.mozilla.fenix.GleanMetrics.Events import org.mozilla.fenix.GleanMetrics.TabsTray import org.mozilla.fenix.HomeActivity import org.mozilla.fenix.collections.CollectionsDialog @@ -145,7 +146,7 @@ class DefaultNavigationInteractor( navController.navigate( TabsTrayFragmentDirections.actionGlobalRecentlyClosed() ) - metrics.track(Event.RecentlyClosedTabsOpenedOld) + Events.recentlyClosedTabsOpened.record(NoExtras()) } override fun onShareTabs(tabs: Collection) { diff --git a/app/src/test/java/org/mozilla/fenix/tabstray/NavigationInteractorTest.kt b/app/src/test/java/org/mozilla/fenix/tabstray/NavigationInteractorTest.kt index 20d1ad29c836..ceb8659c4434 100644 --- a/app/src/test/java/org/mozilla/fenix/tabstray/NavigationInteractorTest.kt +++ b/app/src/test/java/org/mozilla/fenix/tabstray/NavigationInteractorTest.kt @@ -36,6 +36,7 @@ import org.junit.Test import org.junit.rules.RuleChain import org.junit.runner.RunWith import org.mozilla.fenix.BrowserDirection +import org.mozilla.fenix.GleanMetrics.Events import org.mozilla.fenix.GleanMetrics.TabsTray import org.mozilla.fenix.HomeActivity import org.mozilla.fenix.collections.CollectionsDialog @@ -117,8 +118,12 @@ class NavigationInteractorTest { @Test fun `onOpenRecentlyClosedClicked calls navigation on DefaultNavigationInteractor`() { + assertFalse(Events.recentlyClosedTabsOpened.testHasValue()) + createInteractor().onOpenRecentlyClosedClicked() + verify(exactly = 1) { navController.navigate(TabsTrayFragmentDirections.actionGlobalRecentlyClosed()) } + assertTrue(Events.recentlyClosedTabsOpened.testHasValue()) } @Test