mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-17 15:26:23 +00:00
[fenix] For https://github.com/mozilla-mobile/fenix/issues/24809 - Remove Event.wrapper for RecentSearches telemetry
This commit is contained in:
parent
b5cb951ea4
commit
81572369e1
@ -39,9 +39,6 @@ sealed class Event {
|
|||||||
object StartOnHomeEnterHomeScreen : Event()
|
object StartOnHomeEnterHomeScreen : Event()
|
||||||
object StartOnHomeOpenTabsTray : Event()
|
object StartOnHomeOpenTabsTray : Event()
|
||||||
|
|
||||||
// Recently visited/Recent searches
|
|
||||||
object RecentSearchesGroupDeleted : Event()
|
|
||||||
|
|
||||||
// Interaction events with extras
|
// Interaction events with extras
|
||||||
|
|
||||||
data class SearchWithAds(val providerName: String) : Event() {
|
data class SearchWithAds(val providerName: String) : Event() {
|
||||||
|
@ -14,7 +14,6 @@ import org.mozilla.fenix.GleanMetrics.HomeMenu
|
|||||||
import org.mozilla.fenix.GleanMetrics.HomeScreen
|
import org.mozilla.fenix.GleanMetrics.HomeScreen
|
||||||
import org.mozilla.fenix.GleanMetrics.Pings
|
import org.mozilla.fenix.GleanMetrics.Pings
|
||||||
import org.mozilla.fenix.GleanMetrics.ProgressiveWebApp
|
import org.mozilla.fenix.GleanMetrics.ProgressiveWebApp
|
||||||
import org.mozilla.fenix.GleanMetrics.RecentSearches
|
|
||||||
import org.mozilla.fenix.GleanMetrics.RecentlyVisitedHomepage
|
import org.mozilla.fenix.GleanMetrics.RecentlyVisitedHomepage
|
||||||
import org.mozilla.fenix.GleanMetrics.StartOnHome
|
import org.mozilla.fenix.GleanMetrics.StartOnHome
|
||||||
import org.mozilla.fenix.GleanMetrics.SyncedTabs
|
import org.mozilla.fenix.GleanMetrics.SyncedTabs
|
||||||
@ -135,10 +134,6 @@ private val Event.wrapper: EventWrapper<*>?
|
|||||||
{ StartOnHome.openTabsTray.record(it) }
|
{ StartOnHome.openTabsTray.record(it) }
|
||||||
)
|
)
|
||||||
|
|
||||||
is Event.RecentSearchesGroupDeleted -> EventWrapper<NoExtraKeys>(
|
|
||||||
{ RecentSearches.groupDeleted.record(it) }
|
|
||||||
)
|
|
||||||
|
|
||||||
is Event.Messaging.MessageShown -> EventWrapper<NoExtraKeys>(
|
is Event.Messaging.MessageShown -> EventWrapper<NoExtraKeys>(
|
||||||
{
|
{
|
||||||
Messaging.messageShown.record(
|
Messaging.messageShown.record(
|
||||||
|
@ -379,7 +379,6 @@ class HomeFragment : Fragment() {
|
|||||||
storage = components.core.historyStorage,
|
storage = components.core.historyStorage,
|
||||||
scope = viewLifecycleOwner.lifecycleScope,
|
scope = viewLifecycleOwner.lifecycleScope,
|
||||||
store = components.core.store,
|
store = components.core.store,
|
||||||
metrics = requireComponents.analytics.metrics
|
|
||||||
),
|
),
|
||||||
pocketStoriesController = DefaultPocketStoriesController(
|
pocketStoriesController = DefaultPocketStoriesController(
|
||||||
homeActivity = activity,
|
homeActivity = activity,
|
||||||
|
@ -13,11 +13,11 @@ import mozilla.components.browser.state.action.HistoryMetadataAction
|
|||||||
import mozilla.components.browser.state.store.BrowserStore
|
import mozilla.components.browser.state.store.BrowserStore
|
||||||
import mozilla.components.concept.storage.HistoryMetadataStorage
|
import mozilla.components.concept.storage.HistoryMetadataStorage
|
||||||
import mozilla.components.feature.tabs.TabsUseCases.SelectOrAddUseCase
|
import mozilla.components.feature.tabs.TabsUseCases.SelectOrAddUseCase
|
||||||
|
import mozilla.components.service.glean.private.NoExtras
|
||||||
|
import org.mozilla.fenix.GleanMetrics.RecentSearches
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.components.AppStore
|
import org.mozilla.fenix.components.AppStore
|
||||||
import org.mozilla.fenix.components.appstate.AppAction
|
import org.mozilla.fenix.components.appstate.AppAction
|
||||||
import org.mozilla.fenix.components.metrics.Event
|
|
||||||
import org.mozilla.fenix.components.metrics.MetricController
|
|
||||||
import org.mozilla.fenix.home.HomeFragmentDirections
|
import org.mozilla.fenix.home.HomeFragmentDirections
|
||||||
import org.mozilla.fenix.home.recentvisits.RecentlyVisitedItem.RecentHistoryGroup
|
import org.mozilla.fenix.home.recentvisits.RecentlyVisitedItem.RecentHistoryGroup
|
||||||
import org.mozilla.fenix.home.recentvisits.RecentlyVisitedItem.RecentHistoryHighlight
|
import org.mozilla.fenix.home.recentvisits.RecentlyVisitedItem.RecentHistoryHighlight
|
||||||
@ -72,7 +72,6 @@ class DefaultRecentVisitsController(
|
|||||||
private val navController: NavController,
|
private val navController: NavController,
|
||||||
private val storage: HistoryMetadataStorage,
|
private val storage: HistoryMetadataStorage,
|
||||||
private val scope: CoroutineScope,
|
private val scope: CoroutineScope,
|
||||||
private val metrics: MetricController
|
|
||||||
) : RecentVisitsController {
|
) : RecentVisitsController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -115,7 +114,7 @@ class DefaultRecentVisitsController(
|
|||||||
scope.launch {
|
scope.launch {
|
||||||
storage.deleteHistoryMetadata(groupTitle)
|
storage.deleteHistoryMetadata(groupTitle)
|
||||||
}
|
}
|
||||||
metrics.track(Event.RecentSearchesGroupDeleted)
|
RecentSearches.groupDeleted.record(NoExtras())
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,30 +22,37 @@ import mozilla.components.concept.storage.HistoryMetadata
|
|||||||
import mozilla.components.concept.storage.HistoryMetadataKey
|
import mozilla.components.concept.storage.HistoryMetadataKey
|
||||||
import mozilla.components.concept.storage.HistoryMetadataStorage
|
import mozilla.components.concept.storage.HistoryMetadataStorage
|
||||||
import mozilla.components.feature.tabs.TabsUseCases.SelectOrAddUseCase
|
import mozilla.components.feature.tabs.TabsUseCases.SelectOrAddUseCase
|
||||||
|
import mozilla.components.service.glean.testing.GleanTestRule
|
||||||
|
import mozilla.components.support.test.robolectric.testContext
|
||||||
import mozilla.components.support.test.rule.MainCoroutineRule
|
import mozilla.components.support.test.rule.MainCoroutineRule
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
|
import org.junit.Assert.assertFalse
|
||||||
|
import org.junit.Assert.assertTrue
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.mozilla.fenix.GleanMetrics.RecentSearches
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.components.AppStore
|
import org.mozilla.fenix.components.AppStore
|
||||||
import org.mozilla.fenix.components.appstate.AppAction
|
import org.mozilla.fenix.components.appstate.AppAction
|
||||||
import org.mozilla.fenix.components.metrics.Event
|
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
||||||
import org.mozilla.fenix.components.metrics.MetricController
|
|
||||||
import org.mozilla.fenix.home.HomeFragmentDirections
|
import org.mozilla.fenix.home.HomeFragmentDirections
|
||||||
import org.mozilla.fenix.home.recentvisits.RecentlyVisitedItem.RecentHistoryGroup
|
import org.mozilla.fenix.home.recentvisits.RecentlyVisitedItem.RecentHistoryGroup
|
||||||
import org.mozilla.fenix.home.recentvisits.RecentlyVisitedItem.RecentHistoryHighlight
|
import org.mozilla.fenix.home.recentvisits.RecentlyVisitedItem.RecentHistoryHighlight
|
||||||
|
|
||||||
@OptIn(ExperimentalCoroutinesApi::class)
|
@OptIn(ExperimentalCoroutinesApi::class)
|
||||||
|
@RunWith(FenixRobolectricTestRunner::class)
|
||||||
class RecentVisitsControllerTest {
|
class RecentVisitsControllerTest {
|
||||||
|
|
||||||
|
@get:Rule
|
||||||
|
val gleanTestRule = GleanTestRule(testContext)
|
||||||
@get:Rule
|
@get:Rule
|
||||||
val coroutinesTestRule = MainCoroutineRule()
|
val coroutinesTestRule = MainCoroutineRule()
|
||||||
private val testDispatcher = coroutinesTestRule.testDispatcher
|
private val testDispatcher = coroutinesTestRule.testDispatcher
|
||||||
|
|
||||||
private val selectOrAddTabUseCase: SelectOrAddUseCase = mockk(relaxed = true)
|
private val selectOrAddTabUseCase: SelectOrAddUseCase = mockk(relaxed = true)
|
||||||
private val navController = mockk<NavController>(relaxed = true)
|
private val navController = mockk<NavController>(relaxed = true)
|
||||||
private val metrics: MetricController = mockk(relaxed = true)
|
|
||||||
|
|
||||||
private lateinit var storage: HistoryMetadataStorage
|
private lateinit var storage: HistoryMetadataStorage
|
||||||
private lateinit var appStore: AppStore
|
private lateinit var appStore: AppStore
|
||||||
@ -71,7 +78,6 @@ class RecentVisitsControllerTest {
|
|||||||
navController = navController,
|
navController = navController,
|
||||||
scope = scope,
|
scope = scope,
|
||||||
storage = storage,
|
storage = storage,
|
||||||
metrics = metrics
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -140,6 +146,7 @@ class RecentVisitsControllerTest {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
assertFalse(RecentSearches.groupDeleted.testHasValue())
|
||||||
|
|
||||||
controller.handleRemoveRecentHistoryGroup(historyGroup.title)
|
controller.handleRemoveRecentHistoryGroup(historyGroup.title)
|
||||||
|
|
||||||
@ -147,8 +154,8 @@ class RecentVisitsControllerTest {
|
|||||||
verify {
|
verify {
|
||||||
store.dispatch(HistoryMetadataAction.DisbandSearchGroupAction(searchTerm = historyGroup.title))
|
store.dispatch(HistoryMetadataAction.DisbandSearchGroupAction(searchTerm = historyGroup.title))
|
||||||
appStore.dispatch(AppAction.DisbandSearchGroupAction(searchTerm = historyGroup.title))
|
appStore.dispatch(AppAction.DisbandSearchGroupAction(searchTerm = historyGroup.title))
|
||||||
metrics.track(Event.RecentSearchesGroupDeleted)
|
|
||||||
}
|
}
|
||||||
|
assertTrue(RecentSearches.groupDeleted.testHasValue())
|
||||||
|
|
||||||
coVerify {
|
coVerify {
|
||||||
storage.deleteHistoryMetadata(historyGroup.title)
|
storage.deleteHistoryMetadata(historyGroup.title)
|
||||||
|
Loading…
Reference in New Issue
Block a user