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

For #975: Adds telemetry for settings toggles #1896

Merged
merged 2 commits into from
Apr 26, 2019

Conversation

sblatz
Copy link
Contributor

@sblatz sblatz commented Apr 22, 2019

Pull Request checklist

  • Quality: This PR builds and passes detekt/ktlint checks (A pre-push hook is recommended)
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Changelog: This PR includes a changelog entry or does not need one
  • Accessibility: The code in this PR follows accessibility best practices or does not include any user facing features

@sblatz sblatz requested a review from a team as a code owner April 22, 2019 18:45
@ghost ghost assigned sblatz Apr 22, 2019
@ghost ghost added the review label Apr 22, 2019
@sblatz sblatz force-pushed the telemetry-settings branch from aecbf89 to efad4fd Compare April 22, 2019 18:46
@sblatz
Copy link
Contributor Author

sblatz commented Apr 22, 2019

Request for data collection review form

All questions are mandatory. You must receive review from a data steward peer on your responses to these questions before shipping new data collection.

  1. What questions will you answer with this data?
  • How often users toggle their preference in the settings screen
  1. Why does Mozilla need to answer these questions? Are there benefits for users? Do we need this information to address product or business requirements?
  • To measure how useful these features are, and how useful the ability to toggle them is
  1. What alternative methods did you consider to answer these questions? Why were they not sufficient?
  • N/A (These are baseline metrics)
  1. Can current instrumentation answer these questions?
  • Currently no, as these are some of the first metrics we're recording
  1. List all proposed measurements and indicate the category of data collection for each measurement, using the Firefox data collection categories on the found on the Mozilla wiki.
  • All data is Category 2.
  1. How long will this data be collected?

Until 04/01/2020 (renewed thereafter)

  1. What populations will you measure?
  • All release, beta, and nightly users with telemetry enabled.
  1. Please provide a general description of how you will analyze this data.
  • Glean / Amplitude
  1. Where do you intend to share the results of your analysis?
  • Only on Glean, Amplitude and with mobile teams.

@sblatz sblatz removed the request for review from a team April 22, 2019 18:47
@sblatz sblatz force-pushed the telemetry-settings branch from efad4fd to 7e0ea3a Compare April 22, 2019 18:48
@sblatz sblatz requested a review from boek April 22, 2019 20:24
@sblatz sblatz force-pushed the telemetry-settings branch from 7e0ea3a to 228e2e4 Compare April 23, 2019 20:05
boek
boek previously requested changes Apr 23, 2019
return event.wrapper != null
}

// Switch preferences that should have their toggle events sent to Glean
private val switchPreferenceTelemetryAllowList = listOf(
Copy link
Contributor

Choose a reason for hiding this comment

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

I would move this to the PreferenceToggled type under a private failable constructor to keep all of the logic around that type together 👍

preferences:
preference_toggled:
type: event
description: >
Copy link
Contributor

Choose a reason for hiding this comment

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

The extras need to be documented, you can look for an example here.
https://github.com/mozilla-mobile/fenix/blob/master/app/metrics.yaml#L42

In the documentation also put all the available options


preferenceManager.sharedPreferences.registerOnSharedPreferenceChangeListener { sharedPreferences, key ->
context!!.components.analytics.metrics.track(
Event.PreferenceToggled(
Copy link
Contributor

Choose a reason for hiding this comment

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

and then here you could "try" to create the event, and then track it if it succeeds.

@sblatz sblatz force-pushed the telemetry-settings branch 2 times, most recently from d531336 to ffc533a Compare April 24, 2019 16:15
@sblatz sblatz requested review from a team and liuche April 24, 2019 16:15
@sblatz
Copy link
Contributor Author

sblatz commented Apr 25, 2019

Hoping @liuche can data review this. Jeff gave it a thumbs up before he left (after I updated the extras documentation), but I wanted a data review approval documented on the PR to be sure 😄

Copy link
Contributor

@liuche liuche left a comment

Choose a reason for hiding this comment

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

data-review+ just one comment about values

Data Review Form (to be filled by Data Stewards)

  1. Is there or will there be documentation that describes the schema for the ultimate data set available publicly, complete and accurate?
    Yes, in metrics.yaml

  2. Is there a control mechanism that allows the user to turn the data collection on and off? (Note, for data collection not needed for security purposes, Mozilla provides such a control mechanism) Provide details as to the control mechanism available.
    Yes, Fenix data controls

  3. If the request is for permanent data collection, is there someone who will monitor the data over time?**
    No, @vesta0 will monitor and it has expiry

  4. Using the category system of data types on the Mozilla wiki, what collection type of data do the requested measurements fall under? **
    Type 2, interaction with settings provided by Fenix

  5. Is the data collection request for default-on or default-off?
    Default on

  6. Does the instrumentation include the addition of any new identifiers (whether anonymous or otherwise; e.g., username, random IDs, etc. See the appendix for more details)?
    No

  7. Is the data collection covered by the existing Firefox privacy notice?
    Yes

  8. Does there need to be a check-in in the future to determine whether to renew the data? (Yes/No) (If yes, set a todo reminder or file a bug if appropriate)**
    No, has expiry

  9. Does the data collection use a third-party collection tool? If yes, escalate to legal.
    No

app/metrics.yaml Outdated
A user toggled a preference switch in settings
extra_keys:
preferenceKey:
description: "The preference key for the switch preference the user toggled"
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I was thinking about if this needs all possible values - it would be helpful for whomever is looking at this from a data perspective to know what the values are (on the other hand, these are values that we're including that might just get out of date). Slight preference for adding those values though!

context.getString(R.string.pref_key_show_search_suggestions),
context.getString(R.string.pref_key_show_visited_sites_bookmarks),
context.getString(R.string.pref_key_remote_debugging),
context.getString(R.string.pref_key_telemetry),
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess technically we won't ever receive this telemetry getting toggled off, but not important enough to exclude.

Copy link
Contributor

@colintheshots colintheshots left a comment

Choose a reason for hiding this comment

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

I guess I'd put a safe call on Context where you call track ().


preferenceManager.sharedPreferences.registerOnSharedPreferenceChangeListener { sharedPreferences, key ->
try {
context!!.components.analytics.metrics.track(Event.PreferenceToggled
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is safe because onCreate comes right after onAttach, but I don't think we should crash if context is null here.

@@ -71,6 +74,29 @@ sealed class Event {
object CustomTabsActionTapped : Event()
object CustomTabsMenuOpened : Event()

data class PreferenceToggled(val preferenceKey: String, val enabled: Boolean, val context: Context) : Event() {
private val switchPreferenceTelemetryAllowList = listOf(
context.getString(R.string.pref_key_leakcanary),
Copy link
Contributor

Choose a reason for hiding this comment

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

So every single preference toggle needs to grab all of these keys from resources? I rather wish there was a way to do this only once and remember the set or list, but this will do for now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants