From a2482cc1a79217733ac82e6c61ce5fe9742deb53 Mon Sep 17 00:00:00 2001 From: Jeff Boek Date: Fri, 12 Apr 2019 13:25:16 -0700 Subject: [PATCH] For #800 - Adds metrics for the default search engine --- app/metrics.yaml | 40 ++++++++++++++++++- .../components/metrics/GleanMetricsService.kt | 15 +++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/app/metrics.yaml b/app/metrics.yaml index efbd0bb2c586..89ea6fb9b2a6 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -326,4 +326,42 @@ metrics: notification_emails: - telemetry-client-dev@mozilla.com - fenix-core@mozilla.com - expires: "2020-03-01" \ No newline at end of file + expires: "2020-03-01" + +search.default_engine: + code: + type: string + description: The search code for the search engine + send_in_pings: + - metrics + bugs: + - 800 + data_reviews: + - TBD + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" + name: + type: string + description: The name of the search engine + send_in_pings: + - metrics + bugs: + - 800 + data_reviews: + - TBD + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" + submission_url: + type: string + description: The full url we use to query the serach engine + send_in_pings: + - metrics + bugs: + - 800 + data_reviews: + - TBD + notification_emails: + - fenix-core@mozilla.com + 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 493e4357153b..480c5878e4be 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 @@ -13,6 +13,8 @@ import org.mozilla.fenix.GleanMetrics.FindInPage import org.mozilla.fenix.GleanMetrics.ContextMenu import org.mozilla.fenix.GleanMetrics.QuickActionSheet import org.mozilla.fenix.GleanMetrics.Metrics +import org.mozilla.fenix.GleanMetrics.SearchDefaultEngine +import org.mozilla.fenix.ext.components private class EventWrapper>( private val recorder: ((Map?) -> Unit), @@ -119,6 +121,19 @@ class GleanMetricsService(private val context: Context) : MetricsService { defaultBrowser.set(Browsers.all(context).isDefaultBrowser) } + SearchDefaultEngine.apply { + val defaultEngine = context + .components + .search + .searchEngineManager + .defaultSearchEngine ?: return@apply + + code.set(defaultEngine.identifier) + name.set(defaultEngine.name) + submissionUrl.set(defaultEngine.buildSearchUrl("")) + } + + initialized = true }