diff --git a/app/metrics.yaml b/app/metrics.yaml index 6625a2393..f7263ad0c 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -1658,6 +1658,41 @@ download_notification: - fenix-core@mozilla.com expires: "2020-03-01" +user_specified_search_engines: + custom_engine_added: + type: event + description: > + A user added a new custom search engine + bugs: + - https://github.com/mozilla-mobile/fenix/issues/5884 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/6918 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" + custom_engine_deleted: + type: event + description: > + A user deleted a custom search engine + bugs: + - https://github.com/mozilla-mobile/fenix/issues/5586 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/6918 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" + search_with_custom_engine: + type: event + description: > + A user performed a search with a custom search engine + bugs: + - https://github.com/mozilla-mobile/fenix/issues/5586 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/6918 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" + search_suggestions: enable_in_private: type: event @@ -1669,4 +1704,4 @@ search_suggestions: - https://github.com/mozilla-mobile/fenix/pull/6746 notification_emails: - fenix-core@mozilla.com - expires: "2020-03-01" \ No newline at end of file + expires: "2020-03-01" 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 f0b8425b6..8bb4ea4fa 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 @@ -42,6 +42,7 @@ import org.mozilla.fenix.GleanMetrics.SyncAuth import org.mozilla.fenix.GleanMetrics.Tab import org.mozilla.fenix.GleanMetrics.ToolbarSettings import org.mozilla.fenix.GleanMetrics.TrackingProtection +import org.mozilla.fenix.GleanMetrics.UserSpecifiedSearchEngines import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.settings import org.mozilla.fenix.utils.BrowsersCache @@ -454,6 +455,15 @@ private val Event.wrapper: EventWrapper<*>? { ToolbarSettings.changedPosition.record(it) }, { ToolbarSettings.changedPositionKeys.valueOf(it) } ) + is Event.CustomEngineAdded -> EventWrapper( + { UserSpecifiedSearchEngines.customEngineAdded.record(it) } + ) + is Event.CustomEngineDeleted -> EventWrapper( + { UserSpecifiedSearchEngines.customEngineDeleted.record(it) } + ) + is Event.SearchWithCustomEngine -> EventWrapper( + { UserSpecifiedSearchEngines.searchWithCustomEngine.record(it) } + ) // Don't record other events in Glean: is Event.AddBookmark -> null is Event.OpenedBookmark -> null diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt index ee5fcd870..5a92b6260 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt @@ -137,6 +137,9 @@ sealed class Event { object OpenOneLogin : Event() object CopyLogin : Event() object ViewLoginPassword : Event() + object CustomEngineAdded : Event() + object CustomEngineDeleted : Event() + object SearchWithCustomEngine : Event() object PrivateBrowsingShowSearchSuggestions : Event() // Interaction events with extras diff --git a/app/src/main/java/org/mozilla/fenix/search/SearchController.kt b/app/src/main/java/org/mozilla/fenix/search/SearchController.kt index 0f31da903..cefca4903 100644 --- a/app/src/main/java/org/mozilla/fenix/search/SearchController.kt +++ b/app/src/main/java/org/mozilla/fenix/search/SearchController.kt @@ -58,6 +58,13 @@ class DefaultSearchController( } context.metrics.track(event) + if (CustomSearchEngineStore.isCustomSearchEngine( + context, + store.state.searchEngineSource.searchEngine.identifier + ) + ) { + context.components.analytics.metrics.track(Event.SearchWithCustomEngine) + } } } @@ -86,6 +93,13 @@ class DefaultSearchController( ) context.metrics.track(Event.EnteredUrl(false)) + if (CustomSearchEngineStore.isCustomSearchEngine( + context, + store.state.searchEngineSource.searchEngine.identifier + ) + ) { + context.components.analytics.metrics.track(Event.SearchWithCustomEngine) + } } override fun handleSearchTermsTapped(searchTerms: String) { @@ -99,6 +113,13 @@ class DefaultSearchController( val event = createSearchEvent(store.state.searchEngineSource.searchEngine, true) context.metrics.track(event) + if (CustomSearchEngineStore.isCustomSearchEngine( + context, + store.state.searchEngineSource.searchEngine.identifier + ) + ) { + context.components.analytics.metrics.track(Event.SearchWithCustomEngine) + } } override fun handleSearchShortcutEngineSelected(searchEngine: SearchEngine) { diff --git a/app/src/main/java/org/mozilla/fenix/settings/search/AddSearchEngineFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/search/AddSearchEngineFragment.kt index 627b23665..71df0ca3e 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/search/AddSearchEngineFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/search/AddSearchEngineFragment.kt @@ -30,6 +30,7 @@ import kotlinx.coroutines.withContext import mozilla.components.browser.search.SearchEngine import org.mozilla.fenix.R import org.mozilla.fenix.components.FenixSnackbar +import org.mozilla.fenix.components.metrics.Event import org.mozilla.fenix.components.searchengine.CustomSearchEngineStore import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.increaseTapArea @@ -211,6 +212,7 @@ class AddSearchEngineFragment : Fragment(), CompoundButton.OnCheckedChangeListen .show() } + context?.components?.analytics?.metrics?.track(Event.CustomEngineAdded) findNavController().popBackStack() } } diff --git a/app/src/main/java/org/mozilla/fenix/settings/search/SearchEngineListPreference.kt b/app/src/main/java/org/mozilla/fenix/settings/search/SearchEngineListPreference.kt index cf19417b6..5df878e3e 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/search/SearchEngineListPreference.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/search/SearchEngineListPreference.kt @@ -23,6 +23,7 @@ import kotlinx.coroutines.MainScope import mozilla.components.browser.search.SearchEngine import mozilla.components.browser.search.provider.SearchEngineList import org.mozilla.fenix.R +import org.mozilla.fenix.components.metrics.Event import org.mozilla.fenix.components.searchengine.CustomSearchEngineStore import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.getRootView @@ -191,6 +192,10 @@ abstract class SearchEngineListPreference @JvmOverloads constructor( .getDefaultEngine(context) .name } + if (CustomSearchEngineStore.isCustomSearchEngine(context, engine.identifier)) { + context.components.analytics.metrics.track(Event.CustomEngineDeleted) + } + refreshSearchEngineViews(context) } ) diff --git a/docs/metrics.md b/docs/metrics.md index 6038ed88d..027ddb57a 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -156,6 +156,9 @@ The following metrics are added to the ping: | tracking_protection.etp_tracker_list |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user pressed into a list of categorized trackers in tracking protection panel. |[1](https://github.com/mozilla-mobile/fenix/pull/5414#issuecomment-532847188)||2020-03-01 | | tracking_protection.exception_added |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user added a tracking protection exception through the TP toggle in the panel. |[1](https://github.com/mozilla-mobile/fenix/pull/5414#issuecomment-532847188)||2020-03-01 | | tracking_protection.panel_settings |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opened tracking protection settings from the panel. |[1](https://github.com/mozilla-mobile/fenix/pull/5414#issuecomment-532847188)||2020-03-01 | +| user_specified_search_engines.custom_engine_added |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user added a new custom search engine |[1](https://github.com/mozilla-mobile/fenix/pull/6918)||2020-03-01 | +| user_specified_search_engines.custom_engine_deleted |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user deleted a custom search engine |[1](https://github.com/mozilla-mobile/fenix/pull/6918)||2020-03-01 | +| user_specified_search_engines.search_with_custom_engine |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user performed a search with a custom search engine |[1](https://github.com/mozilla-mobile/fenix/pull/6918)||2020-03-01 | ## metrics This is a built-in ping that is assembled out of the box by the Glean SDK.