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

Commit

Permalink
For #981 - mma docs
Browse files Browse the repository at this point in the history
  • Loading branch information
boek committed Jun 14, 2019
1 parent f323c38 commit 45b096c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.leanplum.annotations.Parser
import com.leanplum.internal.LeanplumInternal
import org.mozilla.fenix.BuildConfig
import org.mozilla.fenix.utils.Settings
import java.util.*

private val Event.name: String?
get() = when (this) {
Expand Down Expand Up @@ -57,11 +58,18 @@ class LeanplumMetricsService(private val application: Application) : MetricsServ

Leanplum.setIsTestModeEnabled(false)
Leanplum.setApplicationContext(application)
Leanplum.setDeviceId(UUID.randomUUID().toString())
Parser.parseVariables(application)

LeanplumActivityHelper.enableLifecycleCallbacks(application)

val installedApps = MozillaProductDetector.getInstalledMozillaProducts(application)

Leanplum.start(application, hashMapOf(
"default_browser" to (MozillaProductDetector.getMozillaBrowserDefault(application) ?: "")
"default_browser" to (MozillaProductDetector.getMozillaBrowserDefault(application) ?: ""),
"fennec_installed" to installedApps.contains(MozillaProductDetector.MozillaProducts.FIREFOX.productName),
"focus_installed" to installedApps.contains(MozillaProductDetector.MozillaProducts.FOCUS.productName),
"klar_installed" to installedApps.contains(MozillaProductDetector.MozillaProducts.KLAR.productName)
))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ object MozillaProductDetector {
REFERENCE_BROWSER_DEBUG("org.mozilla.reference.browser.debug"),
FENIX("org.mozilla.fenix"),
FOCUS("org.mozilla.focus"),
KLAR("org.mozilla.klar"),

// Other products
LOCKWISE("mozilla.lockbox")
Expand Down
63 changes: 23 additions & 40 deletions docs/mma.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Mozilla is using a third party framework called "Leanplum" in order to achieve t

The SDK is documented at https://www.leanplum.com/docs/android

There are three major component in Leanplum SDK.
There are four major components in Leanplum SDK.
1. Events : Events are fired when users perform certain actions.
2. User Attributes: User Attributes are set on a per-user basis, and inform us about an aspect of the user.
3. Deep Links: Actions that users can perform to interact with the Message.
Expand All @@ -23,22 +23,16 @@ Data collection
Who will have Leanplum enabled?
======================================================

Users who have a device locale listed in the following code snippet will have Leanplum enabled: https://github.com/mozilla-mobile/firefox-ios/blob/master/Client/Application/LeanplumIntegration.swift

--- ^ Note: NEED TO CONFIRM WITH ENG ---
Everyone with Telemetry enabled.


Where does data sent to the Leanplum backend go?
==============================================

The Leanplum SDK is hard-coded to send data to the endpoint https://www.leanplum.com. The endpoint is
defined by ``com.leanplum.internal.Constants.API_HOST_NAME`` at

--- Note: NEED TO CONFIRM WITH ENG ---
defined by ``com.leanplum.internal.Constants.API_HOST_NAME`` at https://github.com/Leanplum/Leanplum-Android-SDK/blob/master/AndroidSDKCore/src/main/java/com/leanplum/internal/Constants.java#L32

https://searchfox.org/mozilla-central/rev/c49a70b53f67dd5550eec8a08793805f2aca8d42/mobile/android/thirdparty/com/leanplum/internal/Constants.java#32.

The user is identified by Leanplum using a random UUID generated by Apple when Leanplum is initialized for the first time (see https://developer.apple.com/documentation/uikit/uidevice/1620059-identifierforvendor).
The user is identified by Leanplum using a random UUID generated by us when Leanplum is initialized for the first time. See: https://github.com/mozilla-mobile/fenix/blob/master/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt
This unique identifier is only used by Leanplum and can't be tracked back to any Firefox users.


Expand All @@ -48,7 +42,6 @@ What data is collected and sent to the Leanplum backend?
The Leanplum SDK collects and sends the following information at various times while the SDK is in use.

Sent every time when an event is triggered:
--- Note: NEED TO CONFIRM WITH ENG ---
~~~~~~~~~~~~~~~
"action" -> "track" // track: an event is tracked.
"event" -> "Launch" // Used when an event is triggered. e.g. E_Saved_Bookmark.
Expand All @@ -58,7 +51,6 @@ Sent every time when an event is triggered:
~~~~~~~~~~~~~~~

Sent when the app starts:
--- Note: NEED TO CONFIRM WITH ENG ---
~~~~~~~~~~~~~~~
"action" -> "start" // start: Leanplum SDK starts. heartbeat
"userAttributes" -> "{ // A set of key-value pairs used to describe the user.
Expand All @@ -85,7 +77,6 @@ Sent when the app starts:
~~~~~~~~~~~~~~~

Sent every time a session is renewed or has a state change:
--- Note: NEED TO CONFIRM WITH ENG ---
~~~~~~~~~~~~~~~
"action" -> "heartbeat" // heartbeat: every 15 minutes when app is in the foreground
// pauseSession: when app goes to background
Expand All @@ -94,7 +85,6 @@ Sent every time a session is renewed or has a state change:
Sent for every Message:
--- Note: NEED TO CONFIRM WITH ENG ---
~~~~~~~~~~~~~~~
"userId" -> "b13b3c239d01aa7c" // Set by Fennec, we use random uuid so users are anonymous to Leanplum.
"deviceId" -> "b13b3c239d01aa7c" // Same as above.
Expand All @@ -108,28 +98,32 @@ Notes on what data is collected
===============================
User Identifier
---------------
--- Note: NEED TO CONFIRM WITH ENG ---
Since Device ID is a random UUID, Leanplum can't map the device to any know Client ID in Fennec nor Advertising ID.

User Attributes
---------------

"default_browser": A string containing the name of the default browser if property of Mozilla or an empty string
"focus_installed": A boolean indicated that Firefox Focus is installed
"klar_installed": A boolean indicated that Firefox Klar is installed
"fennec_installed": A boolean indicated that Fennec is installed

Events
-------
Most of the Leanplum events can be mapped to a single combination of Telemetry event (Event+Method+Extra).
Some events are not collected in Mozilla Telemetry. This will be addressed separately in each campaign review.
There are three elements that are used for each event. They are: event name, value(default: 0.0), and info(default: "").
Default value for event value is 0.0. Default value for event info is empty string.

Here is the list of current Events sent, which can be found here in the code base: https://github.com/mozilla-mobile/firefox-ios/blob/master/Client/Application/LeanplumIntegration.swift#L21

^ --- Note: NEED TO CONFIRM WITH ENG WHAT THE URL SHOULD BE ---
Here is the list of current Events sent, which can be found here in the code base: https://github.com/mozilla-mobile/fenix/blob/master/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt

The first launch after install
~~~~
{
"event": "E_First_Run"
"event": "E_Opened_App_FirstRun"
}
~~~~


Whenever the App is launched.
~~~~
{
Expand All @@ -144,34 +138,23 @@ The user interacts with search url area.
}
~~~~


Save password and login from door hanger
The user opened a bookmark
~~~~
{
"event": "E_Saved_Login_And_Password"
"event": "E_Opened_Bookmark"
}
~~~~

Deep Links
----------
--- Note: NEED TO CONFIRM WITH ENG WHICH TRIGGERS HAVE BEEN ADDED ---
Deep links are actions that can point Firefox to open certain pages or load features such as `show bookmark list` or
`open Firefox Account Settings`. When users receives a Message, they can click the button(s) on it. These buttons can
trigger the following deep links:
* Link to sync signup/sign in (firefox://deep-link?url=settings/fxa)
* Link to set default browser (firefox://default_browser?uid={{User ID}})
* Link to default search engine settings (firefox://deep-link?url=settings/search)
* Link to history list (firefox://deep-link?url=/history)
* Link to general preferences (firefox://deep-link?url=settings)
* Link to open the settings page so the user can clear their private data (firefox://deep-link?url=settings/clear-private-data)

The user removed a bookmark
~~~~
{
"event": "E_Remove_Bookmark"
}
~~~~

Note these deep links can only be processed from within Firefox (i.e., if they are clicked from outside of Firefox, Firefox will open but nothing further will happen).

Messages
-----------
Messages are in-app prompts to the user from Leanplum. The user interaction of that prompt will be sent to the Leanplum backend (such as "Accept" or "Show") to track overall engagement with the Message. The Message is downloaded from Leanplum when the Leanplum SDK is initialized at App start, assuming the fulfillment criteria for the Message is met. As mentioned before, the fulfillment criteria is a set of required Events and User Attributes. The fulfillment criteria are set in the Leanplum backend.

--- Note: NEED TO CONFIRM WITH ENG/JESS WHICH MESSAGES HAVE BEEN PLANNED ---

The List of current Messages for iOS can be found here: https://wiki.mozilla.org/Leanplum_Contextual_Hints
We currently don't have any messages planned for Firefox Preview

0 comments on commit 45b096c

Please sign in to comment.