diff --git a/app/metrics.yaml b/app/metrics.yaml index 60dd4e79f5e6..018dac98fada 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -728,6 +728,34 @@ preferences: notification_emails: - fenix-core@mozilla.com expires: "2020-09-01" + open_links_in_app: + type: string_list + description: > + Whether or not the user has the open links in apps feature enabled. + default: false + send_in_pings: + - metrics + bugs: + - https://github.com/mozilla-mobile/fenix/issues/11118 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/11446 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-09-01" + theme: + type: string_list + description: > + The theme the user has enabled. "light," "dark," "system," or "battery" + default: "system" for API 28+, else "light" + send_in_pings: + - metrics + bugs: + - https://github.com/mozilla-mobile/fenix/issues/11118 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/11446 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-09-01" search.default_engine: code: 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 277aebd74bc4..a9572322a31c 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 @@ -590,7 +590,53 @@ class GleanMetricsService(private val context: Context) : MetricsService { } internal fun setStartupMetrics() { + setPreferenceMetrics() + Metrics.apply { + defaultBrowser.set(BrowsersCache.all(context).isDefaultBrowser) + MozillaProductDetector.getMozillaBrowserDefault(context)?.also { + defaultMozBrowser.set(it) + } + mozillaProducts.set(MozillaProductDetector.getInstalledMozillaProducts(context)) + adjustCampaign.set(context.settings().adjustCampaignId) + adjustAdGroup.set(context.settings().adjustAdGroup) + adjustCreative.set(context.settings().adjustCreative) + adjustNetwork.set(context.settings().adjustNetwork) + + searchWidgetInstalled.set(context.settings().searchWidgetInstalled) + + val topSitesSize = context.settings().topSitesSize + hasTopSites.set(topSitesSize > 0) + if (topSitesSize > 0) { + topSitesCount.add(topSitesSize) + } + + toolbarPosition.set( + if (context.settings().shouldUseBottomToolbar) { + Event.ToolbarPositionChanged.Position.BOTTOM.name + } else { + Event.ToolbarPositionChanged.Position.TOP.name + } + ) + } + + SearchDefaultEngine.apply { + val defaultEngine = context + .components + .search + .searchEngineManager + .defaultSearchEngine ?: return@apply + + code.set(defaultEngine.identifier) + name.set(defaultEngine.name) + submissionUrl.set(defaultEngine.buildSearchUrl("")) + } + + activationPing.checkAndSend() + installationPing.checkAndSend() + } + + private fun setPreferenceMetrics() { // We purposefully make all of our preferences the string_list format to make data analysis // simpler. While it makes things like booleans a bit more complicated, it means all our // preferences can be analyzed with the same dashboard and compared. @@ -603,6 +649,8 @@ class GleanMetricsService(private val context: Context) : MetricsService { showSearchShortcuts.set(context.settings().shouldShowSearchShortcuts.toStringList()) openLinksInAPrivateTab.set(context.settings().openLinksInAPrivateTab.toStringList()) searchSuggestionsPrivate.set(context.settings().shouldShowSearchSuggestionsInPrivate.toStringList()) + showVoiceSearch.set(context.settings().shouldShowVoiceSearch.toStringList()) + openLinksInApp.set(context.settings().openLinksInExternalApp.toStringList()) val isLoggedIn = context.components.backgroundServices.accountManager.accountProfile() != null @@ -614,6 +662,17 @@ class GleanMetricsService(private val context: Context) : MetricsService { syncItems.set(syncedItems) + val toolbarPositionSelection = + if (context.settings().shouldUseFixedTopToolbar) { + "fixed_top" + } else if (context.settings().shouldUseBottomToolbar) { + "bottom" + } else { + "top" + } + + toolbarPosition.set(listOf(toolbarPositionSelection)) + val etpSelection = if (!context.settings().shouldUseTrackingProtection) { "" @@ -638,51 +697,22 @@ class GleanMetricsService(private val context: Context) : MetricsService { } accessibilityServices.set(accessibilitySelection.toList()) - } - - Metrics.apply { - defaultBrowser.set(BrowsersCache.all(context).isDefaultBrowser) - MozillaProductDetector.getMozillaBrowserDefault(context)?.also { - defaultMozBrowser.set(it) - } - mozillaProducts.set(MozillaProductDetector.getInstalledMozillaProducts(context)) - - adjustCampaign.set(context.settings().adjustCampaignId) - adjustAdGroup.set(context.settings().adjustAdGroup) - adjustCreative.set(context.settings().adjustCreative) - adjustNetwork.set(context.settings().adjustNetwork) - - searchWidgetInstalled.set(context.settings().searchWidgetInstalled) - - val topSitesSize = context.settings().topSitesSize - hasTopSites.set(topSitesSize > 0) - if (topSitesSize > 0) { - topSitesCount.add(topSitesSize) - } - toolbarPosition.set( - if (context.settings().shouldUseBottomToolbar) { - Event.ToolbarPositionChanged.Position.BOTTOM.name + val themeSelection = + if (context.settings().shouldUseLightTheme) { + "light" + } else if (context.settings().shouldUseDarkTheme) { + "dark" + } else if (context.settings().shouldFollowDeviceTheme) { + "system" + } else if (context.settings().shouldUseAutoBatteryTheme) { + "battery" } else { - Event.ToolbarPositionChanged.Position.TOP.name + "" } - ) - } - - SearchDefaultEngine.apply { - val defaultEngine = context - .components - .search - .searchEngineManager - .defaultSearchEngine ?: return@apply - code.set(defaultEngine.identifier) - name.set(defaultEngine.name) - submissionUrl.set(defaultEngine.buildSearchUrl("")) + theme.set(listOf(themeSelection)) } - - activationPing.checkAndSend() - installationPing.checkAndSend() } override fun stop() { diff --git a/docs/metrics.md b/docs/metrics.md index 73e9a252dec4..1096ec7605c7 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -251,6 +251,7 @@ The following metrics are added to the ping: | perf.awesomebar.synced_tabs_suggestions |[timing_distribution](https://mozilla.github.io/glean/book/user/metrics/timing_distribution.html) |Duration of a synced tabs awesomebar suggestion query. |[1](https://github.com/mozilla-mobile/fenix/pull/10276#pullrequestreview-411101979)||2020-09-15 | | preferences.accessibility_services |[string_list](https://mozilla.github.io/glean/book/user/metrics/string_list.html) |Whether or not the user has touch exploration or switch services enabled. These are built into the Android OS, not Fenix prefs. default: "" |[1](https://github.com/mozilla-mobile/fenix/pull/11211)||2020-09-01 | | preferences.open_links_in_a_private_tab |[string_list](https://mozilla.github.io/glean/book/user/metrics/string_list.html) |Whether or not the user has enabled open links in a private tab. default: false |[1](https://github.com/mozilla-mobile/fenix/pull/11211)||2020-09-01 | +| preferences.open_links_in_app |[string_list](https://mozilla.github.io/glean/book/user/metrics/string_list.html) |Whether or not the user has the open links in apps feature enabled. default: false |[1](https://github.com/mozilla-mobile/fenix/pull/11446)||2020-09-01 | | preferences.remote_debugging |[string_list](https://mozilla.github.io/glean/book/user/metrics/string_list.html) |Whether or not the user has remote debugging enabled default: false |[1](https://github.com/mozilla-mobile/fenix/pull/11211)||2020-09-01 | | preferences.search_bookmarks |[string_list](https://mozilla.github.io/glean/book/user/metrics/string_list.html) |Whether or not the user has enabled bookmark search suggestions default: true |[1](https://github.com/mozilla-mobile/fenix/pull/11211)||2020-09-01 | | preferences.search_browsing_history |[string_list](https://mozilla.github.io/glean/book/user/metrics/string_list.html) |Whether or not the user has enabled browsing history suggestions. default: true |[1](https://github.com/mozilla-mobile/fenix/pull/11211)||2020-09-01 | @@ -262,6 +263,7 @@ The following metrics are added to the ping: | preferences.sync |[string_list](https://mozilla.github.io/glean/book/user/metrics/string_list.html) |Whether or not the user is signed into FxA default: false |[1](https://github.com/mozilla-mobile/fenix/pull/11211)||2020-09-01 | | preferences.sync_items |[string_list](https://mozilla.github.io/glean/book/user/metrics/string_list.html) |The list of items the user has chosen to sync with FxA. default: "" if the user is signed out. Otherwise defaults to whatever is set in their FxA account. New accounts set: [bookmarks, history, passwords, tabs] |[1](https://github.com/mozilla-mobile/fenix/pull/11211)||2020-09-01 | | preferences.telemetry |[string_list](https://mozilla.github.io/glean/book/user/metrics/string_list.html) |Whether or not the user has telemetry enabled. Note we should never receive a "false" value for this since telemetry would not send in that case. default: true |[1](https://github.com/mozilla-mobile/fenix/pull/11211)||2020-09-01 | +| preferences.theme |[string_list](https://mozilla.github.io/glean/book/user/metrics/string_list.html) |The theme the user has enabled. "light," "dark," "system," or "battery" default: "system" for API 28+, else "light" |[1](https://github.com/mozilla-mobile/fenix/pull/11446)||2020-09-01 | | preferences.toolbar_position |[string_list](https://mozilla.github.io/glean/book/user/metrics/string_list.html) |The position of the toolbar default: bottom (defaults to top if the user has accessibility services) |[1](https://github.com/mozilla-mobile/fenix/pull/11211)||2020-09-01 | | preferences.tracking_protection |[string_list](https://mozilla.github.io/glean/book/user/metrics/string_list.html) |What type of enhanced tracking protection the user has enabled. "standard," "strict," "custom," or "" (if disabled) default: "standard" |[1](https://github.com/mozilla-mobile/fenix/pull/11211)||2020-09-01 | | search.default_engine.code |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |If the search engine is pre-loaded with Fenix this value will be the search engine identifier. If it's a custom search engine (defined: https://github.com/mozilla-mobile/fenix/issues/1607) the value will be "custom" |[1](https://github.com/mozilla-mobile/fenix/pull/1606), [2](https://github.com/mozilla-mobile/fenix/pull/5216)||2020-09-01 |