2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-15 18:12:54 +00:00

Close #23694: Add telemetry for history search

This commit is contained in:
Roger Yang 2022-02-11 12:19:13 -05:00 committed by mergify[bot]
parent 80a05bcb37
commit 7d8bad05cd
9 changed files with 60 additions and 0 deletions

View File

@ -3124,6 +3124,32 @@ history:
notification_emails: notification_emails:
- android-probes@mozilla.com - android-probes@mozilla.com
expires: "2022-11-01" expires: "2022-11-01"
search_icon_tapped:
type: event
description: |
A user tapped on the search icon in history.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/23694
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/23695
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: "2023-03-31"
search_result_tapped:
type: event
description: |
A user tapped on the search result in history.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/23694
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/23695
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: "2023-03-31"
recently_closed_tabs: recently_closed_tabs:
opened: opened:

View File

@ -90,6 +90,8 @@ sealed class Event {
object HistorySearchTermGroupOpenTab : Event() object HistorySearchTermGroupOpenTab : Event()
object HistorySearchTermGroupRemoveTab : Event() object HistorySearchTermGroupRemoveTab : Event()
object HistorySearchTermGroupRemoveAll : Event() object HistorySearchTermGroupRemoveAll : Event()
object HistorySearchIconTapped : Event()
object HistorySearchResultTapped : Event()
object RecentlyClosedTabsOpened : Event() object RecentlyClosedTabsOpened : Event()
object RecentlyClosedTabsClosed : Event() object RecentlyClosedTabsClosed : Event()
object RecentlyClosedTabsShowFullHistory : Event() object RecentlyClosedTabsShowFullHistory : Event()

View File

@ -326,6 +326,12 @@ private val Event.wrapper: EventWrapper<*>?
is Event.HistorySearchTermGroupRemoveAll -> EventWrapper<NoExtraKeys>( is Event.HistorySearchTermGroupRemoveAll -> EventWrapper<NoExtraKeys>(
{ History.searchTermGroupRemoveAll.record(it) } { History.searchTermGroupRemoveAll.record(it) }
) )
is Event.HistorySearchIconTapped -> EventWrapper<NoExtraKeys>(
{ History.searchIconTapped.record(it) }
)
is Event.HistorySearchResultTapped -> EventWrapper<NoExtraKeys>(
{ History.searchResultTapped.record(it) }
)
is Event.RecentlyClosedTabsOpened -> EventWrapper<NoExtraKeys>( is Event.RecentlyClosedTabsOpened -> EventWrapper<NoExtraKeys>(
{ RecentlyClosedTabs.opened.record(it) } { RecentlyClosedTabs.opened.record(it) }
) )

View File

@ -244,6 +244,7 @@ class HistoryFragment : LibraryPageFragment<History>(), UserInteractionHandler {
true true
} }
R.id.history_search -> { R.id.history_search -> {
requireComponents.analytics.metrics.track(Event.HistorySearchIconTapped)
historyInteractor.onSearch() historyInteractor.onSearch()
true true
} }

View File

@ -7,6 +7,8 @@ package org.mozilla.fenix.library.history
import mozilla.components.concept.engine.EngineSession.LoadUrlFlags import mozilla.components.concept.engine.EngineSession.LoadUrlFlags
import org.mozilla.fenix.BrowserDirection import org.mozilla.fenix.BrowserDirection
import org.mozilla.fenix.HomeActivity import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.components.metrics.MetricController
/** /**
* An interface that handles the view manipulation of the History Search, triggered by the Interactor * An interface that handles the view manipulation of the History Search, triggered by the Interactor
@ -19,6 +21,7 @@ interface HistorySearchController {
class HistorySearchDialogController( class HistorySearchDialogController(
private val activity: HomeActivity, private val activity: HomeActivity,
private val metrics: MetricController,
private val fragmentStore: HistorySearchFragmentStore, private val fragmentStore: HistorySearchFragmentStore,
private val clearToolbarFocus: () -> Unit, private val clearToolbarFocus: () -> Unit,
) : HistorySearchController { ) : HistorySearchController {
@ -32,6 +35,7 @@ class HistorySearchDialogController(
} }
override fun handleUrlTapped(url: String, flags: LoadUrlFlags) { override fun handleUrlTapped(url: String, flags: LoadUrlFlags) {
metrics.track(Event.HistorySearchResultTapped)
clearToolbarFocus() clearToolbarFocus()
activity.openToBrowserAndLoad( activity.openToBrowserAndLoad(

View File

@ -37,6 +37,7 @@ import org.mozilla.fenix.R
import org.mozilla.fenix.components.toolbar.ToolbarPosition import org.mozilla.fenix.components.toolbar.ToolbarPosition
import org.mozilla.fenix.databinding.FragmentHistorySearchDialogBinding import org.mozilla.fenix.databinding.FragmentHistorySearchDialogBinding
import org.mozilla.fenix.databinding.SearchSuggestionsHintBinding import org.mozilla.fenix.databinding.SearchSuggestionsHintBinding
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.settings import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.library.history.awesomebar.AwesomeBarView import org.mozilla.fenix.library.history.awesomebar.AwesomeBarView
import org.mozilla.fenix.library.history.toolbar.ToolbarView import org.mozilla.fenix.library.history.toolbar.ToolbarView
@ -82,6 +83,7 @@ class HistorySearchDialogFragment : AppCompatDialogFragment(), UserInteractionHa
interactor = HistorySearchDialogInteractor( interactor = HistorySearchDialogInteractor(
HistorySearchDialogController( HistorySearchDialogController(
activity = activity, activity = activity,
metrics = activity.components.analytics.metrics,
fragmentStore = store, fragmentStore = store,
clearToolbarFocus = { clearToolbarFocus = {
dialogHandledAction = true dialogHandledAction = true

View File

@ -189,6 +189,14 @@ class GleanMetricsServiceTest {
assertFalse(History.searchTermGroupRemoveAll.testHasValue()) assertFalse(History.searchTermGroupRemoveAll.testHasValue())
gleanService.track(Event.HistorySearchTermGroupRemoveAll) gleanService.track(Event.HistorySearchTermGroupRemoveAll)
assertTrue(History.searchTermGroupRemoveAll.testHasValue()) assertTrue(History.searchTermGroupRemoveAll.testHasValue())
assertFalse(History.searchIconTapped.testHasValue())
gleanService.track(Event.HistorySearchIconTapped)
assertTrue(History.searchIconTapped.testHasValue())
assertFalse(History.searchResultTapped.testHasValue())
gleanService.track(Event.HistorySearchResultTapped)
assertTrue(History.searchResultTapped.testHasValue())
} }
@Test @Test

View File

@ -340,6 +340,8 @@ class MetricControllerTest {
every { marketingService1.shouldTrack(Event.HistorySearchTermGroupOpenTab) } returns true every { marketingService1.shouldTrack(Event.HistorySearchTermGroupOpenTab) } returns true
every { marketingService1.shouldTrack(Event.HistorySearchTermGroupRemoveTab) } returns true every { marketingService1.shouldTrack(Event.HistorySearchTermGroupRemoveTab) } returns true
every { marketingService1.shouldTrack(Event.HistorySearchTermGroupRemoveAll) } returns true every { marketingService1.shouldTrack(Event.HistorySearchTermGroupRemoveAll) } returns true
every { marketingService1.shouldTrack(Event.HistorySearchIconTapped) } returns true
every { marketingService1.shouldTrack(Event.HistorySearchResultTapped) } returns true
controller.start(MetricServiceType.Marketing) controller.start(MetricServiceType.Marketing)
@ -354,6 +356,8 @@ class MetricControllerTest {
controller.track(Event.HistorySearchTermGroupOpenTab) controller.track(Event.HistorySearchTermGroupOpenTab)
controller.track(Event.HistorySearchTermGroupRemoveTab) controller.track(Event.HistorySearchTermGroupRemoveTab)
controller.track(Event.HistorySearchTermGroupRemoveAll) controller.track(Event.HistorySearchTermGroupRemoveAll)
controller.track(Event.HistorySearchIconTapped)
controller.track(Event.HistorySearchResultTapped)
verify { marketingService1.track(Event.HistoryOpenedInNewTab) } verify { marketingService1.track(Event.HistoryOpenedInNewTab) }
verify { marketingService1.track(Event.HistoryOpenedInNewTabs) } verify { marketingService1.track(Event.HistoryOpenedInNewTabs) }
@ -366,6 +370,8 @@ class MetricControllerTest {
verify { marketingService1.track(Event.HistorySearchTermGroupOpenTab) } verify { marketingService1.track(Event.HistorySearchTermGroupOpenTab) }
verify { marketingService1.track(Event.HistorySearchTermGroupRemoveTab) } verify { marketingService1.track(Event.HistorySearchTermGroupRemoveTab) }
verify { marketingService1.track(Event.HistorySearchTermGroupRemoveAll) } verify { marketingService1.track(Event.HistorySearchTermGroupRemoveAll) }
verify { marketingService1.track(Event.HistorySearchIconTapped) }
verify { marketingService1.track(Event.HistorySearchResultTapped) }
} }
@Test @Test

View File

@ -14,11 +14,14 @@ import org.junit.Before
import org.junit.Test import org.junit.Test
import org.mozilla.fenix.BrowserDirection import org.mozilla.fenix.BrowserDirection
import org.mozilla.fenix.HomeActivity import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.components.metrics.MetricController
class HistorySearchControllerTest { class HistorySearchControllerTest {
@MockK(relaxed = true) private lateinit var activity: HomeActivity @MockK(relaxed = true) private lateinit var activity: HomeActivity
@MockK(relaxed = true) private lateinit var store: HistorySearchFragmentStore @MockK(relaxed = true) private lateinit var store: HistorySearchFragmentStore
@MockK(relaxed = true) private lateinit var metrics: MetricController
@Before @Before
fun setUp() { fun setUp() {
@ -64,6 +67,7 @@ class HistorySearchControllerTest {
createController().handleUrlTapped(url) createController().handleUrlTapped(url)
verify { verify {
metrics.track(Event.HistorySearchResultTapped)
activity.openToBrowserAndLoad( activity.openToBrowserAndLoad(
searchTermOrURL = url, searchTermOrURL = url,
newTab = true, newTab = true,
@ -78,6 +82,7 @@ class HistorySearchControllerTest {
): HistorySearchDialogController { ): HistorySearchDialogController {
return HistorySearchDialogController( return HistorySearchDialogController(
activity = activity, activity = activity,
metrics = metrics,
fragmentStore = store, fragmentStore = store,
clearToolbarFocus = clearToolbarFocus, clearToolbarFocus = clearToolbarFocus,
) )