1
0
Fork 0

For #1036 - Adds Glean metrics for find in page

master
Jeff Boek 2019-04-02 16:47:11 -07:00 committed by Colin Lee
parent c678b5d7c5
commit 5764450e34
3 changed files with 78 additions and 8 deletions

View File

@ -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

View File

@ -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<T : Enum<T>>(
private val recorder: ((Map<T, String>?) -> 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<NoExtraKeys>(
{ FindInPage.opened.record(it) }
)
is Event.FindInPageClosed -> EventWrapper<NoExtraKeys>(
{ FindInPage.closed.record(it) }
)
is Event.FindInPageNext -> EventWrapper<NoExtraKeys>(
{ FindInPage.nextResult.record(it) }
)
is Event.FindInPagePrevious-> EventWrapper<NoExtraKeys>(
{ FindInPage.previousResult.record(it) }
)
is Event.FindInPageSearchCommitted -> EventWrapper<NoExtraKeys>(
{ FindInPage.searchedPage.record(it) }
)
// Don't track other events with Glean
else -> null
}

View File

@ -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 {