diff --git a/app/metrics.yaml b/app/metrics.yaml index 11100ebf1..688888480 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -1934,3 +1934,53 @@ 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" + 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" 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 44e3366ac..06bf4ea60 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 @@ -9,6 +9,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 @@ -491,6 +492,12 @@ private val Event.wrapper: EventWrapper<*>? { AppTheme.darkThemeSelected.record(it) }, { AppTheme.darkThemeSelectedKeys.valueOf(it) } ) + is Event.AddonsOpenInSettings -> EventWrapper( + { Addons.openAddonsInSettings.record(it) } + ) + is Event.AddonsOpenInToolbarMenu -> EventWrapper( + { Addons.openAddonInToolbarMenu.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 efec097f2..0f7d2580f 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 @@ -6,6 +6,7 @@ package org.mozilla.fenix.components.metrics import android.content.Context import mozilla.components.browser.errorpages.ErrorType +import mozilla.components.browser.menu.facts.BrowserMenuFacts import mozilla.components.browser.search.SearchEngine import mozilla.components.browser.toolbar.facts.ToolbarFacts 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.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 +155,16 @@ sealed class Event { object PocketTopSiteClicked : Event() object PocketTopSiteRemoved : Event() object FennecToFenixMigrated : Event() + object AddonsOpenInSettings : Event() + object AddonsOpenInToolbarMenu : 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 +195,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 +223,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) } @@ -249,6 +262,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) } @@ -263,8 +277,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. @@ -285,7 +302,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) @@ -323,6 +342,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) } @@ -332,7 +352,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", @@ -380,6 +401,7 @@ private fun Fact.toEvent(): Event? = when (Pair(component, item)) { Component.BROWSER_TOOLBAR to ToolbarFacts.Items.MENU -> { 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.ACTION_BUTTON -> Event.CustomTabsActionTapped @@ -409,6 +431,21 @@ 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.hasInstalledAddons.set(installedAddons.size > 0) + } + } + + metadata?.get("enabled")?.let { enabledAddons -> + if (enabledAddons is List<*>) { + Addons.hasEnabledAddons.set(enabledAddons.size > 0) + } + } + + null + } else -> null } @@ -440,7 +477,8 @@ interface MetricController { ReleaseMetricController( services, isDataTelemetryEnabled, - isMarketingDataTelemetryEnabled) + isMarketingDataTelemetryEnabled + ) } else DebugMetricController() } } @@ -480,7 +518,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 } @@ -492,7 +532,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 } @@ -507,7 +549,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 556236e61..0b923ecf3 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/SettingsFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/SettingsFragment.kt @@ -210,6 +210,7 @@ class SettingsFragment : PreferenceFragmentCompat() { SettingsFragmentDirections.actionSettingsFragmentToLocaleSettingsFragment() } resources.getString(R.string.pref_key_addons) -> { + requireContext().metrics.track(Event.AddonsOpenInSettings) SettingsFragmentDirections.actionSettingsFragmentToAddonsFragment() } resources.getString(R.string.pref_key_make_default_browser) -> { diff --git a/docs/metrics.md b/docs/metrics.md index ca209c9d3..06ec9ad7e 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -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.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_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)|
  • 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 +205,8 @@ The following metrics are added to the ping: | 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 | | 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 |