1
0
Fork 0

For #6174 - Add telemetry for WebExtensions (#8318)

master
Gabriel Luong 2020-04-02 13:12:31 -04:00 committed by GitHub
parent 7043f9ee4e
commit dc6d479da3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 115 additions and 9 deletions

View File

@ -1934,3 +1934,53 @@ installation:
notification_emails: notification_emails:
- fenix-core@mozilla.com - fenix-core@mozilla.com
expires: "2020-09-01" expires: "2020-09-01"
addons:
open_addons_in_settings:
type: event
description: >
A user accessed "Add-ons" from the Settings
bugs:
- https://github.com/mozilla-mobile/fenix/issues/6174
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/8318
notification_emails:
- fenix-core@mozilla.com
expires: "2020-09-01"
open_addon_in_toolbar_menu:
type: event
description: >
A user interacted with an installed add-on in the toolbar menu
bugs:
- https://github.com/mozilla-mobile/fenix/issues/6174
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/8318
notification_emails:
- fenix-core@mozilla.com
expires: "2020-09-01"
has_installed_addons:
type: boolean
description: >
Whether or not the user has installed add-ons on the device.
send_in_pings:
- metrics
bugs:
- https://github.com/mozilla-mobile/fenix/issues/6174
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/8318
notification_emails:
- fenix-core@mozilla.com
expires: "2020-09-01"
has_enabled_addons:
type: boolean
description: >
Whether or not the user has enabled add-ons on the device.
send_in_pings:
- metrics
bugs:
- https://github.com/mozilla-mobile/fenix/issues/6174
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/8318
notification_emails:
- fenix-core@mozilla.com
expires: "2020-09-01"

View File

@ -9,6 +9,7 @@ import mozilla.components.service.glean.Glean
import mozilla.components.service.glean.private.NoExtraKeys import mozilla.components.service.glean.private.NoExtraKeys
import mozilla.components.support.base.log.logger.Logger import mozilla.components.support.base.log.logger.Logger
import org.mozilla.fenix.GleanMetrics.AboutPage import org.mozilla.fenix.GleanMetrics.AboutPage
import org.mozilla.fenix.GleanMetrics.Addons
import org.mozilla.fenix.GleanMetrics.AppTheme import org.mozilla.fenix.GleanMetrics.AppTheme
import org.mozilla.fenix.GleanMetrics.BookmarksManagement import org.mozilla.fenix.GleanMetrics.BookmarksManagement
import org.mozilla.fenix.GleanMetrics.Collections import org.mozilla.fenix.GleanMetrics.Collections
@ -491,6 +492,12 @@ private val Event.wrapper: EventWrapper<*>?
{ AppTheme.darkThemeSelected.record(it) }, { AppTheme.darkThemeSelected.record(it) },
{ AppTheme.darkThemeSelectedKeys.valueOf(it) } { AppTheme.darkThemeSelectedKeys.valueOf(it) }
) )
is Event.AddonsOpenInSettings -> EventWrapper<NoExtraKeys>(
{ Addons.openAddonsInSettings.record(it) }
)
is Event.AddonsOpenInToolbarMenu -> EventWrapper<NoExtraKeys>(
{ Addons.openAddonInToolbarMenu.record(it) }
)
// Don't record other events in Glean: // Don't record other events in Glean:
is Event.AddBookmark -> null is Event.AddBookmark -> null
is Event.OpenedBookmark -> null is Event.OpenedBookmark -> null

View File

@ -6,6 +6,7 @@ package org.mozilla.fenix.components.metrics
import android.content.Context import android.content.Context
import mozilla.components.browser.errorpages.ErrorType import mozilla.components.browser.errorpages.ErrorType
import mozilla.components.browser.menu.facts.BrowserMenuFacts
import mozilla.components.browser.search.SearchEngine import mozilla.components.browser.search.SearchEngine
import mozilla.components.browser.toolbar.facts.ToolbarFacts import mozilla.components.browser.toolbar.facts.ToolbarFacts
import mozilla.components.feature.contextmenu.facts.ContextMenuFacts import mozilla.components.feature.contextmenu.facts.ContextMenuFacts
@ -19,7 +20,9 @@ import mozilla.components.support.base.facts.Fact
import mozilla.components.support.base.facts.FactProcessor import mozilla.components.support.base.facts.FactProcessor
import mozilla.components.support.base.facts.Facts import mozilla.components.support.base.facts.Facts
import mozilla.components.support.base.log.logger.Logger import mozilla.components.support.base.log.logger.Logger
import mozilla.components.support.webextensions.facts.WebExtensionFacts
import org.mozilla.fenix.BuildConfig import org.mozilla.fenix.BuildConfig
import org.mozilla.fenix.GleanMetrics.Addons
import org.mozilla.fenix.GleanMetrics.AppTheme import org.mozilla.fenix.GleanMetrics.AppTheme
import org.mozilla.fenix.GleanMetrics.Collections import org.mozilla.fenix.GleanMetrics.Collections
import org.mozilla.fenix.GleanMetrics.ContextMenu import org.mozilla.fenix.GleanMetrics.ContextMenu
@ -152,10 +155,16 @@ sealed class Event {
object PocketTopSiteClicked : Event() object PocketTopSiteClicked : Event()
object PocketTopSiteRemoved : Event() object PocketTopSiteRemoved : Event()
object FennecToFenixMigrated : Event() object FennecToFenixMigrated : Event()
object AddonsOpenInSettings : Event()
object AddonsOpenInToolbarMenu : Event()
// Interaction events with extras // Interaction events with extras
data class PreferenceToggled(val preferenceKey: String, val enabled: Boolean, val context: Context) : Event() { data class PreferenceToggled(
val preferenceKey: String,
val enabled: Boolean,
val context: Context
) : Event() {
private val booleanPreferenceTelemetryAllowList = listOf( private val booleanPreferenceTelemetryAllowList = listOf(
context.getString(R.string.pref_key_show_search_suggestions), context.getString(R.string.pref_key_show_search_suggestions),
context.getString(R.string.pref_key_remote_debugging), context.getString(R.string.pref_key_remote_debugging),
@ -186,18 +195,21 @@ sealed class Event {
data class ToolbarPositionChanged(val position: Position) : Event() { data class ToolbarPositionChanged(val position: Position) : Event() {
enum class Position { TOP, BOTTOM } enum class Position { TOP, BOTTOM }
override val extras: Map<ToolbarSettings.changedPositionKeys, String>? override val extras: Map<ToolbarSettings.changedPositionKeys, String>?
get() = hashMapOf(ToolbarSettings.changedPositionKeys.position to position.name) get() = hashMapOf(ToolbarSettings.changedPositionKeys.position to position.name)
} }
data class OpenedLink(val mode: Mode) : Event() { data class OpenedLink(val mode: Mode) : Event() {
enum class Mode { NORMAL, PRIVATE } enum class Mode { NORMAL, PRIVATE }
override val extras: Map<Events.openedLinkKeys, String>? override val extras: Map<Events.openedLinkKeys, String>?
get() = hashMapOf(Events.openedLinkKeys.mode to mode.name) get() = hashMapOf(Events.openedLinkKeys.mode to mode.name)
} }
data class TrackingProtectionSettingChanged(val setting: Setting) : Event() { data class TrackingProtectionSettingChanged(val setting: Setting) : Event() {
enum class Setting { STRICT, STANDARD } enum class Setting { STRICT, STANDARD }
override val extras: Map<TrackingProtection.etpSettingChangedKeys, String>? override val extras: Map<TrackingProtection.etpSettingChangedKeys, String>?
get() = hashMapOf(TrackingProtection.etpSettingChangedKeys.etpSetting to setting.name) get() = hashMapOf(TrackingProtection.etpSettingChangedKeys.etpSetting to setting.name)
} }
@ -211,6 +223,7 @@ sealed class Event {
data class OpenedApp(val source: Source) : Event() { data class OpenedApp(val source: Source) : Event() {
enum class Source { APP_ICON, LINK, CUSTOM_TAB } enum class Source { APP_ICON, LINK, CUSTOM_TAB }
override val extras: Map<Events.appOpenedKeys, String>? override val extras: Map<Events.appOpenedKeys, String>?
get() = hashMapOf(Events.appOpenedKeys.source to source.name) get() = hashMapOf(Events.appOpenedKeys.source to source.name)
} }
@ -249,6 +262,7 @@ sealed class Event {
data class SearchBarTapped(val source: Source) : Event() { data class SearchBarTapped(val source: Source) : Event() {
enum class Source { HOME, BROWSER } enum class Source { HOME, BROWSER }
override val extras: Map<Events.searchBarTappedKeys, String>? override val extras: Map<Events.searchBarTappedKeys, String>?
get() = mapOf(Events.searchBarTappedKeys.source to source.name) get() = mapOf(Events.searchBarTappedKeys.source to source.name)
} }
@ -263,8 +277,11 @@ sealed class Event {
abstract val engine: SearchEngine abstract val engine: SearchEngine
abstract val isCustom: Boolean abstract val isCustom: Boolean
data class Default(override val engine: SearchEngine, override val isCustom: Boolean) : EngineSource() data class Default(override val engine: SearchEngine, override val isCustom: Boolean) :
data class Shortcut(override val engine: SearchEngine, override val isCustom: Boolean) : EngineSource() EngineSource()
data class Shortcut(override val engine: SearchEngine, override val isCustom: Boolean) :
EngineSource()
// https://github.com/mozilla-mobile/fenix/issues/1607 // https://github.com/mozilla-mobile/fenix/issues/1607
// Sanitize identifiers for custom search engines. // Sanitize identifiers for custom search engines.
@ -285,7 +302,9 @@ sealed class Event {
} }
sealed class EventSource(open val engineSource: EngineSource) { sealed class EventSource(open val engineSource: EngineSource) {
data class Suggestion(override val engineSource: EngineSource) : EventSource(engineSource) data class Suggestion(override val engineSource: EngineSource) :
EventSource(engineSource)
data class Action(override val engineSource: EngineSource) : EventSource(engineSource) data class Action(override val engineSource: EngineSource) : EventSource(engineSource)
data class Widget(override val engineSource: EngineSource) : EventSource(engineSource) data class Widget(override val engineSource: EngineSource) : EventSource(engineSource)
data class Shortcut(override val engineSource: EngineSource) : EventSource(engineSource) data class Shortcut(override val engineSource: EngineSource) : EventSource(engineSource)
@ -323,6 +342,7 @@ sealed class Event {
data class DarkThemeSelected(val source: Source) : Event() { data class DarkThemeSelected(val source: Source) : Event() {
enum class Source { SETTINGS, ONBOARDING } enum class Source { SETTINGS, ONBOARDING }
override val extras: Map<AppTheme.darkThemeSelectedKeys, String>? override val extras: Map<AppTheme.darkThemeSelectedKeys, String>?
get() = mapOf(AppTheme.darkThemeSelectedKeys.source to source.name) get() = mapOf(AppTheme.darkThemeSelectedKeys.source to source.name)
} }
@ -332,7 +352,8 @@ sealed class Event {
get() = mapOf(ContextMenu.itemTappedKeys.named to item) get() = mapOf(ContextMenu.itemTappedKeys.named to item)
companion object { companion object {
fun create(context_item: String) = allowList[context_item]?.let { ContextMenuItemTapped(it) } fun create(context_item: String) =
allowList[context_item]?.let { ContextMenuItemTapped(it) }
private val allowList = mapOf( private val allowList = mapOf(
"mozac.feature.contextmenu.open_in_new_tab" to "open_in_new_tab", "mozac.feature.contextmenu.open_in_new_tab" to "open_in_new_tab",
@ -380,6 +401,7 @@ private fun Fact.toEvent(): Event? = when (Pair(component, item)) {
Component.BROWSER_TOOLBAR to ToolbarFacts.Items.MENU -> { Component.BROWSER_TOOLBAR to ToolbarFacts.Items.MENU -> {
metadata?.get("customTab")?.let { Event.CustomTabsMenuOpened } metadata?.get("customTab")?.let { Event.CustomTabsMenuOpened }
} }
Component.BROWSER_MENU to BrowserMenuFacts.Items.WEB_EXTENSION_MENU_ITEM -> Event.AddonsOpenInToolbarMenu
Component.FEATURE_CUSTOMTABS to CustomTabsFacts.Items.CLOSE -> Event.CustomTabsClosed Component.FEATURE_CUSTOMTABS to CustomTabsFacts.Items.CLOSE -> Event.CustomTabsClosed
Component.FEATURE_CUSTOMTABS to CustomTabsFacts.Items.ACTION_BUTTON -> Event.CustomTabsActionTapped Component.FEATURE_CUSTOMTABS to CustomTabsFacts.Items.ACTION_BUTTON -> Event.CustomTabsActionTapped
@ -409,6 +431,21 @@ private fun Fact.toEvent(): Event? = when (Pair(component, item)) {
else -> null else -> null
} }
} }
Component.SUPPORT_WEBEXTENSIONS to WebExtensionFacts.Items.WEB_EXTENSIONS_INITIALIZED -> {
metadata?.get("installed")?.let { installedAddons ->
if (installedAddons is List<*>) {
Addons.hasInstalledAddons.set(installedAddons.size > 0)
}
}
metadata?.get("enabled")?.let { enabledAddons ->
if (enabledAddons is List<*>) {
Addons.hasEnabledAddons.set(enabledAddons.size > 0)
}
}
null
}
else -> null else -> null
} }
@ -440,7 +477,8 @@ interface MetricController {
ReleaseMetricController( ReleaseMetricController(
services, services,
isDataTelemetryEnabled, isDataTelemetryEnabled,
isMarketingDataTelemetryEnabled) isMarketingDataTelemetryEnabled
)
} else DebugMetricController() } else DebugMetricController()
} }
} }
@ -480,7 +518,9 @@ private class ReleaseMetricController(
override fun start(type: MetricServiceType) { override fun start(type: MetricServiceType) {
val isEnabled = isTelemetryEnabled(type) val isEnabled = isTelemetryEnabled(type)
val isInitialized = isInitialized(type) val isInitialized = isInitialized(type)
if (!isEnabled || isInitialized) { return } if (!isEnabled || isInitialized) {
return
}
services services
.filter { it.type == type } .filter { it.type == type }
@ -492,7 +532,9 @@ private class ReleaseMetricController(
override fun stop(type: MetricServiceType) { override fun stop(type: MetricServiceType) {
val isEnabled = isTelemetryEnabled(type) val isEnabled = isTelemetryEnabled(type)
val isInitialized = isInitialized(type) val isInitialized = isInitialized(type)
if (isEnabled || !isInitialized) { return } if (isEnabled || !isInitialized) {
return
}
services services
.filter { it.type == type } .filter { it.type == type }
@ -507,7 +549,9 @@ private class ReleaseMetricController(
.forEach { .forEach {
val isEnabled = isTelemetryEnabled(it.type) val isEnabled = isTelemetryEnabled(it.type)
val isInitialized = isInitialized(it.type) val isInitialized = isInitialized(it.type)
if (!isEnabled || !isInitialized) { return } if (!isEnabled || !isInitialized) {
return
}
it.track(event) it.track(event)
} }

View File

@ -210,6 +210,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
SettingsFragmentDirections.actionSettingsFragmentToLocaleSettingsFragment() SettingsFragmentDirections.actionSettingsFragmentToLocaleSettingsFragment()
} }
resources.getString(R.string.pref_key_addons) -> { resources.getString(R.string.pref_key_addons) -> {
requireContext().metrics.track(Event.AddonsOpenInSettings)
SettingsFragmentDirections.actionSettingsFragmentToAddonsFragment() SettingsFragmentDirections.actionSettingsFragmentToAddonsFragment()
} }
resources.getString(R.string.pref_key_make_default_browser) -> { resources.getString(R.string.pref_key_make_default_browser) -> {

View File

@ -54,6 +54,8 @@ The following metrics are added to the ping:
| about_page.privacy_notice_tapped |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user tapped on "Privacy notice" item from About page |[1](https://github.com/mozilla-mobile/fenix/pull/8047)||2020-09-01 | | about_page.privacy_notice_tapped |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user tapped on "Privacy notice" item from About page |[1](https://github.com/mozilla-mobile/fenix/pull/8047)||2020-09-01 |
| about_page.rights_tapped |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user tapped on "Know your rights" item from About page |[1](https://github.com/mozilla-mobile/fenix/pull/8047)||2020-09-01 | | about_page.rights_tapped |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user tapped on "Know your rights" item from About page |[1](https://github.com/mozilla-mobile/fenix/pull/8047)||2020-09-01 |
| about_page.support_tapped |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user tapped on "Support" item from About page |[1](https://github.com/mozilla-mobile/fenix/pull/8047)||2020-09-01 | | about_page.support_tapped |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user tapped on "Support" item from About page |[1](https://github.com/mozilla-mobile/fenix/pull/8047)||2020-09-01 |
| addons.open_addon_in_toolbar_menu |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user interacted with an installed add-on in the toolbar menu |[1](https://github.com/mozilla-mobile/fenix/pull/8318)||2020-09-01 |
| addons.open_addons_in_settings |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user accessed "Add-ons" from the Settings |[1](https://github.com/mozilla-mobile/fenix/pull/8318)||2020-09-01 |
| app_theme.dark_theme_selected |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user selected Dark Theme |[1](https://github.com/mozilla-mobile/fenix/pull/7968)|<ul><li>source: The source from where dark theme was selected. The source can be 'SETTINGS' or 'ONBOARDING'</li></ul>|2020-09-01 | | app_theme.dark_theme_selected |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user selected Dark Theme |[1](https://github.com/mozilla-mobile/fenix/pull/7968)|<ul><li>source: The source from where dark theme was selected. The source can be 'SETTINGS' or 'ONBOARDING'</li></ul>|2020-09-01 |
| bookmarks_management.copied |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user copied a bookmark. |[1](https://github.com/mozilla-mobile/fenix/pull/1708)||2020-09-01 | | bookmarks_management.copied |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user copied a bookmark. |[1](https://github.com/mozilla-mobile/fenix/pull/1708)||2020-09-01 |
| bookmarks_management.edited |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user edited the title and/or URL of an existing bookmark. |[1](https://github.com/mozilla-mobile/fenix/pull/1708)||2020-09-01 | | bookmarks_management.edited |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user edited the title and/or URL of an existing bookmark. |[1](https://github.com/mozilla-mobile/fenix/pull/1708)||2020-09-01 |
@ -203,6 +205,8 @@ The following metrics are added to the ping:
| Name | Type | Description | Data reviews | Extras | Expiration | | Name | Type | Description | Data reviews | Extras | Expiration |
| --- | --- | --- | --- | --- | --- | | --- | --- | --- | --- | --- | --- |
| addons.has_enabled_addons |[boolean](https://mozilla.github.io/glean/book/user/metrics/boolean.html) |Whether or not the user has enabled add-ons on the device. |[1](https://github.com/mozilla-mobile/fenix/pull/8318)||2020-09-01 |
| addons.has_installed_addons |[boolean](https://mozilla.github.io/glean/book/user/metrics/boolean.html) |Whether or not the user has installed add-ons on the device. |[1](https://github.com/mozilla-mobile/fenix/pull/8318)||2020-09-01 |
| events.total_uri_count |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |A counter of URIs visited by the user in the current session, including page reloads. This does not include background page requests and URIs from embedded pages or private browsing. |[1](https://github.com/mozilla-mobile/fenix/pull/1785), [2](https://github.com/mozilla-mobile/fenix/pull/8314)||2020-09-01 | | events.total_uri_count |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |A counter of URIs visited by the user in the current session, including page reloads. This does not include background page requests and URIs from embedded pages or private browsing. |[1](https://github.com/mozilla-mobile/fenix/pull/1785), [2](https://github.com/mozilla-mobile/fenix/pull/8314)||2020-09-01 |
| metrics.adjust_ad_group |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |A string containing the Adjust ad group ID from which the user installed Fenix. This will not send on the first session the user runs. If the install is organic, this will be empty. |[1](https://github.com/mozilla-mobile/fenix/pull/9253)||2020-09-01 | | metrics.adjust_ad_group |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |A string containing the Adjust ad group ID from which the user installed Fenix. This will not send on the first session the user runs. If the install is organic, this will be empty. |[1](https://github.com/mozilla-mobile/fenix/pull/9253)||2020-09-01 |
| metrics.adjust_campaign |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |A string containing the Adjust campaign ID from which the user installed Fenix. This will not send on the first session the user runs. If the install is organic, this will be empty. |[1](https://github.com/mozilla-mobile/fenix/pull/5579)||2020-09-01 | | metrics.adjust_campaign |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |A string containing the Adjust campaign ID from which the user installed Fenix. This will not send on the first session the user runs. If the install is organic, this will be empty. |[1](https://github.com/mozilla-mobile/fenix/pull/5579)||2020-09-01 |