From b7ca52078754b8f131cc2c144acba3040cd2d8fe Mon Sep 17 00:00:00 2001 From: Sawyer Blatz Date: Wed, 14 Aug 2019 13:48:45 -0700 Subject: [PATCH] For #4421: Adds Leanplum events and attributes (#4626) * For #4421: Adds Leanplum events and attributes * For #4421: Adds Leanplum deep links --- app/metrics.yaml | 24 +++--- app/src/main/AndroidManifest.xml | 24 ++++++ .../java/org/mozilla/fenix/HomeActivity.kt | 47 +++++++++++ .../fenix/components/BackgroundServices.kt | 8 ++ .../components/metrics/GleanMetricsService.kt | 9 ++- .../metrics/LeanplumMetricsService.kt | 6 ++ .../fenix/components/metrics/Metrics.kt | 25 +----- .../settings/DeleteBrowsingDataFragment.kt | 2 + .../mozilla/fenix/settings/SignOutFragment.kt | 2 - .../fenix/settings/TurnOnSyncFragment.kt | 1 - app/src/main/res/navigation/nav_graph.xml | 15 ++++ docs/metrics.md | 10 +-- docs/mma.md | 80 +++++++++++++++++++ 13 files changed, 202 insertions(+), 51 deletions(-) diff --git a/app/metrics.yaml b/app/metrics.yaml index 19e326590..f2ce0f37d 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -774,7 +774,7 @@ sync_auth: sign_in: type: event description: > - A user pressed the sign in button on the sync authentication page + A user pressed the sign in button on the sync authentication page and was successfully signed in to FxA bugs: - 1190 data_reviews: @@ -782,6 +782,17 @@ sync_auth: notification_emails: - fenix-core@mozilla.com expires: "2020-03-01" + sign_out: + type: event + description: > + A user pressed the sign out button on the sync account page and was successfully signed out of FxA + bugs: + - 1190 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/2745#issuecomment-494918532 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" scan_pairing: type: event description: > @@ -839,17 +850,6 @@ sync_account: notification_emails: - fenix-core@mozilla.com expires: "2020-03-01" - sign_out: - type: event - description: > - A user pressed the sign out button on 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" history: opened: diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 61bb72dbb..c63dcf1cb 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -34,6 +34,30 @@ + + + + + + + + + + + + + + + { + navHost.navController.navigate(NavGraphDirections.actionGlobalHomeFragment()) + browsingModeManager.mode = BrowsingMode.Private + } + "make_default_browser" -> { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { return } + val settingsIntent = Intent( + android.provider.Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS + ) + startActivity(settingsIntent) + } + "open" -> { + uri.getQueryParameter("url")?.let { + load( + searchTermOrURL = it, + newTab = true, + engine = null, + forceSearch = false + ) + navHost.navController.navigate(NavGraphDirections.actionGlobalBrowser(null)) + } + } + } + + val directions = when (link) { + "home" -> NavGraphDirections.actionGlobalHomeFragment() + "settings" -> NavGraphDirections.actionGlobalSettingsFragment() + "turn_on_sync" -> NavGraphDirections.actionGlobalTurnOnSync() + "settings_search_engine" -> NavGraphDirections.actionGlobalSearchEngineFragment() + "settings_accessibility" -> NavGraphDirections.actionGlobalAccessibilityFragment() + "settings_delete_browsing_data" -> NavGraphDirections.actionGlobalDeleteBrowsingDataFragment() + else -> return + } + + navHost.navController.navigate(directions) + } + @Suppress("LongParameterList") fun openToBrowserAndLoad( searchTermOrURL: String, diff --git a/app/src/main/java/org/mozilla/fenix/components/BackgroundServices.kt b/app/src/main/java/org/mozilla/fenix/components/BackgroundServices.kt index 6a0c2a7f9..d3643ff68 100644 --- a/app/src/main/java/org/mozilla/fenix/components/BackgroundServices.kt +++ b/app/src/main/java/org/mozilla/fenix/components/BackgroundServices.kt @@ -36,6 +36,8 @@ import mozilla.components.support.base.log.logger.Logger import org.mozilla.fenix.Experiments import org.mozilla.fenix.FeatureFlags import org.mozilla.fenix.R +import org.mozilla.fenix.components.metrics.Event +import org.mozilla.fenix.ext.components import org.mozilla.fenix.isInExperiment import org.mozilla.fenix.test.Mockable import org.mozilla.fenix.utils.Settings @@ -139,6 +141,8 @@ class BackgroundServices( push.unsubscribeForType(PushType.Services) + context.components.analytics.metrics.track(Event.SyncAuthSignOut) + Settings.instance?.setFxaSignedIn(false) } @@ -146,8 +150,12 @@ class BackgroundServices( pushService.start(context) if (newAccount) { + context.components.analytics.metrics.track(Event.FXANewSignup) push.subscribeForType(PushType.Services) } + + context.components.analytics.metrics.track(Event.SyncAuthSignIn) + Settings.instance?.setFxaSignedIn(true) } } 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 3d250cf75..d8c7af289 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 @@ -209,6 +209,9 @@ private val Event.wrapper is Event.SyncAuthSignIn -> EventWrapper( { SyncAuth.signIn.record(it) } ) + is Event.SyncAuthSignOut -> EventWrapper( + { SyncAuth.signOut.record(it) } + ) is Event.SyncAuthScanPairing -> EventWrapper( { SyncAuth.scanPairing.record(it) } ) @@ -224,9 +227,6 @@ private val Event.wrapper is Event.SyncAccountSyncNow -> EventWrapper( { SyncAccount.syncNow.record(it) } ) - is Event.SyncAccountSignOut -> EventWrapper( - { SyncAccount.signOut.record(it) } - ) is Event.PreferenceToggled -> EventWrapper( { Events.preferenceToggled.record(it) }, { Events.preferenceToggledKeys.valueOf(it) } @@ -300,6 +300,9 @@ private val Event.wrapper is Event.SearchWidgetVoiceSearchPressed -> EventWrapper( { SearchWidget.voiceButton.record(it) } ) + is Event.FXANewSignup -> EventWrapper( + { Collections.renameButton.record(it) } + ) // Don't track other events with Glean else -> null diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt index 07bd2f4bc..f91509718 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt @@ -23,6 +23,12 @@ private val Event.name: String? is Event.OpenedApp -> "E_Opened_App" is Event.OpenedAppFirstRun -> "E_Opened_App_FirstRun" is Event.InteractWithSearchURLArea -> "E_Interact_With_Search_URL_Area" + is Event.CollectionSaved -> "E_Collection_Created" + is Event.CollectionTabRestored -> "E_Collection_Tab_Opened" + is Event.SyncAuthSignIn -> "E_Sign_In_FxA" + is Event.SyncAuthSignOut -> "E_Sign_Out_FxA" + is Event.FXANewSignup -> "E_New_Sign_Up_FxA" + is Event.ClearedPrivateData -> "E_Cleared_Private_Data" // Do not track other events in Leanplum else -> "" 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 df0f61d09..b5d520098 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 @@ -27,31 +27,9 @@ sealed class Event { object OpenedAppFirstRun : Event() object InteractWithSearchURLArea : Event() - object SavedLoginandPassword : Event() object FXANewSignup : Event() - object UserSignedInToFxA : Event() - object UserDownloadedFocus : Event() - object UserDownloadedLockbox : Event() - object UserDownloadedFennec : Event() - object TrackingProtectionSettingsChanged : Event() - object FXASyncedNewDevice : Event() object DismissedOnboarding : Event() - object Uninstall : Event() - object OpenNewNormalTab : Event() - object OpenNewPrivateTab : Event() - object ShareStarted : Event() - object ShareCanceled : Event() - object ShareCompleted : Event() - object ClosePrivateTabs : Event() object ClearedPrivateData : Event() - object OpenedLoginManager : Event() - object OpenedMailtoLink : Event() - object DownloadMediaSavedImage : Event() - object UserUsedReaderView : Event() - object UserDownloadedPocket : Event() - object UserDownloadedSend : Event() - object OpenedPocketStory : Event() - object DarkModeEnabled : Event() object SearchShortcutMenuOpened : Event() object SearchShortcutMenuClosed : Event() object AddBookmark : Event() @@ -87,12 +65,12 @@ sealed class Event { object SyncAuthOpened : Event() object SyncAuthClosed : Event() object SyncAuthSignIn : Event() + object SyncAuthSignOut : Event() object SyncAuthScanPairing : Event() object SyncAuthCreateAccount : Event() object SyncAccountOpened : Event() object SyncAccountClosed : Event() object SyncAccountSyncNow : Event() - object SyncAccountSignOut : Event() object HistoryOpened : Event() object HistoryItemShared : Event() object HistoryItemOpened : Event() @@ -100,7 +78,6 @@ sealed class Event { object HistoryAllItemsRemoved : Event() object ReaderModeAvailable : Event() object ReaderModeOpened : Event() - object ReaderModeClosed : Event() object ReaderModeAppearanceOpened : Event() object CollectionRenamed : Event() object CollectionTabRestored : Event() diff --git a/app/src/main/java/org/mozilla/fenix/settings/DeleteBrowsingDataFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/DeleteBrowsingDataFragment.kt index 0637814d0..26b5b77da 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/DeleteBrowsingDataFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/DeleteBrowsingDataFragment.kt @@ -27,6 +27,7 @@ import mozilla.components.concept.engine.Engine import mozilla.components.feature.tab.collections.TabCollection import org.mozilla.fenix.R import org.mozilla.fenix.components.FenixSnackbar +import org.mozilla.fenix.components.metrics.Event import org.mozilla.fenix.ext.requireComponents @SuppressWarnings("TooManyFunctions") @@ -111,6 +112,7 @@ class DeleteBrowsingDataFragment : Fragment() { launch(Dispatchers.Main) { finishDeletion() + requireComponents.analytics.metrics.track(Event.ClearedPrivateData) } } } diff --git a/app/src/main/java/org/mozilla/fenix/settings/SignOutFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/SignOutFragment.kt index d58acd8f2..10eaaa37b 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/SignOutFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/SignOutFragment.kt @@ -19,7 +19,6 @@ import kotlinx.android.synthetic.main.fragment_sign_out.view.* import kotlinx.coroutines.launch import mozilla.components.service.fxa.manager.FxaAccountManager import org.mozilla.fenix.R -import org.mozilla.fenix.components.metrics.Event import org.mozilla.fenix.ext.requireComponents class SignOutFragment : BottomSheetDialogFragment() { @@ -57,7 +56,6 @@ class SignOutFragment : BottomSheetDialogFragment() { super.onViewCreated(view, savedInstanceState) view.signOutDisconnect.setOnClickListener { - requireComponents.analytics.metrics.track(Event.SyncAccountSignOut) lifecycleScope.launch { accountManager.logoutAsync().await() }.invokeOnCompletion { 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 f958ceceb..43a425fd3 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/TurnOnSyncFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/TurnOnSyncFragment.kt @@ -64,7 +64,6 @@ class TurnOnSyncFragment : Fragment(), AccountObserver { // 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.SyncAuthSignIn) } } diff --git a/app/src/main/res/navigation/nav_graph.xml b/app/src/main/res/navigation/nav_graph.xml index e5f125578..40ff313ff 100644 --- a/app/src/main/res/navigation/nav_graph.xml +++ b/app/src/main/res/navigation/nav_graph.xml @@ -466,4 +466,19 @@ + + + + + \ No newline at end of file diff --git a/docs/metrics.md b/docs/metrics.md index 3fa0305f9..46af067b3 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -634,7 +634,7 @@ tracking_protection sign_in event - A user pressed the sign in button on the sync authentication page + A user pressed the sign in button on the sync authentication page and was successfully signed in to FxA link 2020-03-01 @@ -694,14 +694,6 @@ tracking_protection 2020-03-01 - - sign_out - event - A user pressed the sign out button on the sync account page - link - - 2020-03-01 - diff --git a/docs/mma.md b/docs/mma.md index fe93f8d3b..3d7d1cd62 100644 --- a/docs/mma.md +++ b/docs/mma.md @@ -191,6 +191,86 @@ Here is the list of current Events sent, which can be found here in the code bas The user removed a bookmark #3632 + + `E_Collection_Created` + The user created a new collection + #4626 + + + `E_Collection_Tab_Opened` + The user opened a tab from a previously created collection + #4626 + + + `E_Sign_In_FxA` + The user successfully signed in to FxA + #4626 + + + `E_Sign_Out_FxA` + The user successfully signed out of FxA + #4626 + + + `E_New_Sign_Up_FxA` + The user successfully signed up for a new FxA account + #4626 + + + `E_Cleared_Private_Data` + The user cleared one or many types of private data + #4626 + + + +Deep links +------- +Deep links are hooks utilized by marketing to direct users to certain portions of the application through a link. They can also be invoked by other applications or even users +directly to access specific screens quickly. + +Here is the list of current deep links available, which can be found here in the code base: https://github.com/mozilla-mobile/fenix/blob/master/app/src/main/AndroidManifest.xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Deep linkDescription
`fenix://home`Opens to the Fenix home screen
`fenix://settings`Opens to the top level settings screen
`fenix://turn_on_sync`Opens to the turn on sync screen. **Only valid if the user is not signed in to FxA**
`fenix://settings_search_engine`Opens to the search engine settings screen
`fenix://settings_accessibility`Opens to the accessibility settings screen
`fenix://settings_delete_browsing_data`Opens to the delete browsing data settings screen
`fenix://enable_private_browsing`Opens to the Fenix home screen and enables private browsing
`fenix://open?url={DESIRED_URL}`Creates a new tab, opens to the browser screen and loads the {DESIRED_URL}
`fenix://make_default_browser`Opens to the Android default apps settings screen. **Only works on Android API >=24**
Messages