From cc318021cc99a72e0619f6fc26684eaa0c8ef947 Mon Sep 17 00:00:00 2001 From: Emily Kager Date: Tue, 12 Nov 2019 15:55:36 -0800 Subject: [PATCH] For #5586 - Adds Logins Telemetry (#6352) * For #5586 - Adds Logins Telemetry * Adds Logins Sync Telemetry to PreferenceToggled event --- app/metrics.yaml | 55 ++++++++++++++++++- .../components/metrics/GleanMetricsService.kt | 13 +++++ .../fenix/components/metrics/Metrics.kt | 11 +++- .../logins/SavedLoginSiteInfoFragment.kt | 3 + .../fenix/logins/SavedLoginsFragment.kt | 2 + .../mozilla/fenix/settings/LoginsFragment.kt | 3 + docs/metrics.md | 6 +- 7 files changed, 86 insertions(+), 7 deletions(-) diff --git a/app/metrics.yaml b/app/metrics.yaml index 55b943f6b..821993f7b 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -108,23 +108,26 @@ events: preference_toggled: type: event description: > - A user toggled a preference switch in settings + A user toggled a boolean preference in settings extra_keys: preference_key: - description: "The preference key for the switch preference the user toggled. We currently track: + description: "The preference key for the boolean (true/false) preference the user toggled. We currently track: show_search_suggestions, remote_debugging, telemetry, tracking_protection, search_bookmarks, - search_browsing_history, show_clipboard_suggestions, show_search_shortcuts, and open_links_in_a_private_tab" + search_browsing_history, show_clipboard_suggestions, show_search_shortcuts, open_links_in_a_private_tab, + and pref_key_sync_logins" enabled: description: "Whether or not the preference is *now* enabled" bugs: - https://github.com/mozilla-mobile/fenix/issue/975 - https://github.com/mozilla-mobile/fenix/issue/5094 - https://github.com/mozilla-mobile/fenix/issues/5737 + - https://github.com/mozilla-mobile/fenix/issues/5586 data_reviews: - https://github.com/mozilla-mobile/fenix/pull/1896 - https://github.com/mozilla-mobile/fenix/pull/5704 - https://github.com/mozilla-mobile/fenix/pull/5886 - https://github.com/mozilla-mobile/fenix/pull/5975 + - https://github.com/mozilla-mobile/fenix/pull/6352 notification_emails: - fenix-core@mozilla.com expires: "2020-03-01" @@ -1443,6 +1446,52 @@ media_notification: - fenix-core@mozilla.com expires: "2020-03-01" +logins: + open_logins: + type: event + description: > + A user accessed Logins in Settings + bugs: + - https://github.com/mozilla-mobile/fenix/issues/5586 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/6352 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" + open_individual_login: + type: event + description: > + A user accessed an individual login in saved logins + bugs: + - https://github.com/mozilla-mobile/fenix/issues/5586 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/6352 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" + copy_login: + type: event + description: > + A user copied a piece of a login in saved logins + bugs: + - https://github.com/mozilla-mobile/fenix/issues/5586 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/6352 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" + view_password_login: + type: event + description: > + A user viewed a password in an individual saved login + bugs: + - https://github.com/mozilla-mobile/fenix/issues/5586 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/6352 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" + experiments.metrics: active_experiment: type: string 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 cdd1ffa0e..24ca0b9cd 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 @@ -25,6 +25,7 @@ import org.mozilla.fenix.GleanMetrics.Events import org.mozilla.fenix.GleanMetrics.FindInPage import org.mozilla.fenix.GleanMetrics.History import org.mozilla.fenix.GleanMetrics.Library +import org.mozilla.fenix.GleanMetrics.Logins import org.mozilla.fenix.GleanMetrics.MediaNotification import org.mozilla.fenix.GleanMetrics.Metrics import org.mozilla.fenix.GleanMetrics.Pings @@ -401,6 +402,18 @@ private val Event.wrapper: EventWrapper<*>? { Events.openedLink.record(it) }, { Events.openedLinkKeys.valueOf(it) } ) + is Event.OpenLogins -> EventWrapper( + { Logins.openLogins.record(it) } + ) + is Event.OpenOneLogin -> EventWrapper( + { Logins.openIndividualLogin.record(it) } + ) + is Event.CopyLogin -> EventWrapper( + { Logins.copyLogin.record(it) } + ) + is Event.ViewLoginPassword -> EventWrapper( + { Logins.viewPasswordLogin.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 0cd7d3a3b..712dee418 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 @@ -120,11 +120,15 @@ sealed class Event { object TrackingProtectionSettingsPanel : Event() object TrackingProtectionSettings : Event() object TrackingProtectionException : Event() + object OpenLogins : Event() + object OpenOneLogin : Event() + object CopyLogin : Event() + object ViewLoginPassword : Event() // Interaction events with extras data class PreferenceToggled(val preferenceKey: String, val enabled: Boolean, val context: Context) : Event() { - private val switchPreferenceTelemetryAllowList = listOf( + private val booleanPreferenceTelemetryAllowList = listOf( context.getString(R.string.pref_key_show_search_suggestions), context.getString(R.string.pref_key_remote_debugging), context.getString(R.string.pref_key_telemetry), @@ -133,7 +137,8 @@ sealed class Event { context.getString(R.string.pref_key_search_browsing_history), context.getString(R.string.pref_key_show_clipboard_suggestions), context.getString(R.string.pref_key_show_search_shortcuts), - context.getString(R.string.pref_key_open_links_in_a_private_tab) + context.getString(R.string.pref_key_open_links_in_a_private_tab), + context.getString(R.string.pref_key_sync_logins) ) override val extras: Map? @@ -144,7 +149,7 @@ sealed class Event { init { // If the event is not in the allow list, we don't want to track it - if (!switchPreferenceTelemetryAllowList.contains(preferenceKey)) { throw IllegalArgumentException() } + require(booleanPreferenceTelemetryAllowList.contains(preferenceKey)) } } diff --git a/app/src/main/java/org/mozilla/fenix/logins/SavedLoginSiteInfoFragment.kt b/app/src/main/java/org/mozilla/fenix/logins/SavedLoginSiteInfoFragment.kt index fdf949931..34e5b5b63 100644 --- a/app/src/main/java/org/mozilla/fenix/logins/SavedLoginSiteInfoFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/logins/SavedLoginSiteInfoFragment.kt @@ -14,6 +14,7 @@ import com.google.android.material.snackbar.Snackbar import kotlinx.android.synthetic.main.fragment_saved_login_site_info.* import org.mozilla.fenix.R import org.mozilla.fenix.components.FenixSnackbar +import org.mozilla.fenix.components.metrics.Event import org.mozilla.fenix.ext.components class SavedLoginSiteInfoFragment : Fragment(R.layout.fragment_saved_login_site_info) { @@ -58,6 +59,7 @@ class SavedLoginSiteInfoFragment : Fragment(R.layout.fragment_saved_login_site_i val clipboard = view.context.components.clipboardHandler clipboard.text = savedLoginItem.password showCopiedSnackbar(getString(R.string.logins_password_copied)) + context?.components?.analytics?.metrics?.track(Event.CopyLogin) } } @@ -69,6 +71,7 @@ class SavedLoginSiteInfoFragment : Fragment(R.layout.fragment_saved_login_site_i private fun togglePasswordReveal() { if (passwordInfoText.inputType == InputType.TYPE_TEXT_VARIATION_PASSWORD or InputType.TYPE_CLASS_TEXT) { + context?.components?.analytics?.metrics?.track(Event.ViewLoginPassword) revealPasswordItem.setImageDrawable(context?.getDrawable(R.drawable.ic_password_hide)) passwordInfoText.inputType = InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD revealPasswordItem.contentDescription = diff --git a/app/src/main/java/org/mozilla/fenix/logins/SavedLoginsFragment.kt b/app/src/main/java/org/mozilla/fenix/logins/SavedLoginsFragment.kt index 2ab7c7ab8..32dbdf6d6 100644 --- a/app/src/main/java/org/mozilla/fenix/logins/SavedLoginsFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/logins/SavedLoginsFragment.kt @@ -22,6 +22,7 @@ import kotlinx.coroutines.launch import mozilla.components.lib.state.ext.consumeFrom import org.mozilla.fenix.R import org.mozilla.fenix.components.StoreProvider +import org.mozilla.fenix.components.metrics.Event import org.mozilla.fenix.ext.components class SavedLoginsFragment : Fragment() { @@ -70,6 +71,7 @@ class SavedLoginsFragment : Fragment() { } private fun itemClicked(item: SavedLoginsItem) { + context?.components?.analytics?.metrics?.track(Event.OpenOneLogin) val directions = SavedLoginsFragmentDirections.actionSavedLoginsFragmentToSavedLoginSiteInfoFragment(item) findNavController().navigate(directions) diff --git a/app/src/main/java/org/mozilla/fenix/settings/LoginsFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/LoginsFragment.kt index 3ba147ae3..32eb22894 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/LoginsFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/LoginsFragment.kt @@ -29,6 +29,8 @@ import mozilla.components.concept.sync.OAuthAccount import mozilla.components.service.fxa.SyncEngine import mozilla.components.service.fxa.manager.SyncEnginesStorage import org.mozilla.fenix.R +import org.mozilla.fenix.components.metrics.Event +import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.getPreferenceKey import org.mozilla.fenix.ext.requireComponents import org.mozilla.fenix.ext.settings @@ -234,6 +236,7 @@ class LoginsFragment : PreferenceFragmentCompat(), AccountObserver { } private fun navigateToSavedLoginsFragment() { + context?.components?.analytics?.metrics?.track(Event.OpenLogins) val directions = LoginsFragmentDirections.actionLoginsFragmentToSavedLoginsFragment() findNavController().navigate(directions) } diff --git a/docs/metrics.md b/docs/metrics.md index 341688615..218e57a61 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -78,7 +78,7 @@ The following metrics are added to the ping: | events.entered_url |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user entered a url |[1](https://github.com/mozilla-mobile/fenix/pull/1067#issuecomment-474598673)|
  • autocomplete: A boolean that tells us whether the URL was autofilled by an Autocomplete suggestion
|2020-03-01 | | events.opened_link |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opened a link with Fenix |[1](https://github.com/mozilla-mobile/fenix/pull/5975)|
  • mode: The mode the link was opened in. Either 'PRIVATE' or 'NORMAL'
|2020-03-01 | | events.performed_search |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user performed a search |[1](https://github.com/mozilla-mobile/fenix/pull/1067#issuecomment-474598673), [2](https://github.com/mozilla-mobile/fenix/pull/1677)|
  • source: A string that tells us how the user performed the search. Possible values are: * default.action * default.suggestion * shortcut.action * shortcut.suggestion
|2020-03-01 | -| events.preference_toggled |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user toggled a preference switch in settings |[1](https://github.com/mozilla-mobile/fenix/pull/1896), [2](https://github.com/mozilla-mobile/fenix/pull/5704), [3](https://github.com/mozilla-mobile/fenix/pull/5886), [4](https://github.com/mozilla-mobile/fenix/pull/5975)|
  • enabled: Whether or not the preference is *now* enabled
  • preference_key: The preference key for the switch preference the user toggled. We currently track: show_search_suggestions, remote_debugging, telemetry, tracking_protection, search_bookmarks, search_browsing_history, show_clipboard_suggestions, show_search_shortcuts, and open_links_in_a_private_tab
|2020-03-01 | +| events.preference_toggled |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user toggled a boolean preference in settings |[1](https://github.com/mozilla-mobile/fenix/pull/1896), [2](https://github.com/mozilla-mobile/fenix/pull/5704), [3](https://github.com/mozilla-mobile/fenix/pull/5886), [4](https://github.com/mozilla-mobile/fenix/pull/5975), [5](https://github.com/mozilla-mobile/fenix/pull/6352)|
  • enabled: Whether or not the preference is *now* enabled
  • preference_key: The preference key for the boolean (true/false) preference the user toggled. We currently track: show_search_suggestions, remote_debugging, telemetry, tracking_protection, search_bookmarks, search_browsing_history, show_clipboard_suggestions, show_search_shortcuts, open_links_in_a_private_tab, and pref_key_sync_logins
|2020-03-01 | | events.search_bar_tapped |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user tapped the search bar |[1](https://github.com/mozilla-mobile/fenix/pull/1067#issuecomment-474598673)|
  • source: The view the user was on when they initiated the search (For example: `Home` or `Browser`)
|2020-03-01 | | events.whats_new_tapped |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opened the "what's new" page button |[1](https://github.com/mozilla-mobile/fenix/pull/5090)|
  • source: The location from which the user selected the what's new button. Either 'about' or 'home'
|2020-03-01 | | find_in_page.closed |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user closed the find in page UI |[1](https://github.com/mozilla-mobile/fenix/pull/1344#issuecomment-479285010)||2020-03-01 | @@ -94,6 +94,10 @@ The following metrics are added to the ping: | library.closed |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user closed the library |[1](https://github.com/mozilla-mobile/fenix/pull/2538#issuecomment-492830242)||2020-03-01 | | library.opened |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opened the library |[1](https://github.com/mozilla-mobile/fenix/pull/2538#issuecomment-492830242)||2020-03-01 | | library.selected_item |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user selected a library item |[1](https://github.com/mozilla-mobile/fenix/pull/2538#issuecomment-492830242)|
  • item: The library item the user selected
|2020-03-01 | +| logins.copy_login |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user copied a piece of a login in saved logins |[1](https://github.com/mozilla-mobile/fenix/pull/6352)||2020-03-01 | +| logins.open_individual_login |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user accessed an individual login in saved logins |[1](https://github.com/mozilla-mobile/fenix/pull/6352)||2020-03-01 | +| logins.open_logins |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user accessed Logins in Settings |[1](https://github.com/mozilla-mobile/fenix/pull/6352)||2020-03-01 | +| logins.view_password_login |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user viewed a password in an individual saved login |[1](https://github.com/mozilla-mobile/fenix/pull/6352)||2020-03-01 | | media_notification.pause |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user pressed the pause icon on the media notification |[1](https://github.com/mozilla-mobile/fenix/pull/5520)||2020-03-01 | | media_notification.play |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user pressed the play icon on the media notification |[1](https://github.com/mozilla-mobile/fenix/pull/5520)||2020-03-01 | | private_browsing_mode.garbage_icon |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user pressed the garbage can icon on the private browsing home page, deleting all private tabs. |[1](https://github.com/mozilla-mobile/fenix/pull/4968)||2020-03-01 |