1
0
Fork 0

Addresses metrics nits

master
Jeff Boek 2019-03-21 23:05:28 -07:00
parent 51e778ead5
commit ea01ae43be
4 changed files with 47 additions and 31 deletions

View File

@ -1,6 +1,7 @@
# This file defines the metrics that are recorded by glean telemetry. They are # This Source Code Form is subject to the terms of the Mozilla Public
# automatically converted to Kotlin code at build time using the `glean_parser` # License, v. 2.0. If a copy of the MPL was not distributed with this
# PyPI package. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
$schema: moz://mozilla.org/schemas/glean/metrics/1-0-0 $schema: moz://mozilla.org/schemas/glean/metrics/1-0-0
@ -10,53 +11,57 @@ events:
description: > description: >
A user opened the app A user opened the app
extra_keys: extra_keys:
source: "The source from which the app was opened" source:
description: "The method used to open Fenix. Possible values are: `app_icon`, `custom_tab` or `link`"
bugs: bugs:
- 968 - 968
data_reviews: data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/1067#issuecomment-474598673 - https://github.com/mozilla-mobile/fenix/pull/1067#issuecomment-474598673
notification_emails: notification_emails:
- telemetry-client-dev@mozilla.com - telemetry-client-dev@mozilla.com
expires: never expires: "2020-03-01"
search_bar_tapped: search_bar_tapped:
type: event type: event
description: > description: >
A user tapped the search bar A user tapped the search bar
extra_keys: extra_keys:
source: "The source from which the search bar was tapped" source:
description: "The view the user was on when they initiated the search (For example: `Home` or `Browser`)"
bugs: bugs:
- 959 - 959
data_reviews: data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/1067#issuecomment-474598673 - https://github.com/mozilla-mobile/fenix/pull/1067#issuecomment-474598673
notification_emails: notification_emails:
- telemetry-client-dev@mozilla.com - telemetry-client-dev@mozilla.com
expires: never expires: "2020-03-01"
entered_url: entered_url:
type: event type: event
description: > description: >
A user entered a url A user entered a url
extra_keys: extra_keys:
autocomplete: "The url was filled by the autocomplete" autocomplete:
description: "A boolean that tells us whether the URL was autofilled by an Autocomplete suggestion"
bugs: bugs:
- 959 - 959
data_reviews: data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/1067#issuecomment-474598673 - https://github.com/mozilla-mobile/fenix/pull/1067#issuecomment-474598673
notification_emails: notification_emails:
- telemetry-client-dev@mozilla.com - telemetry-client-dev@mozilla.com
expires: never expires: "2020-03-01"
performed_search: performed_search:
type: event type: event
description: > description: >
A user performed a search A user performed a search
extra_keys: extra_keys:
search_suggestion: "The search was initiated from a search suggestion" search_suggestion:
description: "A boolean that tells us whether or not the search term was suggested by the Awesomebar"
bugs: bugs:
- 959 - 959
data_reviews: data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/1067#issuecomment-474598673 - https://github.com/mozilla-mobile/fenix/pull/1067#issuecomment-474598673
notification_emails: notification_emails:
- telemetry-client-dev@mozilla.com - telemetry-client-dev@mozilla.com
expires: never expires: "2020-03-01"
metrics: metrics:
default_browser: default_browser:
@ -71,4 +76,4 @@ metrics:
- https://github.com/mozilla-mobile/fenix/pull/1067#issuecomment-474598673 - https://github.com/mozilla-mobile/fenix/pull/1067#issuecomment-474598673
notification_emails: notification_emails:
- telemetry-client-dev@mozilla.com - telemetry-client-dev@mozilla.com
expires: never expires: "2020-03-01"

View File

@ -76,7 +76,7 @@ open class HomeActivity : AppCompatActivity() {
handleOpenedFromExternalSourceIfNecessary(intent) handleOpenedFromExternalSourceIfNecessary(intent)
} }
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
// There is no session, or it has timed out; we should pop everything to home // There is no session, or it has timed out; we should pop everything to home

View File

@ -12,12 +12,27 @@ import org.mozilla.fenix.utils.Settings
import org.mozilla.fenix.debug.GleanMetrics.Metrics import org.mozilla.fenix.debug.GleanMetrics.Metrics
import org.mozilla.fenix.debug.GleanMetrics.Events import org.mozilla.fenix.debug.GleanMetrics.Events
private val Event.metricType: EventMetricType? private class EventWrapper<T : Enum<T>>(
private val event: EventMetricType<T>,
private val keyMapper: ((String) -> T)? = null
) {
fun track(event: Event) {
val extras = if (keyMapper != null) {
event.extras?.mapKeys { keyMapper.invoke(it.key) }
} else {
null
}
this.event.record(extras)
}
}
private val Event.wrapper
get() = when (this) { get() = when (this) {
is Event.OpenedApp -> Events.appOpened is Event.OpenedApp -> EventWrapper(Events.appOpened) { Events.appOpenedKeys.valueOf(it) }
is Event.SearchBarTapped -> Events.searchBarTapped is Event.SearchBarTapped -> EventWrapper(Events.searchBarTapped) { Events.searchBarTappedKeys.valueOf(it) }
is Event.EnteredUrl -> Events.enteredUrl is Event.EnteredUrl -> EventWrapper(Events.enteredUrl) { Events.enteredUrlKeys.valueOf(it) }
is Event.PerformedSearch -> Events.performedSearch is Event.PerformedSearch -> EventWrapper(Events.performedSearch) { Events.performedSearchKeys.valueOf(it) }
else -> null else -> null
} }
@ -32,11 +47,11 @@ class GleanMetricsService(private val context: Context) : MetricsService {
} }
override fun track(event: Event) { override fun track(event: Event) {
event.metricType?.record(event.extras) event.wrapper?.track(event)
} }
override fun shouldTrack(event: Event): Boolean { override fun shouldTrack(event: Event): Boolean {
return Settings.getInstance(context).isTelemetryEnabled && event.metricType != null return Settings.getInstance(context).isTelemetryEnabled && event.wrapper != null
} }
companion object { companion object {

View File

@ -12,16 +12,12 @@ Fenix creates and tries to send a "baseline" ping. It is defined inside the [`me
## Events ## Events
Fenix sends event pings that allows us to measure feature performance. Fenix sends event pings that allows us to measure feature performance. These are defined inside the [`metrics.yaml`](https://github.com/mozilla-mobile/fenix/blob/master/app/metrics.yaml) file.
| Event | Glean Key | Leanplum Key | extras | ## Leanplum Events
|-----------------|-------------------|--------------|-----------------------|
| OpenedApp | app_opened | E_Opened_App | source* |
| SearchBarTapped | search_bar_tapped | | source** |
| EnteredUrl | entered_url | | autocomplete*** |
| PerformedSearch | performed_search | | search_suggestion**** |
* `source`: The method used to open Fenix (For exmaple: `app_icon` or `link`) | Event | Leanplum Key | extras |
** `source`: The view the user was on when they initiated the search (For example: `Home` or `Browser`) |-----------------|---------------|-----------------------|
*** `autocomplete`: A boolean that tells us wether the URL was autofilled by an Autocomplete suggestion | OpenedApp | E_Opened_App | source* |
**** `search_suggestion`: A boolean that tells us wether or not the search term was suggested by the Awesomebar
* `source`: The method used to open Fenix (For exmaple: `app_icon`, `custom_tab` or `link`)