For #4421: Adds Leanplum events and attributes (#4626)

* For #4421: Adds Leanplum events and attributes

* For #4421: Adds Leanplum deep links
This commit is contained in:
Sawyer Blatz 2019-08-14 13:48:45 -07:00 committed by Jeff Boek
parent 67f3b63ae5
commit b7ca520787
13 changed files with 202 additions and 51 deletions

View File

@ -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:

View File

@ -34,6 +34,30 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="fenix"
android:host="home"/>
<data android:scheme="fenix"
android:host="settings"/>
<data android:scheme="fenix"
android:host="turn_on_sync"/>
<data android:scheme="fenix"
android:host="settings_search_engine"/>
<data android:scheme="fenix"
android:host="settings_accessibility"/>
<data android:scheme="fenix"
android:host="settings_delete_browsing_data"/>
<data android:scheme="fenix"
android:host="enable_private_browsing"/>
<data android:scheme="fenix"
android:host="open"/>
<data android:scheme="fenix"
android:host="make_default_browser"/>
</intent-filter>
</activity>
<activity

View File

@ -6,6 +6,8 @@ package org.mozilla.fenix
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.util.AttributeSet
import android.view.View
@ -192,6 +194,8 @@ open class HomeActivity : AppCompatActivity(), ShareFragment.TabsSharedCallback
components.analytics.metrics.track(Event.SearchWidgetNewTabPressed)
navHost.navController.nav(null, NavGraphDirections.actionGlobalSearch(null))
return
} else if (intent?.scheme == "fenix") {
intent.data?.let { handleDeepLink(it) }
}
if (intent?.extras?.getBoolean(OPEN_TO_BROWSER) != true) return
@ -206,6 +210,49 @@ open class HomeActivity : AppCompatActivity(), ShareFragment.TabsSharedCallback
openToBrowser(BrowserDirection.FromGlobal, customTabSessionId)
}
@SuppressWarnings("ComplexMethod")
private fun handleDeepLink(uri: Uri) {
val link = uri.host
// Handle links that require more than just simple navigation
when (link) {
"enable_private_browsing" -> {
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,

View File

@ -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)
}
}

View File

@ -209,6 +209,9 @@ private val Event.wrapper
is Event.SyncAuthSignIn -> EventWrapper<NoExtraKeys>(
{ SyncAuth.signIn.record(it) }
)
is Event.SyncAuthSignOut -> EventWrapper<NoExtraKeys>(
{ SyncAuth.signOut.record(it) }
)
is Event.SyncAuthScanPairing -> EventWrapper<NoExtraKeys>(
{ SyncAuth.scanPairing.record(it) }
)
@ -224,9 +227,6 @@ private val Event.wrapper
is Event.SyncAccountSyncNow -> EventWrapper<NoExtraKeys>(
{ SyncAccount.syncNow.record(it) }
)
is Event.SyncAccountSignOut -> EventWrapper<NoExtraKeys>(
{ 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<NoExtraKeys>(
{ SearchWidget.voiceButton.record(it) }
)
is Event.FXANewSignup -> EventWrapper<NoExtraKeys>(
{ Collections.renameButton.record(it) }
)
// Don't track other events with Glean
else -> null

View File

@ -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 -> ""

View File

@ -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()

View File

@ -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)
}
}
}

View File

@ -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 {

View File

@ -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)
}
}

View File

@ -466,4 +466,19 @@
<dialog
android:id="@+id/signOutFragment"
android:name="org.mozilla.fenix.settings.SignOutFragment" />
<action
android:id="@+id/action_global_settingsFragment"
app:destination="@id/settingsFragment" />
<action
android:id="@+id/action_global_searchEngineFragment"
app:destination="@id/searchEngineFragment" />
<action
android:id="@+id/action_global_accessibilityFragment"
app:destination="@id/accessibilityFragment" />
<action
android:id="@+id/action_global_deleteBrowsingDataFragment"
app:destination="@id/deleteBrowsingDataFragment" />
<action
android:id="@+id/action_global_homeFragment"
app:destination="@id/homeFragment" />
</navigation>

View File

@ -634,7 +634,7 @@ tracking_protection</td>
<tr>
<td>sign_in</td>
<td>event</td>
<td>A user pressed the sign in button on the sync authentication page</td>
<td>A user pressed the sign in button on the sync authentication page and was successfully signed in to FxA</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/2745#issuecomment-494918532">link</a></td>
<td></td>
<td>2020-03-01</td>
@ -694,14 +694,6 @@ tracking_protection</td>
<td></td>
<td>2020-03-01</td>
</tr>
<tr>
<td>sign_out</td>
<td>event</td>
<td>A user pressed the sign out button on the sync account page</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/2745#issuecomment-494918532">link</a></td>
<td></td>
<td>2020-03-01</td>
</tr>
</table>
</pre>

View File

@ -191,6 +191,86 @@ Here is the list of current Events sent, which can be found here in the code bas
<td>The user removed a bookmark</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/3632#issuecomment-505135753">#3632</a></td>
</tr>
<tr>
<td>`E_Collection_Created`</td>
<td>The user created a new collection</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/4626#issuecomment-519691332">#4626</a></td>
</tr>
<tr>
<td>`E_Collection_Tab_Opened`</td>
<td>The user opened a tab from a previously created collection</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/4626#issuecomment-519691332">#4626</a></td>
</tr>
<tr>
<td>`E_Sign_In_FxA`</td>
<td>The user successfully signed in to FxA</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/4626#issuecomment-519691332">#4626</a></td>
</tr>
<tr>
<td>`E_Sign_Out_FxA`</td>
<td>The user successfully signed out of FxA</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/4626#issuecomment-519691332">#4626</a></td>
</tr>
<tr>
<td>`E_New_Sign_Up_FxA`</td>
<td>The user successfully signed up for a new FxA account</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/4626#issuecomment-519691332">#4626</a></td>
</tr>
<tr>
<td>`E_Cleared_Private_Data`</td>
<td>The user cleared one or many types of private data</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/4626#issuecomment-519691332">#4626</a></td>
</tr>
</table>
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
<table>
<tr>
<th>Deep link</th>
<th>Description</th>
</tr>
<tr>
<td>`fenix://home`</td>
<td>Opens to the Fenix home screen</td>
</tr>
<tr>
<td>`fenix://settings`</td>
<td>Opens to the top level settings screen</td>
</tr>
<tr>
<td>`fenix://turn_on_sync`</td>
<td>Opens to the turn on sync screen. **Only valid if the user is not signed in to FxA**</td>
</tr>
<tr>
<td>`fenix://settings_search_engine`</td>
<td>Opens to the search engine settings screen</td>
</tr>
<tr>
<td>`fenix://settings_accessibility`</td>
<td>Opens to the accessibility settings screen</td>
</tr>
<tr>
<td>`fenix://settings_delete_browsing_data`</td>
<td>Opens to the delete browsing data settings screen</td>
</tr>
<tr>
<td>`fenix://enable_private_browsing`</td>
<td>Opens to the Fenix home screen and enables private browsing</td>
</tr>
<tr>
<td>`fenix://open?url={DESIRED_URL}`</td>
<td>Creates a new tab, opens to the browser screen and loads the {DESIRED_URL}</td>
</tr>
<tr>
<td>`fenix://make_default_browser`</td>
<td>Opens to the Android default apps settings screen. **Only works on Android API >=24**</td>
</tr>
</table>
Messages