From 5764450e344c288de778b82698490bf09b784971 Mon Sep 17 00:00:00 2001 From: Jeff Boek Date: Tue, 2 Apr 2019 16:47:11 -0700 Subject: [PATCH] For #1036 - Adds Glean metrics for find in page --- app/metrics.yaml | 57 +++++++++++++++++++ .../components/metrics/GleanMetricsService.kt | 20 ++++++- .../metrics/LeanplumMetricsService.kt | 9 +-- 3 files changed, 78 insertions(+), 8 deletions(-) diff --git a/app/metrics.yaml b/app/metrics.yaml index c15854833..9871ab5b6 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -101,6 +101,63 @@ events: - telemetry-client-dev@mozilla.com expires: "2020-03-01" +find_in_page: + opened: + type: event + description: > + A user opened the find in page UI + bugs: + - 1036 + data_reviews: + - TBD + notification_emails: + - telemetry-client-dev@mozilla.com + expires: "2020-03-01" + closed: + type: event + description: > + A user closed the find in page UI + bugs: + - 1036 + data_reviews: + - TBD + notification_emails: + - telemetry-client-dev@mozilla.com + expires: "2020-03-01" + next_result: + type: event + description: > + A user clicked the "next result" button + bugs: + - 1036 + data_reviews: + - TBD + notification_emails: + - telemetry-client-dev@mozilla.com + expires: "2020-03-01" + previous_result: + type: event + description: > + A user clicked the "previous result" button + bugs: + - 1036 + data_reviews: + - TBD + notification_emails: + - telemetry-client-dev@mozilla.com + expires: "2020-03-01" + searched_page: + type: event + description: > + A user searched the page + bugs: + - 1036 + data_reviews: + - TBD + notification_emails: + - telemetry-client-dev@mozilla.com + expires: "2020-03-01" + metrics: default_browser: type: boolean 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 2d443f036..23676967d 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 @@ -5,15 +5,17 @@ package org.mozilla.fenix.components.metrics import android.content.Context import mozilla.components.service.glean.Glean +import mozilla.components.service.glean.metrics.NoExtraKeys import mozilla.components.support.utils.Browsers import org.mozilla.fenix.BuildConfig import org.mozilla.fenix.utils.Settings import org.mozilla.fenix.GleanMetrics.Metrics import org.mozilla.fenix.GleanMetrics.Events +import org.mozilla.fenix.GleanMetrics.FindInPage private class EventWrapper>( private val recorder: ((Map?) -> Unit), - private val keyMapper: ((String) -> T)? + private val keyMapper: ((String) -> T)? = null ) { private val String.asCamelCase: String get() = this.split("_").reduceIndexed { index, acc, s -> @@ -50,6 +52,22 @@ private val Event.wrapper { Events.performedSearch.record(it) }, { Events.performedSearchKeys.valueOf(it) } ) + is Event.FindInPageOpened -> EventWrapper( + { FindInPage.opened.record(it) } + ) + is Event.FindInPageClosed -> EventWrapper( + { FindInPage.closed.record(it) } + ) + is Event.FindInPageNext -> EventWrapper( + { FindInPage.nextResult.record(it) } + ) + is Event.FindInPagePrevious-> EventWrapper( + { FindInPage.previousResult.record(it) } + ) + is Event.FindInPageSearchCommitted -> EventWrapper( + { FindInPage.searchedPage.record(it) } + ) + // Don't track other events with Glean else -> null } diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt index bf4d5da53..33267aeca 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt @@ -45,13 +45,8 @@ private val Event.name: String? is Event.OpenedPocketStory -> "E_Opened_Pocket_Story" is Event.DarkModeEnabled -> "E_Dark_Mode_Enabled" - // Do not track these events in Leanplum - is Event.SearchBarTapped -> "" - is Event.EnteredUrl -> "" - is Event.PerformedSearch -> "" - is Event.SearchShortcutMenuOpened -> "" - is Event.SearchShortcutMenuClosed -> "" - is Event.SearchShortcutSelected -> "" + // Do not track other events in Leanplum + else -> "" } class LeanplumMetricsService(private val application: Application) : MetricsService {