diff --git a/app/metrics.yaml b/app/metrics.yaml index 4e18979af5ee..d2017d2ea2e4 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -1856,3 +1856,42 @@ installation: notification_emails: - fenix-core@mozilla.com 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" + installed_addons: + type: string_list + description: > + A list of all 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" + enabled_addons: + type: string_list + description: > + A list of all 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" 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 927b765ad449..a2d01a22a6b3 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 @@ -12,6 +12,7 @@ import mozilla.components.service.glean.Glean import mozilla.components.service.glean.private.NoExtraKeys import mozilla.components.support.base.log.logger.Logger import org.mozilla.fenix.GleanMetrics.AboutPage +import org.mozilla.fenix.GleanMetrics.Addons import org.mozilla.fenix.GleanMetrics.AppTheme import org.mozilla.fenix.GleanMetrics.BookmarksManagement import org.mozilla.fenix.GleanMetrics.Collections @@ -494,6 +495,9 @@ private val Event.wrapper: EventWrapper<*>? { AppTheme.darkThemeSelected.record(it) }, { AppTheme.darkThemeSelectedKeys.valueOf(it) } ) + is Event.AddonsOpenedInSettings -> EventWrapper( + { Addons.openAddonsInSettings.record(it) } + ) // Don't record other events in Glean: is Event.AddBookmark -> null is Event.OpenedBookmark -> null diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt index 46ff83a5934d..8fff3aa10d3e 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt @@ -19,7 +19,9 @@ import mozilla.components.support.base.facts.Fact import mozilla.components.support.base.facts.FactProcessor import mozilla.components.support.base.facts.Facts import mozilla.components.support.base.log.logger.Logger +import mozilla.components.support.webextensions.facts.WebExtensionFacts import org.mozilla.fenix.BuildConfig +import org.mozilla.fenix.GleanMetrics.Addons import org.mozilla.fenix.GleanMetrics.AppTheme import org.mozilla.fenix.GleanMetrics.Collections import org.mozilla.fenix.GleanMetrics.ContextMenu @@ -152,10 +154,15 @@ sealed class Event { object PocketTopSiteClicked : Event() object PocketTopSiteRemoved : Event() object FennecToFenixMigrated : Event() + object AddonsOpenedInSettings : Event() // 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( context.getString(R.string.pref_key_show_search_suggestions), context.getString(R.string.pref_key_remote_debugging), @@ -186,18 +193,21 @@ sealed class Event { data class ToolbarPositionChanged(val position: Position) : Event() { enum class Position { TOP, BOTTOM } + override val extras: Map? get() = hashMapOf(ToolbarSettings.changedPositionKeys.position to position.name) } data class OpenedLink(val mode: Mode) : Event() { enum class Mode { NORMAL, PRIVATE } + override val extras: Map? get() = hashMapOf(Events.openedLinkKeys.mode to mode.name) } data class TrackingProtectionSettingChanged(val setting: Setting) : Event() { enum class Setting { STRICT, STANDARD } + override val extras: Map? get() = hashMapOf(TrackingProtection.etpSettingChangedKeys.etpSetting to setting.name) } @@ -211,6 +221,7 @@ sealed class Event { data class OpenedApp(val source: Source) : Event() { enum class Source { APP_ICON, LINK, CUSTOM_TAB } + override val extras: Map? get() = hashMapOf(Events.appOpenedKeys.source to source.name) } @@ -248,6 +259,7 @@ sealed class Event { data class SearchBarTapped(val source: Source) : Event() { enum class Source { HOME, BROWSER } + override val extras: Map? get() = mapOf(Events.searchBarTappedKeys.source to source.name) } @@ -262,8 +274,11 @@ sealed class Event { abstract val engine: SearchEngine abstract val isCustom: Boolean - data class Default(override val engine: SearchEngine, override val isCustom: Boolean) : EngineSource() - data class Shortcut(override val engine: SearchEngine, override val isCustom: Boolean) : EngineSource() + data class Default(override val engine: SearchEngine, override val isCustom: Boolean) : + EngineSource() + + data class Shortcut(override val engine: SearchEngine, override val isCustom: Boolean) : + EngineSource() // https://github.com/mozilla-mobile/fenix/issues/1607 // Sanitize identifiers for custom search engines. @@ -284,7 +299,9 @@ sealed class Event { } 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 Widget(override val engineSource: EngineSource) : EventSource(engineSource) data class Shortcut(override val engineSource: EngineSource) : EventSource(engineSource) @@ -322,6 +339,7 @@ sealed class Event { data class DarkThemeSelected(val source: Source) : Event() { enum class Source { SETTINGS, ONBOARDING } + override val extras: Map? get() = mapOf(AppTheme.darkThemeSelectedKeys.source to source.name) } @@ -331,7 +349,8 @@ sealed class Event { get() = mapOf(ContextMenu.itemTappedKeys.named to item) 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( "mozac.feature.contextmenu.open_in_new_tab" to "open_in_new_tab", @@ -408,6 +427,22 @@ private fun Fact.toEvent(): Event? = when (Pair(component, item)) { else -> null } } + + Component.SUPPORT_WEBEXTENSIONS to WebExtensionFacts.Items.WEB_EXTENSIONS_INITIALIZED -> { + metadata?.get("installed")?.let { installedAddons -> + if (installedAddons is List<*>) { + Addons.enabledAddons.set(installedAddons.map { it.toString() }) + } + } + + metadata?.get("enabled")?.let { enabledAddons -> + if (enabledAddons is List<*>) { + Addons.installedAddons.set(enabledAddons.map { it.toString() }) + } + } + + null + } else -> null } @@ -439,7 +474,8 @@ interface MetricController { ReleaseMetricController( services, isDataTelemetryEnabled, - isMarketingDataTelemetryEnabled) + isMarketingDataTelemetryEnabled + ) } else DebugMetricController() } } @@ -479,7 +515,9 @@ private class ReleaseMetricController( override fun start(type: MetricServiceType) { val isEnabled = isTelemetryEnabled(type) val isInitialized = isInitialized(type) - if (!isEnabled || isInitialized) { return } + if (!isEnabled || isInitialized) { + return + } services .filter { it.type == type } @@ -491,7 +529,9 @@ private class ReleaseMetricController( override fun stop(type: MetricServiceType) { val isEnabled = isTelemetryEnabled(type) val isInitialized = isInitialized(type) - if (isEnabled || !isInitialized) { return } + if (isEnabled || !isInitialized) { + return + } services .filter { it.type == type } @@ -506,7 +546,9 @@ private class ReleaseMetricController( .forEach { val isEnabled = isTelemetryEnabled(it.type) val isInitialized = isInitialized(it.type) - if (!isEnabled || !isInitialized) { return } + if (!isEnabled || !isInitialized) { + return + } it.track(event) } diff --git a/app/src/main/java/org/mozilla/fenix/settings/SettingsFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/SettingsFragment.kt index d1c33372bfc7..0dc350a8fbef 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/SettingsFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/SettingsFragment.kt @@ -181,6 +181,7 @@ class SettingsFragment : PreferenceFragmentCompat() { SettingsFragmentDirections.actionSettingsFragmentToLocaleSettingsFragment() } resources.getString(R.string.pref_key_addons) -> { + requireContext().metrics.track(Event.AddonsOpenedInSettings) SettingsFragmentDirections.actionSettingsFragmentToAddonsFragment() } resources.getString(R.string.pref_key_make_default_browser) -> { diff --git a/docs/metrics.md b/docs/metrics.md index e3a45f1cee9f..8b55d9a075ac 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -54,6 +54,7 @@ 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.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 | +| 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)|
  • source: The source from where dark theme was selected. The source can be 'SETTINGS' or 'ONBOARDING'
|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 | @@ -203,6 +204,8 @@ The following metrics are added to the ping: | Name | Type | Description | Data reviews | Extras | Expiration | | --- | --- | --- | --- | --- | --- | +| addons.enabled_addons |[string_list](https://mozilla.github.io/glean/book/user/metrics/string_list.html) |A list of all enabled add-ons on the device. |[1](https://github.com/mozilla-mobile/fenix/pull/8318)||2020-09-01 | +| addons.installed_addons |[string_list](https://mozilla.github.io/glean/book/user/metrics/string_list.html) |A list of all 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 | | 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.default_browser |[boolean](https://mozilla.github.io/glean/book/user/metrics/boolean.html) |Is Fenix the default browser? |[1](https://github.com/mozilla-mobile/fenix/pull/1067#issuecomment-474598673)||2020-09-01 |