Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
For #11118: Add missing telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
sblatz committed Jun 10, 2020
1 parent 31edbc9 commit 6094f91
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 40 deletions.
28 changes: 28 additions & 0 deletions app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/TODO
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/TODO
notification_emails:
- fenix-core@mozilla.com
expires: "2020-09-01"

search.default_engine:
code:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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) {
""
Expand All @@ -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() {
Expand Down
2 changes: 2 additions & 0 deletions docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/TODO)||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 |
Expand All @@ -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/TODO)||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 |
Expand Down

0 comments on commit 6094f91

Please sign in to comment.