Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
For #15366: Add recently closed tabs metrics from history fragment.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcarare committed Dec 10, 2020
1 parent 1972a16 commit 262a72f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import mozilla.components.concept.engine.prompt.ShareData
import org.mozilla.fenix.R
import org.mozilla.fenix.browser.browsingmode.BrowsingMode
import org.mozilla.fenix.components.FenixSnackbar
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.components.metrics.MetricController

@Suppress("TooManyFunctions")
interface HistoryController {
Expand Down Expand Up @@ -43,7 +45,8 @@ class DefaultHistoryController(
private val displayDeleteAll: () -> Unit,
private val invalidateOptionsMenu: () -> Unit,
private val deleteHistoryItems: (Set<HistoryItem>) -> Unit,
private val syncHistory: suspend () -> Unit
private val syncHistory: suspend () -> Unit,
private val metrics: MetricController
) : HistoryController {
override fun handleOpen(item: HistoryItem, mode: BrowsingMode?) {
openToBrowser(item, mode)
Expand Down Expand Up @@ -111,5 +114,6 @@ class DefaultHistoryController(
HistoryFragmentDirections.actionGlobalRecentlyClosed(),
NavOptions.Builder().setPopUpTo(R.id.recentlyClosedFragment, true).build()
)
metrics.track(Event.RecentlyClosedTabsOpened)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ class HistoryFragment : LibraryPageFragment<HistoryItem>(), UserInteractionHandl
::displayDeleteAllDialog,
::invalidateOptionsMenu,
::deleteHistoryItems,
::syncHistory
)
::syncHistory,
requireComponents.analytics.metrics
)
historyInteractor = HistoryInteractor(
historyController
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.fenix.browser.browsingmode.BrowsingMode
import org.mozilla.fenix.components.FenixSnackbar
import org.mozilla.fenix.components.metrics.MetricController
import org.mozilla.fenix.ext.directionsEq
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner

Expand All @@ -45,6 +46,7 @@ class HistoryControllerTest {
private val invalidateOptionsMenu: () -> Unit = mockk(relaxed = true)
private val deleteHistoryItems: (Set<HistoryItem>) -> Unit = mockk(relaxed = true)
private val syncHistory: suspend () -> Unit = mockk(relaxed = true)
private val metrics: MetricController = mockk(relaxed = true)
private val controller = DefaultHistoryController(
store,
navController,
Expand All @@ -56,7 +58,8 @@ class HistoryControllerTest {
displayDeleteAll,
invalidateOptionsMenu,
deleteHistoryItems,
syncHistory
syncHistory,
metrics
)

@Before
Expand Down

0 comments on commit 262a72f

Please sign in to comment.