diff --git a/app/src/main/java/org/mozilla/fenix/tabstray/browser/TabSorter.kt b/app/src/main/java/org/mozilla/fenix/tabstray/browser/TabSorter.kt index 02d770a981..850fa69b5a 100644 --- a/app/src/main/java/org/mozilla/fenix/tabstray/browser/TabSorter.kt +++ b/app/src/main/java/org/mozilla/fenix/tabstray/browser/TabSorter.kt @@ -32,6 +32,8 @@ class TabSorter( private val concatAdapter: ConcatAdapter, private val store: BrowserStore ) : TabsTray, Observable by ObserverRegistry() { + private var shouldReportMetrics: Boolean = true + override fun updateTabs(tabs: Tabs) { val inactiveTabs = tabs.list.getInactiveTabs(context) val searchTermTabs = tabs.list.getSearchGroupTabs(context) @@ -41,9 +43,6 @@ class TabSorter( // Inactive tabs val selectedInactiveIndex = inactiveTabs.findSelectedIndex(selectedTabId) concatAdapter.inactiveTabsAdapter.updateTabs((Tabs(inactiveTabs, selectedInactiveIndex))) - if (settings.inactiveTabsAreEnabled) { - metrics.track(Event.TabsTrayHasInactiveTabs(inactiveTabs.size)) - } // Tab groups // We don't need to provide a selectedId, because the [TabGroupAdapter] has that built-in with support from @@ -55,6 +54,14 @@ class TabSorter( val totalNormalTabs = (normalTabs + remainderTabs) val selectedTabIndex = totalNormalTabs.findSelectedIndex(selectedTabId) concatAdapter.browserAdapter.updateTabs(Tabs(totalNormalTabs, selectedTabIndex)) + + if (shouldReportMetrics) { + shouldReportMetrics = false + + if (settings.inactiveTabsAreEnabled) { + metrics.track(Event.TabsTrayHasInactiveTabs(inactiveTabs.size)) + } + } } override fun isTabSelected(tabs: Tabs, position: Int): Boolean = false