From 2bcea1a958a3147be50105d0db64d32a328acc7b Mon Sep 17 00:00:00 2001 From: mcarare Date: Thu, 7 Apr 2022 16:44:25 +0300 Subject: [PATCH] For #24211: Remove wrapper from search related metrics. Removes wrapper from search labeled counter and performed search event. --- app/metrics.yaml | 1 + .../mozilla/fenix/components/metrics/Event.kt | 66 ----- .../components/metrics/GleanMetricsService.kt | 9 - .../fenix/components/metrics/MetricsUtils.kt | 75 ++---- .../intent/SpeechProcessingIntentProcessor.kt | 9 +- .../home/intent/StartSearchIntentProcessor.kt | 6 +- .../SessionControlController.kt | 40 ++- .../fenix/search/SearchDialogController.kt | 31 +-- .../fenix/search/SearchFragmentStore.kt | 9 +- app/src/main/res/navigation/nav_graph.xml | 2 +- .../metrics/MetricsUtilsTestRoboelectric.kt | 60 ----- .../metrics/MetricsUtilsTestRobolectric.kt | 254 ++++++++++++++++++ .../DefaultSessionControlControllerTest.kt | 31 +-- .../intent/StartSearchIntentProcessorTest.kt | 4 +- .../search/SearchDialogControllerTest.kt | 4 +- .../fenix/search/SearchFragmentStoreTest.kt | 14 +- .../fenix/search/toolbar/ToolbarViewTest.kt | 4 +- detekt-baseline.xml | 3 - 18 files changed, 353 insertions(+), 269 deletions(-) delete mode 100644 app/src/test/java/org/mozilla/fenix/components/metrics/MetricsUtilsTestRoboelectric.kt create mode 100644 app/src/test/java/org/mozilla/fenix/components/metrics/MetricsUtilsTestRobolectric.kt diff --git a/app/metrics.yaml b/app/metrics.yaml index 20d5113af83c..6d930ea45165 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -108,6 +108,7 @@ events: * default.suggestion * shortcut.action * shortcut.suggestion + type: string bugs: - https://github.com/mozilla-mobile/fenix/issues/959 - https://github.com/mozilla-mobile/fenix/issues/19923 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 2f94e9e73e8c..97707c3bae1b 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 @@ -4,12 +4,10 @@ package org.mozilla.fenix.components.metrics -import mozilla.components.browser.state.search.SearchEngine import mozilla.components.feature.top.sites.TopSite import org.mozilla.fenix.GleanMetrics.Addons import org.mozilla.fenix.GleanMetrics.Autoplay import org.mozilla.fenix.GleanMetrics.ContextMenu -import org.mozilla.fenix.GleanMetrics.Events import org.mozilla.fenix.GleanMetrics.Pocket import org.mozilla.fenix.GleanMetrics.SearchTerms import org.mozilla.fenix.GleanMetrics.TopSites @@ -178,70 +176,6 @@ sealed class Event { get() = hashMapOf(Addons.openAddonSettingKeys.addonId to addonId) } - data class PerformedSearch(val eventSource: EventSource) : Event() { - sealed class EngineSource { - abstract val engine: SearchEngine - abstract val isCustom: Boolean - - data class Default(override val engine: SearchEngine, override val isCustom: Boolean) : - EngineSource() - - data class Shortcut(override val engine: SearchEngine, override val isCustom: Boolean) : - EngineSource() - - // https://github.com/mozilla-mobile/fenix/issues/1607 - // Sanitize identifiers for custom search engines. - val identifier: String - get() = if (isCustom) "custom" else engine.id - - val searchEngine: SearchEngine - get() = when (this) { - is Default -> engine - is Shortcut -> engine - } - - val descriptor: String - get() = when (this) { - is Default -> "default" - is Shortcut -> "shortcut" - } - } - - sealed class EventSource(open val engineSource: EngineSource) { - data class Suggestion(override val engineSource: EngineSource) : - EventSource(engineSource) - - data class Action(override val engineSource: EngineSource) : EventSource(engineSource) - data class Widget(override val engineSource: EngineSource) : EventSource(engineSource) - data class Shortcut(override val engineSource: EngineSource) : EventSource(engineSource) - data class TopSite(override val engineSource: EngineSource) : EventSource(engineSource) - data class Other(override val engineSource: EngineSource) : EventSource(engineSource) - - private val label: String - get() = when (this) { - is Suggestion -> "suggestion" - is Action -> "action" - is Widget -> "widget" - is Shortcut -> "shortcut" - is TopSite -> "topsite" - is Other -> "other" - } - - val countLabel: String - get() = "${engineSource.identifier.lowercase(Locale.getDefault())}.$label" - - val sourceLabel: String - get() = "${engineSource.descriptor}.$label" - } - - enum class SearchAccessPoint { - SUGGESTION, ACTION, WIDGET, SHORTCUT, TOPSITE, NONE - } - - override val extras: Map? - get() = mapOf(Events.performedSearchKeys.source to eventSource.sourceLabel) - } - data class SearchWithAds(val providerName: String) : Event() { val label: String get() = providerName 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 03e0dca332db..4f7dd4a499b3 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 @@ -16,12 +16,10 @@ import org.mozilla.fenix.GleanMetrics.BrowserSearch import org.mozilla.fenix.GleanMetrics.ContextMenu import org.mozilla.fenix.GleanMetrics.ContextualMenu import org.mozilla.fenix.GleanMetrics.CreditCards -import org.mozilla.fenix.GleanMetrics.Events import org.mozilla.fenix.GleanMetrics.ExperimentsDefaultBrowser import org.mozilla.fenix.GleanMetrics.HomeMenu import org.mozilla.fenix.GleanMetrics.HomeScreen import org.mozilla.fenix.GleanMetrics.MediaState -import org.mozilla.fenix.GleanMetrics.Metrics import org.mozilla.fenix.GleanMetrics.Pings import org.mozilla.fenix.GleanMetrics.Pocket import org.mozilla.fenix.GleanMetrics.ProgressiveWebApp @@ -81,13 +79,6 @@ private class EventWrapper>( // FIXME(#19967): Migrate to non-deprecated API. private val Event.wrapper: EventWrapper<*>? get() = when (this) { - is Event.PerformedSearch -> EventWrapper( - { - Metrics.searchCount[this.eventSource.countLabel].add(1) - Events.performedSearch.record(it) - }, - { Events.performedSearchKeys.valueOf(it) } - ) is Event.SearchWithAds -> EventWrapper( { BrowserSearch.withAds[label].add(1) diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/MetricsUtils.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/MetricsUtils.kt index dc506ff00214..a9e977c885f6 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/MetricsUtils.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/MetricsUtils.kt @@ -13,10 +13,9 @@ import com.google.android.gms.common.GooglePlayServicesRepairableException import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import mozilla.components.browser.state.search.SearchEngine -import mozilla.components.browser.state.state.selectedOrDefaultSearchEngine -import mozilla.components.browser.state.store.BrowserStore import mozilla.components.support.base.log.logger.Logger -import org.mozilla.fenix.components.metrics.Event.PerformedSearch.SearchAccessPoint +import org.mozilla.fenix.GleanMetrics.Events +import org.mozilla.fenix.GleanMetrics.Metrics import java.io.IOException import java.security.NoSuchAlgorithmException import java.security.spec.InvalidKeySpecException @@ -24,53 +23,37 @@ import javax.crypto.SecretKeyFactory import javax.crypto.spec.PBEKeySpec object MetricsUtils { - fun createSearchEvent( + + /** + * Possible sources for a performed search. + */ + enum class Source { + ACTION, SHORTCUT, SUGGESTION, TOPSITE, WIDGET, NONE + } + + /** + * Records the appropriate metric for performed searches. + * @engine the engine used for searching. + * @isDefault whether te engine is the default engine or not. + * @searchAccessPoint the source of the search. Can be one of the values of [Source]. + */ + fun recordSearchMetrics( engine: SearchEngine, - store: BrowserStore, - searchAccessPoint: SearchAccessPoint - ): Event.PerformedSearch? { - val isShortcut = engine != store.state.search.selectedOrDefaultSearchEngine - val isCustom = engine.type == SearchEngine.Type.CUSTOM + isDefault: Boolean, + searchAccessPoint: Source + ) { + val identifier = if (engine.type == SearchEngine.Type.CUSTOM) "custom" else engine.id + val source = searchAccessPoint.name.lowercase() - val engineSource = - if (isShortcut) { - Event.PerformedSearch.EngineSource.Shortcut(engine, isCustom) - } else { - Event.PerformedSearch.EngineSource.Default(engine, isCustom) - } + Metrics.searchCount["$identifier.$source"].add() - return when (searchAccessPoint) { - SearchAccessPoint.SUGGESTION -> Event.PerformedSearch( - Event.PerformedSearch.EventSource.Suggestion( - engineSource - ) - ) - SearchAccessPoint.ACTION -> Event.PerformedSearch( - Event.PerformedSearch.EventSource.Action( - engineSource - ) - ) - SearchAccessPoint.WIDGET -> Event.PerformedSearch( - Event.PerformedSearch.EventSource.Widget( - engineSource - ) - ) - SearchAccessPoint.SHORTCUT -> Event.PerformedSearch( - Event.PerformedSearch.EventSource.Shortcut( - engineSource - ) - ) - SearchAccessPoint.TOPSITE -> Event.PerformedSearch( - Event.PerformedSearch.EventSource.TopSite( - engineSource - ) - ) - SearchAccessPoint.NONE -> Event.PerformedSearch( - Event.PerformedSearch.EventSource.Other( - engineSource - ) - ) + val performedSearchExtra = if (isDefault) { + "default.$source" + } else { + "shortcut.$source" } + + Events.performedSearch.record(Events.PerformedSearchExtra(performedSearchExtra)) } /** diff --git a/app/src/main/java/org/mozilla/fenix/home/intent/SpeechProcessingIntentProcessor.kt b/app/src/main/java/org/mozilla/fenix/home/intent/SpeechProcessingIntentProcessor.kt index ace0aeaccdbe..6aff6ffb4a00 100644 --- a/app/src/main/java/org/mozilla/fenix/home/intent/SpeechProcessingIntentProcessor.kt +++ b/app/src/main/java/org/mozilla/fenix/home/intent/SpeechProcessingIntentProcessor.kt @@ -8,11 +8,11 @@ import android.content.Intent import android.os.StrictMode import androidx.navigation.NavController import mozilla.components.browser.state.search.SearchEngine +import mozilla.components.browser.state.state.selectedOrDefaultSearchEngine import mozilla.components.browser.state.store.BrowserStore import mozilla.components.feature.search.ext.waitForSelectedOrDefaultSearchEngine import org.mozilla.fenix.BrowserDirection import org.mozilla.fenix.HomeActivity -import org.mozilla.fenix.components.metrics.Event import org.mozilla.fenix.components.metrics.MetricController import org.mozilla.fenix.components.metrics.MetricsUtils import org.mozilla.fenix.ext.components @@ -52,12 +52,11 @@ class SpeechProcessingIntentProcessor( private fun launchToBrowser(searchEngine: SearchEngine, text: String) { activity.components.strictMode.resetAfter(StrictMode.allowThreadDiskReads()) { - val searchEvent = MetricsUtils.createSearchEvent( + MetricsUtils.recordSearchMetrics( searchEngine, - store, - Event.PerformedSearch.SearchAccessPoint.WIDGET + searchEngine == store.state.search.selectedOrDefaultSearchEngine, + MetricsUtils.Source.WIDGET ) - searchEvent?.let { metrics.track(it) } } activity.openToBrowserAndLoad( diff --git a/app/src/main/java/org/mozilla/fenix/home/intent/StartSearchIntentProcessor.kt b/app/src/main/java/org/mozilla/fenix/home/intent/StartSearchIntentProcessor.kt index 2bcd2fb2d395..580f6dd58e62 100644 --- a/app/src/main/java/org/mozilla/fenix/home/intent/StartSearchIntentProcessor.kt +++ b/app/src/main/java/org/mozilla/fenix/home/intent/StartSearchIntentProcessor.kt @@ -12,8 +12,8 @@ import org.mozilla.fenix.GleanMetrics.SearchWidget import org.mozilla.fenix.HomeActivity import org.mozilla.fenix.NavGraphDirections import org.mozilla.fenix.R -import org.mozilla.fenix.components.metrics.Event import org.mozilla.fenix.components.metrics.MetricController +import org.mozilla.fenix.components.metrics.MetricsUtils import org.mozilla.fenix.ext.nav /** @@ -30,12 +30,12 @@ class StartSearchIntentProcessor( val source = when (event) { SEARCH_WIDGET -> { SearchWidget.newTabButton.record(NoExtras()) - Event.PerformedSearch.SearchAccessPoint.WIDGET + MetricsUtils.Source.WIDGET } STATIC_SHORTCUT_NEW_TAB, STATIC_SHORTCUT_NEW_PRIVATE_TAB, PRIVATE_BROWSING_PINNED_SHORTCUT -> { - Event.PerformedSearch.SearchAccessPoint.SHORTCUT + MetricsUtils.Source.SHORTCUT } else -> null } diff --git a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlController.kt b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlController.kt index 01e0671fe55f..621232c4679d 100644 --- a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlController.kt +++ b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlController.kt @@ -13,6 +13,7 @@ import androidx.navigation.NavController import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch +import mozilla.components.browser.state.search.SearchEngine import mozilla.components.browser.state.selector.getNormalOrPrivateTabs import mozilla.components.browser.state.state.availableSearchEngines import mozilla.components.browser.state.state.searchEngines @@ -47,7 +48,6 @@ import org.mozilla.fenix.components.metrics.Event import org.mozilla.fenix.components.metrics.MetricController import org.mozilla.fenix.components.metrics.MetricsUtils import org.mozilla.fenix.ext.components -import org.mozilla.fenix.ext.metrics import org.mozilla.fenix.ext.nav import org.mozilla.fenix.ext.settings import org.mozilla.fenix.gleanplumb.Message @@ -420,17 +420,18 @@ class DefaultSessionControlController( SupportUtils.POCKET_TRENDING_URL -> metrics.track(Event.PocketTopSiteClicked) } - val availableEngines = getAvailableSearchEngines() - val searchAccessPoint = Event.PerformedSearch.SearchAccessPoint.TOPSITE - val event = - availableEngines.firstOrNull { engine -> - engine.resultUrls.firstOrNull { it.contains(topSite.url) } != null - }?.let { searchEngine -> - searchAccessPoint.let { sap -> - MetricsUtils.createSearchEvent(searchEngine, store, sap) - } - } - event?.let { activity.metrics.track(it) } + val availableEngines: List = getAvailableSearchEngines() + val searchAccessPoint = MetricsUtils.Source.TOPSITE + + availableEngines.firstOrNull { engine -> + engine.resultUrls.firstOrNull { it.contains(topSite.url) } != null + }?.let { searchEngine -> + MetricsUtils.recordSearchMetrics( + searchEngine, + searchEngine == store.state.search.selectedOrDefaultSearchEngine, + searchAccessPoint + ) + } val tabId = addTabUseCase.invoke( url = appendSearchAttributionToUrlIfNeeded(topSite.url), @@ -596,15 +597,12 @@ class DefaultSessionControlController( if (clipboardText.isUrl() || searchEngine == null) { Events.enteredUrl.record(Events.EnteredUrlExtra(autocomplete = false)) } else { - val searchAccessPoint = Event.PerformedSearch.SearchAccessPoint.ACTION - val event = searchAccessPoint.let { sap -> - MetricsUtils.createSearchEvent( - searchEngine, - store, - sap - ) - } - event?.let { activity.metrics.track(it) } + val searchAccessPoint = MetricsUtils.Source.ACTION + MetricsUtils.recordSearchMetrics( + searchEngine, + searchEngine == store.state.search.selectedOrDefaultSearchEngine, + searchAccessPoint + ) } } diff --git a/app/src/main/java/org/mozilla/fenix/search/SearchDialogController.kt b/app/src/main/java/org/mozilla/fenix/search/SearchDialogController.kt index 38ab54c01401..24140e9243f4 100644 --- a/app/src/main/java/org/mozilla/fenix/search/SearchDialogController.kt +++ b/app/src/main/java/org/mozilla/fenix/search/SearchDialogController.kt @@ -13,6 +13,7 @@ import androidx.annotation.VisibleForTesting import androidx.appcompat.app.AlertDialog import androidx.navigation.NavController import mozilla.components.browser.state.search.SearchEngine +import mozilla.components.browser.state.state.selectedOrDefaultSearchEngine import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.EngineSession.LoadUrlFlags import mozilla.components.feature.tabs.TabsUseCases @@ -22,7 +23,6 @@ import org.mozilla.fenix.GleanMetrics.Events import org.mozilla.fenix.GleanMetrics.SearchShortcuts import org.mozilla.fenix.HomeActivity import org.mozilla.fenix.R -import org.mozilla.fenix.components.metrics.Event import org.mozilla.fenix.components.metrics.MetricController import org.mozilla.fenix.components.metrics.MetricsUtils import org.mozilla.fenix.crashes.CrashListActivity @@ -106,20 +106,15 @@ class SearchDialogController( Events.enteredUrl.record(Events.EnteredUrlExtra(autocomplete = false)) } else { val searchAccessPoint = when (fragmentStore.state.searchAccessPoint) { - Event.PerformedSearch.SearchAccessPoint.NONE -> Event.PerformedSearch.SearchAccessPoint.ACTION + MetricsUtils.Source.NONE -> MetricsUtils.Source.ACTION else -> fragmentStore.state.searchAccessPoint } - val event = searchAccessPoint?.let { sap -> - MetricsUtils.createSearchEvent( - searchEngine, - store, - sap - ) - } - event?.let { - metrics.track(it) - } + MetricsUtils.recordSearchMetrics( + searchEngine, + searchEngine == store.state.search.selectedOrDefaultSearchEngine, + searchAccessPoint + ) } } @@ -176,18 +171,16 @@ class SearchDialogController( ) val searchAccessPoint = when (fragmentStore.state.searchAccessPoint) { - Event.PerformedSearch.SearchAccessPoint.NONE -> Event.PerformedSearch.SearchAccessPoint.SUGGESTION + MetricsUtils.Source.NONE -> MetricsUtils.Source.SUGGESTION else -> fragmentStore.state.searchAccessPoint } - if (searchAccessPoint != null && searchEngine != null) { - MetricsUtils.createSearchEvent( + if (searchEngine != null) { + MetricsUtils.recordSearchMetrics( searchEngine, - store, + searchEngine == store.state.search.selectedOrDefaultSearchEngine, searchAccessPoint - )?.apply { - metrics.track(this) - } + ) } } diff --git a/app/src/main/java/org/mozilla/fenix/search/SearchFragmentStore.kt b/app/src/main/java/org/mozilla/fenix/search/SearchFragmentStore.kt index 464999448287..27fdf5c6e1b5 100644 --- a/app/src/main/java/org/mozilla/fenix/search/SearchFragmentStore.kt +++ b/app/src/main/java/org/mozilla/fenix/search/SearchFragmentStore.kt @@ -15,7 +15,7 @@ import mozilla.components.lib.state.Store import org.mozilla.fenix.HomeActivity import org.mozilla.fenix.browser.browsingmode.BrowsingMode import org.mozilla.fenix.components.Components -import org.mozilla.fenix.components.metrics.Event +import org.mozilla.fenix.components.metrics.MetricsUtils /** * The [Store] for holding the [SearchFragmentState] and applying [SearchFragmentAction]s. @@ -80,16 +80,19 @@ data class SearchFragmentState( val showSyncedTabsSuggestions: Boolean, val tabId: String?, val pastedText: String? = null, - val searchAccessPoint: Event.PerformedSearch.SearchAccessPoint?, + val searchAccessPoint: MetricsUtils.Source, val clipboardHasUrl: Boolean = false ) : State +/** + * Creates the initial state for the search fragment. + */ fun createInitialSearchFragmentState( activity: HomeActivity, components: Components, tabId: String?, pastedText: String?, - searchAccessPoint: Event.PerformedSearch.SearchAccessPoint + searchAccessPoint: MetricsUtils.Source ): SearchFragmentState { val settings = components.settings val tab = tabId?.let { components.core.store.state.findTab(it) } diff --git a/app/src/main/res/navigation/nav_graph.xml b/app/src/main/res/navigation/nav_graph.xml index 8d419b10b84c..fbc9913dee6c 100644 --- a/app/src/main/res/navigation/nav_graph.xml +++ b/app/src/main/res/navigation/nav_graph.xml @@ -211,7 +211,7 @@ + app:argType="org.mozilla.fenix.components.metrics.MetricsUtils$Source" /> ()) } + assertTrue(Events.performedSearch.testHasValue()) + createController().handlePasteAndGo("https://mozilla.org") verify { activity.openToBrowserAndLoad( diff --git a/app/src/test/java/org/mozilla/fenix/home/intent/StartSearchIntentProcessorTest.kt b/app/src/test/java/org/mozilla/fenix/home/intent/StartSearchIntentProcessorTest.kt index 3229d2b8bad7..2cc1b64cebda 100644 --- a/app/src/test/java/org/mozilla/fenix/home/intent/StartSearchIntentProcessorTest.kt +++ b/app/src/test/java/org/mozilla/fenix/home/intent/StartSearchIntentProcessorTest.kt @@ -21,8 +21,8 @@ import org.mozilla.fenix.GleanMetrics.SearchWidget import org.mozilla.fenix.HomeActivity import org.mozilla.fenix.NavGraphDirections import org.mozilla.fenix.R -import org.mozilla.fenix.components.metrics.Event import org.mozilla.fenix.components.metrics.MetricController +import org.mozilla.fenix.components.metrics.MetricsUtils import org.mozilla.fenix.ext.nav import org.mozilla.fenix.helpers.FenixRobolectricTestRunner @@ -77,7 +77,7 @@ class StartSearchIntentProcessorTest { null, NavGraphDirections.actionGlobalSearchDialog( sessionId = null, - searchAccessPoint = Event.PerformedSearch.SearchAccessPoint.WIDGET + searchAccessPoint = MetricsUtils.Source.WIDGET ), options ) diff --git a/app/src/test/java/org/mozilla/fenix/search/SearchDialogControllerTest.kt b/app/src/test/java/org/mozilla/fenix/search/SearchDialogControllerTest.kt index fcbf4a1c1f9a..b6d712c3786d 100644 --- a/app/src/test/java/org/mozilla/fenix/search/SearchDialogControllerTest.kt +++ b/app/src/test/java/org/mozilla/fenix/search/SearchDialogControllerTest.kt @@ -8,8 +8,10 @@ import androidx.appcompat.app.AlertDialog import androidx.navigation.NavController import androidx.navigation.NavDirections import io.mockk.MockKAnnotations +import io.mockk.Runs import io.mockk.every import io.mockk.impl.annotations.MockK +import io.mockk.just import io.mockk.mockk import io.mockk.mockkObject import io.mockk.spyk @@ -78,7 +80,7 @@ class SearchDialogControllerTest { every { navController.currentDestination } returns mockk { every { id } returns R.id.searchDialogFragment } - every { MetricsUtils.createSearchEvent(searchEngine, browserStore, any()) } returns null + every { MetricsUtils.recordSearchMetrics(searchEngine, any(), any()) } just Runs } @After diff --git a/app/src/test/java/org/mozilla/fenix/search/SearchFragmentStoreTest.kt b/app/src/test/java/org/mozilla/fenix/search/SearchFragmentStoreTest.kt index 65e056775a78..dbd31344f067 100644 --- a/app/src/test/java/org/mozilla/fenix/search/SearchFragmentStoreTest.kt +++ b/app/src/test/java/org/mozilla/fenix/search/SearchFragmentStoreTest.kt @@ -28,7 +28,7 @@ import org.mozilla.fenix.HomeActivity import org.mozilla.fenix.browser.browsingmode.BrowsingMode import org.mozilla.fenix.browser.browsingmode.BrowsingModeManager import org.mozilla.fenix.components.Components -import org.mozilla.fenix.components.metrics.Event.PerformedSearch.SearchAccessPoint +import org.mozilla.fenix.components.metrics.MetricsUtils import org.mozilla.fenix.utils.Settings class SearchFragmentStoreTest { @@ -70,7 +70,7 @@ class SearchFragmentStoreTest { showSyncedTabsSuggestions = false, tabId = null, pastedText = "pastedText", - searchAccessPoint = SearchAccessPoint.ACTION + searchAccessPoint = MetricsUtils.Source.ACTION ) assertEquals( @@ -80,7 +80,7 @@ class SearchFragmentStoreTest { components, tabId = null, pastedText = "pastedText", - searchAccessPoint = SearchAccessPoint.ACTION + searchAccessPoint = MetricsUtils.Source.ACTION ) ) assertEquals( @@ -90,7 +90,7 @@ class SearchFragmentStoreTest { components, tabId = "tabId", pastedText = "pastedText", - searchAccessPoint = SearchAccessPoint.ACTION + searchAccessPoint = MetricsUtils.Source.ACTION ) ) } @@ -128,14 +128,14 @@ class SearchFragmentStoreTest { showSyncedTabsSuggestions = false, tabId = "tabId", pastedText = "", - searchAccessPoint = SearchAccessPoint.SHORTCUT + searchAccessPoint = MetricsUtils.Source.SHORTCUT ), createInitialSearchFragmentState( activity, components, tabId = "tabId", pastedText = "", - searchAccessPoint = SearchAccessPoint.SHORTCUT + searchAccessPoint = MetricsUtils.Source.SHORTCUT ) ) } @@ -347,6 +347,6 @@ class SearchFragmentStoreTest { showHistorySuggestions = false, showBookmarkSuggestions = false, showSyncedTabsSuggestions = false, - searchAccessPoint = SearchAccessPoint.NONE + searchAccessPoint = MetricsUtils.Source.NONE ) } diff --git a/app/src/test/java/org/mozilla/fenix/search/toolbar/ToolbarViewTest.kt b/app/src/test/java/org/mozilla/fenix/search/toolbar/ToolbarViewTest.kt index 48c1eacddab1..5c75ea34db5e 100644 --- a/app/src/test/java/org/mozilla/fenix/search/toolbar/ToolbarViewTest.kt +++ b/app/src/test/java/org/mozilla/fenix/search/toolbar/ToolbarViewTest.kt @@ -24,7 +24,7 @@ import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.mozilla.fenix.R -import org.mozilla.fenix.components.metrics.Event +import org.mozilla.fenix.components.metrics.MetricsUtils import org.mozilla.fenix.helpers.FenixRobolectricTestRunner import org.mozilla.fenix.search.SearchEngineSource import org.mozilla.fenix.search.SearchFragmentState @@ -57,7 +57,7 @@ class ToolbarViewTest { showHistorySuggestions = false, showBookmarkSuggestions = false, showSyncedTabsSuggestions = false, - searchAccessPoint = Event.PerformedSearch.SearchAccessPoint.NONE + searchAccessPoint = MetricsUtils.Source.NONE ) @Before diff --git a/detekt-baseline.xml b/detekt-baseline.xml index 05e520a510af..aa59d246425d 100644 --- a/detekt-baseline.xml +++ b/detekt-baseline.xml @@ -436,7 +436,6 @@ UndocumentedPublicClass:Event.kt$Event.OpenedLink$Mode UndocumentedPublicClass:Event.kt$Event.PerformedSearch$EngineSource UndocumentedPublicClass:Event.kt$Event.PerformedSearch$EventSource - UndocumentedPublicClass:Event.kt$Event.PerformedSearch$SearchAccessPoint UndocumentedPublicClass:Event.kt$Event.PerformedSearch.EngineSource$Default : EngineSource UndocumentedPublicClass:Event.kt$Event.PerformedSearch.EngineSource$Shortcut : EngineSource UndocumentedPublicClass:Event.kt$Event.PerformedSearch.EventSource$Action : EventSource @@ -1077,7 +1076,6 @@ UndocumentedPublicFunction:MetricsService.kt$MetricsService$fun start() UndocumentedPublicFunction:MetricsService.kt$MetricsService$fun stop() UndocumentedPublicFunction:MetricsService.kt$MetricsService$fun track(event: Event) - UndocumentedPublicFunction:MetricsUtils.kt$MetricsUtils$fun createSearchEvent( engine: SearchEngine, store: BrowserStore, searchAccessPoint: SearchAccessPoint ): Event.PerformedSearch? UndocumentedPublicFunction:Mode.kt$CurrentMode$fun emitModeChanges() UndocumentedPublicFunction:Mode.kt$CurrentMode$fun getCurrentMode() UndocumentedPublicFunction:Mode.kt$Mode.Companion$fun fromBrowsingMode(browsingMode: BrowsingMode) @@ -1179,7 +1177,6 @@ UndocumentedPublicFunction:SearchDialogController.kt$SearchController$fun handleUrlTapped(url: String, flags: LoadUrlFlags = LoadUrlFlags.none()) UndocumentedPublicFunction:SearchDialogController.kt$SearchDialogController$@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) fun buildDialog(): AlertDialog.Builder UndocumentedPublicFunction:SearchDialogInteractor.kt$SearchDialogInteractor$fun onCameraPermissionsNeeded() - UndocumentedPublicFunction:SearchFragmentStore.kt$fun createInitialSearchFragmentState( activity: HomeActivity, components: Components, tabId: String?, pastedText: String?, searchAccessPoint: Event.PerformedSearch.SearchAccessPoint ): SearchFragmentState UndocumentedPublicFunction:SearchStringValidator.kt$SearchStringValidator$fun isSearchStringValid(client: Client, searchString: String): Result UndocumentedPublicFunction:SearchWidgetProvider.kt$SearchWidgetProvider.Companion$fun updateAllWidgets(context: Context) UndocumentedPublicFunction:SelectBookmarkFolderAdapter.kt$SelectBookmarkFolderAdapter$fun updateData(tree: BookmarkNode?, hideFolderGuid: String?)