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

For #11118: Add toggle states to metrics ping #11211

Merged
merged 1 commit into from Jun 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
219 changes: 219 additions & 0 deletions app/metrics.yaml
Expand Up @@ -509,6 +509,225 @@ metrics:
- fenix-core@mozilla.com
expires: "2020-09-01"

preferences:
show_search_suggestions:
type: string_list
description: >
Whether or not the user has search suggestions enabled
default: true
send_in_pings:
- metrics
bugs:
- https://github.com/mozilla-mobile/fenix/issues/11118
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/11211
notification_emails:
- fenix-core@mozilla.com
expires: "2020-09-01"
remote_debugging:
type: string_list
description: >
Whether or not the user has remote debugging 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/11211
notification_emails:
- fenix-core@mozilla.com
expires: "2020-09-01"
telemetry:
type: string_list
description: >
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
send_in_pings:
- metrics
bugs:
- https://github.com/mozilla-mobile/fenix/issues/11118
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/11211
notification_emails:
- fenix-core@mozilla.com
expires: "2020-09-01"
tracking_protection:
type: string_list
description: >
What type of enhanced tracking protection the user has enabled.
"standard," "strict," "custom," or "" (if disabled)
default: "standard"
sblatz marked this conversation as resolved.
Show resolved Hide resolved
send_in_pings:
- metrics
bugs:
- https://github.com/mozilla-mobile/fenix/issues/11118
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/11211
notification_emails:
- fenix-core@mozilla.com
expires: "2020-09-01"
search_bookmarks:
type: string_list
description: >
Whether or not the user has enabled bookmark search suggestions
default: true
send_in_pings:
- metrics
bugs:
- https://github.com/mozilla-mobile/fenix/issues/11118
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/11211
notification_emails:
- fenix-core@mozilla.com
expires: "2020-09-01"
search_browsing_history:
type: string_list
description: >
Whether or not the user has enabled browsing history suggestions.
default: true
send_in_pings:
- metrics
bugs:
- https://github.com/mozilla-mobile/fenix/issues/11118
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/11211
notification_emails:
- fenix-core@mozilla.com
expires: "2020-09-01"
show_clipboard_suggestions:
type: string_list
description: >
Whether or not the user has enabled clipboard search suggestions.
default: true
send_in_pings:
- metrics
bugs:
- https://github.com/mozilla-mobile/fenix/issues/11118
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/11211
notification_emails:
- fenix-core@mozilla.com
expires: "2020-09-01"
show_search_shortcuts:
type: string_list
description: >
Whether or not the user has enabled search shortcuts.
default: true
send_in_pings:
- metrics
bugs:
- https://github.com/mozilla-mobile/fenix/issues/11118
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/11211
notification_emails:
- fenix-core@mozilla.com
expires: "2020-09-01"
open_links_in_a_private_tab:
type: string_list
description: >
Whether or not the user has enabled open links in a private tab.
default: false
send_in_pings:
- metrics
bugs:
- https://github.com/mozilla-mobile/fenix/issues/11118
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/11211
notification_emails:
- fenix-core@mozilla.com
expires: "2020-09-01"
sync:
type: string_list
description: >
Whether or not the user is signed into FxA
default: false
send_in_pings:
- metrics
bugs:
- https://github.com/mozilla-mobile/fenix/issues/11118
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/11211
notification_emails:
- fenix-core@mozilla.com
expires: "2020-09-01"
sync_items:
type: string_list
description: >
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]
sblatz marked this conversation as resolved.
Show resolved Hide resolved
send_in_pings:
- metrics
bugs:
- https://github.com/mozilla-mobile/fenix/issues/11118
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/11211
notification_emails:
- fenix-core@mozilla.com
expires: "2020-09-01"
show_voice_search:
type: string_list
description: >
Whether or not the user has enabled the voice search button.
sblatz marked this conversation as resolved.
Show resolved Hide resolved
default: true
send_in_pings:
- metrics
bugs:
- https://github.com/mozilla-mobile/fenix/issues/11118
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/11211
notification_emails:
- fenix-core@mozilla.com
expires: "2020-09-01"
search_suggestions_private:
type: string_list
description: >
Whether or not the user has enabled showing search suggestions
in private mode.
default: false (we prompt the user, asking them to make a selection)
send_in_pings:
- metrics
bugs:
- https://github.com/mozilla-mobile/fenix/issues/11118
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/11211
notification_emails:
- fenix-core@mozilla.com
expires: "2020-09-01"
toolbar_position:
type: string_list
description: >
The position of the toolbar
default: bottom (defaults to top if the user has accessibility services)
send_in_pings:
- metrics
bugs:
- https://github.com/mozilla-mobile/fenix/issues/11118
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/11211
notification_emails:
- fenix-core@mozilla.com
expires: "2020-09-01"
accessibility_services:
type: string_list
description: >
Whether or not the user has touch exploration or switch services enabled.
These are built into the Android OS, not Fenix prefs.
default: ""
send_in_pings:
- metrics
bugs:
- https://github.com/mozilla-mobile/fenix/issues/11118
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/11211
notification_emails:
- fenix-core@mozilla.com
expires: "2020-09-01"

search.default_engine:
code:
type: string
Expand Down
Expand Up @@ -5,6 +5,7 @@
package org.mozilla.fenix.components.metrics

import android.content.Context
import mozilla.components.service.fxa.manager.SyncEnginesStorage
import mozilla.components.service.glean.Glean
import mozilla.components.service.glean.private.NoExtraKeys
import mozilla.components.support.base.log.logger.Logger
Expand All @@ -28,6 +29,7 @@ import org.mozilla.fenix.GleanMetrics.MediaState
import org.mozilla.fenix.GleanMetrics.Metrics
import org.mozilla.fenix.GleanMetrics.Pings
import org.mozilla.fenix.GleanMetrics.Pocket
import org.mozilla.fenix.GleanMetrics.Preferences
import org.mozilla.fenix.GleanMetrics.PrivateBrowsingMode
import org.mozilla.fenix.GleanMetrics.PrivateBrowsingShortcut
import org.mozilla.fenix.GleanMetrics.QrScanner
Expand Down Expand Up @@ -587,6 +589,56 @@ class GleanMetricsService(private val context: Context) : MetricsService {
}

internal fun setStartupMetrics() {

// 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.
Preferences.apply {
showSearchSuggestions.set(context.settings().shouldShowSearchSuggestions.toStringList())
remoteDebugging.set(context.settings().isRemoteDebuggingEnabled.toStringList())
telemetry.set(context.settings().isTelemetryEnabled.toStringList())
searchBookmarks.set(context.settings().shouldShowBookmarkSuggestions.toStringList())
showClipboardSuggestions.set(context.settings().shouldShowClipboardSuggestions.toStringList())
showSearchShortcuts.set(context.settings().shouldShowSearchShortcuts.toStringList())
openLinksInAPrivateTab.set(context.settings().openLinksInAPrivateTab.toStringList())
searchSuggestionsPrivate.set(context.settings().shouldShowSearchSuggestionsInPrivate.toStringList())

val isLoggedIn =
context.components.backgroundServices.accountManager.accountProfile() != null
sync.set(isLoggedIn.toStringList())

val syncedItems = SyncEnginesStorage(context).getStatus().entries.filter {
it.value
}.map { it.key.nativeName }

syncItems.set(syncedItems)

val etpSelection =
if (!context.settings().shouldUseTrackingProtection) {
""
} else if (context.settings().useStandardTrackingProtection) {
"standard"
} else if (context.settings().useStrictTrackingProtection) {
"strict"
} else if (context.settings().useCustomTrackingProtection) {
"custom"
} else {
""
}

trackingProtection.set(listOf(etpSelection))

val accessibilitySelection = mutableListOf<String>()

if (context.settings().switchServiceIsEnabled) { accessibilitySelection.add("switch") }

if (context.settings().touchExplorationIsEnabled) {
accessibilitySelection.add("touch exploration")
}

accessibilityServices.set(accessibilitySelection.toList())
}

Metrics.apply {
defaultBrowser.set(BrowsersCache.all(context).isDefaultBrowser)
MozillaProductDetector.getMozillaBrowserDefault(context)?.also {
Expand Down Expand Up @@ -644,3 +696,8 @@ class GleanMetricsService(private val context: Context) : MetricsService {
return event.wrapper != null
}
}

// Helper function for making our booleans fit into the string list formatting
fun Boolean.toStringList(): List<String> {
return listOf(this.toString())
}
9 changes: 7 additions & 2 deletions app/src/main/java/org/mozilla/fenix/utils/Settings.kt
Expand Up @@ -331,6 +331,11 @@ class Settings private constructor(
default = false
)

val useStandardTrackingProtection by booleanPreference(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, so did we not have this before?

It's a little weird that this isn't a radio preference...in theory does that mean that the settings could get messed up and more than one of these could be selected? 🤔 (out of scope for this bug I know)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me touch base with Emily about this. I think the Radio Group does prevent these from getting sent to multiple true vales.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

appContext.getPreferenceKey(R.string.pref_key_tracking_protection_standard_option),
true
)

val useStrictTrackingProtection by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_tracking_protection_strict_default),
false
Expand Down Expand Up @@ -435,7 +440,7 @@ class Settings private constructor(
* Check each active accessibility service to see if it can perform gestures, if any can,
* then it is *likely* a switch service is enabled. We are assuming this to be the case based on #7486
*/
private val switchServiceIsEnabled: Boolean
val switchServiceIsEnabled: Boolean
get() {
val accessibilityManager =
appContext.getSystemService(Context.ACCESSIBILITY_SERVICE) as? AccessibilityManager
Expand All @@ -451,7 +456,7 @@ class Settings private constructor(
return false
}

private val touchExplorationIsEnabled: Boolean
val touchExplorationIsEnabled: Boolean
get() {
val accessibilityManager =
appContext.getSystemService(Context.ACCESSIBILITY_SERVICE) as? AccessibilityManager
Expand Down
15 changes: 15 additions & 0 deletions docs/metrics.md
Expand Up @@ -247,6 +247,21 @@ The following metrics are added to the ping:
| perf.awesomebar.session_suggestions |[timing_distribution](https://mozilla.github.io/glean/book/user/metrics/timing_distribution.html) |Duration of a session awesomebar suggestion query. |[1](https://github.com/mozilla-mobile/fenix/pull/10276#pullrequestreview-411101979)||2020-09-15 |
| perf.awesomebar.shortcuts_suggestions |[timing_distribution](https://mozilla.github.io/glean/book/user/metrics/timing_distribution.html) |Duration of a shortcuts awesomebar suggestion query. |[1](https://github.com/mozilla-mobile/fenix/pull/10276#pullrequestreview-411101979)||2020-09-15 |
| 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.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 |
| preferences.search_suggestions_private |[string_list](https://mozilla.github.io/glean/book/user/metrics/string_list.html) |Whether or not the user has enabled showing search suggestions in private mode. default: false (we prompt the user, asking them to make a selection) |[1](https://github.com/mozilla-mobile/fenix/pull/11211)||2020-09-01 |
| preferences.show_clipboard_suggestions |[string_list](https://mozilla.github.io/glean/book/user/metrics/string_list.html) |Whether or not the user has enabled clipboard search suggestions. default: true |[1](https://github.com/mozilla-mobile/fenix/pull/11211)||2020-09-01 |
| preferences.show_search_shortcuts |[string_list](https://mozilla.github.io/glean/book/user/metrics/string_list.html) |Whether or not the user has enabled search shortcuts. default: true |[1](https://github.com/mozilla-mobile/fenix/pull/11211)||2020-09-01 |
| preferences.show_search_suggestions |[string_list](https://mozilla.github.io/glean/book/user/metrics/string_list.html) |Whether or not the user has search suggestions enabled default: true |[1](https://github.com/mozilla-mobile/fenix/pull/11211)||2020-09-01 |
| preferences.show_voice_search |[string_list](https://mozilla.github.io/glean/book/user/metrics/string_list.html) |Whether or not the user has enabled the voice search button. default: true |[1](https://github.com/mozilla-mobile/fenix/pull/11211)||2020-09-01 |
| 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.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 |
| search.default_engine.name |[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 name. 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 |
| search.default_engine.submission_url |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |If the search engine is pre-loaded with Fenix this value will be he base URL we use to build the search query for the search engine. For example: https://mysearchengine.com/?query=%s. 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