For #1036 - Adds Glean metrics for find in page
parent
c678b5d7c5
commit
5764450e34
|
@ -101,6 +101,63 @@ events:
|
||||||
- telemetry-client-dev@mozilla.com
|
- telemetry-client-dev@mozilla.com
|
||||||
expires: "2020-03-01"
|
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:
|
metrics:
|
||||||
default_browser:
|
default_browser:
|
||||||
type: boolean
|
type: boolean
|
||||||
|
|
|
@ -5,15 +5,17 @@ package org.mozilla.fenix.components.metrics
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import mozilla.components.service.glean.Glean
|
import mozilla.components.service.glean.Glean
|
||||||
|
import mozilla.components.service.glean.metrics.NoExtraKeys
|
||||||
import mozilla.components.support.utils.Browsers
|
import mozilla.components.support.utils.Browsers
|
||||||
import org.mozilla.fenix.BuildConfig
|
import org.mozilla.fenix.BuildConfig
|
||||||
import org.mozilla.fenix.utils.Settings
|
import org.mozilla.fenix.utils.Settings
|
||||||
import org.mozilla.fenix.GleanMetrics.Metrics
|
import org.mozilla.fenix.GleanMetrics.Metrics
|
||||||
import org.mozilla.fenix.GleanMetrics.Events
|
import org.mozilla.fenix.GleanMetrics.Events
|
||||||
|
import org.mozilla.fenix.GleanMetrics.FindInPage
|
||||||
|
|
||||||
private class EventWrapper<T : Enum<T>>(
|
private class EventWrapper<T : Enum<T>>(
|
||||||
private val recorder: ((Map<T, String>?) -> Unit),
|
private val recorder: ((Map<T, String>?) -> Unit),
|
||||||
private val keyMapper: ((String) -> T)?
|
private val keyMapper: ((String) -> T)? = null
|
||||||
) {
|
) {
|
||||||
private val String.asCamelCase: String
|
private val String.asCamelCase: String
|
||||||
get() = this.split("_").reduceIndexed { index, acc, s ->
|
get() = this.split("_").reduceIndexed { index, acc, s ->
|
||||||
|
@ -50,6 +52,22 @@ private val Event.wrapper
|
||||||
{ Events.performedSearch.record(it) },
|
{ Events.performedSearch.record(it) },
|
||||||
{ Events.performedSearchKeys.valueOf(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
|
else -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,13 +45,8 @@ private val Event.name: String?
|
||||||
is Event.OpenedPocketStory -> "E_Opened_Pocket_Story"
|
is Event.OpenedPocketStory -> "E_Opened_Pocket_Story"
|
||||||
is Event.DarkModeEnabled -> "E_Dark_Mode_Enabled"
|
is Event.DarkModeEnabled -> "E_Dark_Mode_Enabled"
|
||||||
|
|
||||||
// Do not track these events in Leanplum
|
// Do not track other events in Leanplum
|
||||||
is Event.SearchBarTapped -> ""
|
else -> ""
|
||||||
is Event.EnteredUrl -> ""
|
|
||||||
is Event.PerformedSearch -> ""
|
|
||||||
is Event.SearchShortcutMenuOpened -> ""
|
|
||||||
is Event.SearchShortcutMenuClosed -> ""
|
|
||||||
is Event.SearchShortcutSelected -> ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class LeanplumMetricsService(private val application: Application) : MetricsService {
|
class LeanplumMetricsService(private val application: Application) : MetricsService {
|
||||||
|
|
Loading…
Reference in New Issue