From 9aa4f48e77001058c05f3d3182228706720bf87a Mon Sep 17 00:00:00 2001 From: Sawyer Blatz Date: Fri, 24 May 2019 08:25:00 -0700 Subject: [PATCH] For #1190: Adds additional telemetry for FxA login --- app/metrics.yaml | 94 ++++++++++++------- .../components/metrics/GleanMetricsService.kt | 37 +++++--- .../fenix/components/metrics/Metrics.kt | 16 ++-- .../fenix/settings/AccountSettingsFragment.kt | 7 +- .../fenix/settings/SettingsFragment.kt | 1 - .../fenix/settings/TurnOnSyncFragment.kt | 10 +- 6 files changed, 99 insertions(+), 66 deletions(-) diff --git a/app/metrics.yaml b/app/metrics.yaml index 8c4bd8c76..5575ab886 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -138,31 +138,31 @@ events: expires: "2020-03-01" crash_reporter: - opened: - type: event - description: > - The crash reporter was displayed - bugs: - - 1040 - data_reviews: - - TBD - notification_emails: - - fenix-core@mozilla.com - expires: "2020-03-01" - closed: - type: event - description: > - The crash reporter was closed - extra_keys: - crash_submitted: - description: "A boolean that tells us whether or not the user submitted a crash report" - bugs: - - 1040 - data_reviews: - - TBD - notification_emails: - - fenix-core@mozilla.com - expires: "2020-03-01" + opened: + type: event + description: > + The crash reporter was displayed + bugs: + - 1040 + data_reviews: + - TBD + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" + closed: + type: event + description: > + The crash reporter was closed + extra_keys: + crash_submitted: + description: "A boolean that tells us whether or not the user submitted a crash report" + bugs: + - 1040 + data_reviews: + - TBD + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" context_menu: item_tapped: @@ -345,9 +345,9 @@ metrics: mozilla_products: type: string_list description: > - A list of all the Mozilla products installed on device. We currently scan for: Firefox, Firefox Beta, - Firefox Aurora, Firefox Nightly, Firefox Fdroid, Firefox Lite, Reference Browser, Reference Browser Debug, - Fenix, Focus, and Lockbox. + A list of all the Mozilla products installed on device. We currently scan for: Firefox, Firefox Beta, + Firefox Aurora, Firefox Nightly, Firefox Fdroid, Firefox Lite, Reference Browser, Reference Browser Debug, + Fenix, Focus, and Lockbox. send_in_pings: - metrics bugs: @@ -746,11 +746,11 @@ error_page: - fenix-core@mozilla.com expires: "2020-03-01" -sync: +sync_auth: opened: type: event description: > - A user opened the sync page + A user opened the sync authentication page bugs: - 1190 data_reviews: @@ -772,7 +772,7 @@ sync: sign_in: type: event description: > - A user pressed the sign in button on the sync page + A user pressed the sign in button on the sync authentication page bugs: - 1190 data_reviews: @@ -783,7 +783,7 @@ sync: scan_pairing: type: event description: > - A user pressed the scan pairing button on the sync page + A user pressed the scan pairing button on the sync authentication page bugs: - 1190 data_reviews: @@ -794,7 +794,31 @@ sync: create_account: type: event description: > - A user pressed the create account button on the sync page + A user pressed the create account button on the sync authentication page + bugs: + - 1190 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/2745#issuecomment-494918532 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" + +sync_account: + opened: + type: event + description: > + A user opened the sync account page + bugs: + - 1190 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/2745#issuecomment-494918532 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" + closed: + type: event + description: > + A user closed the sync account page bugs: - 1190 data_reviews: @@ -805,7 +829,7 @@ sync: sync_now: type: event description: > - A user pressed the sync now button on the sync page + A user pressed the sync now button on the sync account page bugs: - 1190 data_reviews: @@ -816,7 +840,7 @@ sync: sign_out: type: event description: > - A user pressed the sign out button on the sync page + A user pressed the sign out button on the sync account page bugs: - 1190 data_reviews: 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 61ea64d41..c33ebef1a 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 @@ -26,7 +26,8 @@ import kotlinx.coroutines.runBlocking import org.mozilla.fenix.GleanMetrics.QrScanner import org.mozilla.fenix.GleanMetrics.Library import org.mozilla.fenix.GleanMetrics.ErrorPage -import org.mozilla.fenix.GleanMetrics.Sync +import org.mozilla.fenix.GleanMetrics.SyncAccount +import org.mozilla.fenix.GleanMetrics.SyncAuth import org.mozilla.fenix.R import org.mozilla.fenix.ext.getPreferenceKey import org.mozilla.fenix.utils.Settings @@ -192,26 +193,32 @@ private val Event.wrapper { ErrorPage.visitedError }, { ErrorPage.visitedErrorKeys.valueOf(it) } ) - is Event.SyncOpened -> EventWrapper( - { Sync.opened.record(it) } + is Event.SyncAuthOpened -> EventWrapper( + { SyncAuth.opened.record(it) } ) - is Event.SyncClosed -> EventWrapper( - { Sync.closed.record(it) } + is Event.SyncAuthClosed -> EventWrapper( + { SyncAuth.closed.record(it) } ) - is Event.SyncSignIn -> EventWrapper( - { Sync.signIn.record(it) } + is Event.SyncAuthSignIn -> EventWrapper( + { SyncAuth.signIn.record(it) } ) - is Event.SyncScanPairing -> EventWrapper( - { Sync.scanPairing.record(it) } + is Event.SyncAuthScanPairing -> EventWrapper( + { SyncAuth.scanPairing.record(it) } ) - is Event.SyncCreateAccount -> EventWrapper( - { Sync.createAccount.record(it) } + is Event.SyncAuthCreateAccount -> EventWrapper( + { SyncAuth.createAccount.record(it) } ) - is Event.SyncSyncNow -> EventWrapper( - { Sync.syncNow.record(it) } + is Event.SyncAccountOpened -> EventWrapper( + { SyncAccount.opened.record(it) } ) - is Event.SyncSignOut -> EventWrapper( - { Sync.signOut.record(it) } + is Event.SyncAccountClosed -> EventWrapper( + { SyncAccount.closed.record(it) } + ) + is Event.SyncAccountSyncNow -> EventWrapper( + { SyncAccount.syncNow.record(it) } + ) + is Event.SyncAccountSignOut -> EventWrapper( + { SyncAccount.signOut.record(it) } ) // Don't track other events with Glean 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 b8cce0640..fb7e4cff4 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 @@ -81,13 +81,15 @@ sealed class Event { object QRScannerNavigationDenied : Event() object LibraryOpened : Event() object LibraryClosed : Event() - object SyncOpened : Event() - object SyncClosed : Event() - object SyncSignIn : Event() - object SyncScanPairing : Event() - object SyncCreateAccount : Event() - object SyncSyncNow : Event() - object SyncSignOut : Event() + object SyncAuthOpened : Event() + object SyncAuthClosed : Event() + object SyncAuthSignIn : Event() + object SyncAuthScanPairing : Event() + object SyncAuthCreateAccount : Event() + object SyncAccountOpened : Event() + object SyncAccountClosed : Event() + object SyncAccountSyncNow : Event() + object SyncAccountSignOut : Event() data class PreferenceToggled(val preferenceKey: String, val enabled: Boolean, val context: Context) : Event() { private val switchPreferenceTelemetryAllowList = listOf( diff --git a/app/src/main/java/org/mozilla/fenix/settings/AccountSettingsFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/AccountSettingsFragment.kt index 28c40171a..5e32d3132 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/AccountSettingsFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/AccountSettingsFragment.kt @@ -45,11 +45,13 @@ class AccountSettingsFragment : PreferenceFragmentCompat(), CoroutineScope { job = Job() (activity as AppCompatActivity).title = getString(R.string.preferences_account_settings) (activity as AppCompatActivity).supportActionBar?.show() + requireComponents.analytics.metrics.track(Event.SyncAccountOpened) } override fun onDestroy() { super.onDestroy() job.cancel() + requireComponents.analytics.metrics.track(Event.SyncAccountClosed) } override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { @@ -97,7 +99,7 @@ class AccountSettingsFragment : PreferenceFragmentCompat(), CoroutineScope { private fun getClickListenerForSignOut(): Preference.OnPreferenceClickListener { return Preference.OnPreferenceClickListener { - requireComponents.analytics.metrics.track(Event.SyncSignOut) + requireComponents.analytics.metrics.track(Event.SyncAccountSignOut) launch { accountManager.logoutAsync().await() Navigation.findNavController(view!!).popBackStack() @@ -109,7 +111,7 @@ class AccountSettingsFragment : PreferenceFragmentCompat(), CoroutineScope { private fun getClickListenerForSyncNow(): Preference.OnPreferenceClickListener { return Preference.OnPreferenceClickListener { // Trigger a sync. - requireComponents.analytics.metrics.track(Event.SyncSyncNow) + requireComponents.analytics.metrics.track(Event.SyncAccountSyncNow) requireComponents.backgroundServices.syncManager.syncNow() // Poll for device events. launch { @@ -183,7 +185,6 @@ class AccountSettingsFragment : PreferenceFragmentCompat(), CoroutineScope { } } - private val deviceConstellationObserver = object : DeviceConstellationObserver { override fun onDevicesUpdate(constellation: ConstellationState) { val deviceNameKey = context!!.getPreferenceKey(R.string.pref_key_sync_device_name) diff --git a/app/src/main/java/org/mozilla/fenix/settings/SettingsFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/SettingsFragment.kt index c78d03045..24e61d204 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/SettingsFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/SettingsFragment.kt @@ -203,7 +203,6 @@ class SettingsFragment : PreferenceFragmentCompat(), CoroutineScope, AccountObse private fun getClickListenerForSignIn(): OnPreferenceClickListener { return OnPreferenceClickListener { - requireComponents.analytics.metrics.track(Event.SyncOpened) val directions = SettingsFragmentDirections.actionSettingsFragmentToTurnOnSyncFragment() Navigation.findNavController(view!!).navigate(directions) true diff --git a/app/src/main/java/org/mozilla/fenix/settings/TurnOnSyncFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/TurnOnSyncFragment.kt index 80e5b4a1c..ad8793f7d 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/TurnOnSyncFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/TurnOnSyncFragment.kt @@ -20,12 +20,12 @@ class TurnOnSyncFragment : PreferenceFragmentCompat() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - requireComponents.analytics.metrics.track(Event.SyncOpened) + requireComponents.analytics.metrics.track(Event.SyncAuthOpened) } override fun onDestroy() { super.onDestroy() - requireComponents.analytics.metrics.track(Event.SyncClosed) + requireComponents.analytics.metrics.track(Event.SyncAuthClosed) } override fun onResume() { @@ -56,7 +56,7 @@ class TurnOnSyncFragment : PreferenceFragmentCompat() { // session history stack. // We could auto-close this tab once we get to the end of the authentication process? // Via an interceptor, perhaps. - requireComponents.analytics.metrics.track(Event.SyncSignIn) + requireComponents.analytics.metrics.track(Event.SyncAuthSignIn) view?.let { (activity as HomeActivity).openToBrowser(BrowserDirection.FromTurnOnSync) } @@ -68,7 +68,7 @@ class TurnOnSyncFragment : PreferenceFragmentCompat() { // Currently the same as sign in, as FxA handles this, however we want to emit a different telemetry event return Preference.OnPreferenceClickListener { requireComponents.services.accountsAuthFeature.beginAuthentication() - requireComponents.analytics.metrics.track(Event.SyncCreateAccount) + requireComponents.analytics.metrics.track(Event.SyncAuthCreateAccount) view?.let { (activity as HomeActivity).openToBrowser(BrowserDirection.FromTurnOnSync) } @@ -80,7 +80,7 @@ class TurnOnSyncFragment : PreferenceFragmentCompat() { return Preference.OnPreferenceClickListener { val directions = TurnOnSyncFragmentDirections.actionTurnOnSyncFragmentToPairInstructionsFragment() Navigation.findNavController(view!!).navigate(directions) - requireComponents.analytics.metrics.track(Event.SyncScanPairing) + requireComponents.analytics.metrics.track(Event.SyncAuthScanPairing) true }