Bug 1423045 - Drop an event when User changes default browser to Firefox; r?sdaswani
This will help us figure which message creates higher conversions.
MozReview-Commit-ID: 4l41iWgTV8H
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -1367,16 +1367,18 @@ public class BrowserApp extends GeckoApp
final SharedPreferences sharedPrefs = GeckoSharedPrefs.forProfileName(BrowserApp.this, profile.getName());
FileCleanupController.startIfReady(BrowserApp.this, sharedPrefs, profile.getDir().getAbsolutePath());
}
});
for (final BrowserAppDelegate delegate : delegates) {
delegate.onStart(this);
}
+
+ MmaDelegate.informDefaultBrowserStatus();
}
@Override
public void onStop() {
super.onStop();
if (mIsAbortingAppLaunch) {
return;
}
--- a/mobile/android/base/java/org/mozilla/gecko/mma/MmaDelegate.java
+++ b/mobile/android/base/java/org/mozilla/gecko/mma/MmaDelegate.java
@@ -44,16 +44,17 @@ public class MmaDelegate {
public static final String OPENED_BOOKMARK = "E_Opened_Bookmark";
public static final String INTERACT_WITH_SEARCH_URL_AREA = "E_Interact_With_Search_URL_Area";
public static final String SCREENSHOT = "E_Screenshot";
public static final String SAVED_LOGIN_AND_PASSWORD = "E_Saved_Login_And_Password";
public static final String LAUNCH_BUT_NOT_DEFAULT_BROWSER = "E_Launch_But_Not_Default_Browser";
public static final String LAUNCH_BROWSER = "E_Launch_Browser";
public static final String NEW_TAB = "E_Opened_New_Tab";
public static final String DISMISS_ONBOARDING = "E_Dismiss_Onboarding";
+ public static final String CHANGED_DEFAULT_TO_FENNEC = "E_Changed_Default_To_Fennec";
public static final String USER_ATT_FOCUS_INSTALLED = "Focus Installed";
public static final String USER_ATT_KLAR_INSTALLED = "Klar Installed";
public static final String USER_ATT_POCKET_INSTALLED = "Pocket Installed";
public static final String USER_ATT_DEFAULT_BROWSER = "Default Browser";
public static final String USER_ATT_SIGNED_IN = "Signed In Sync";
public static final String USER_ATT_POCKET_TOP_SITES = "Pocket in Top Sites";
@@ -64,30 +65,32 @@ public class MmaDelegate {
private static final String TAG = "MmaDelegate";
public static final String KEY_ANDROID_PREF_STRING_LEANPLUM_DEVICE_ID = "android.not_a_preference.leanplum.device_id";
private static final String DEBUG_LEANPLUM_DEVICE_ID = "8effda84-99df-11e7-abc4-cec278b6b50a";
private static final MmaInterface mmaHelper = MmaConstants.getMma();
private static WeakReference<Context> applicationContext;
+ private static boolean defaultBrowserStatus;
public static void init(Activity activity) {
applicationContext = new WeakReference<>(activity.getApplicationContext());
+ defaultBrowserStatus = isDefaultBrowser(activity);
// Since user attributes are gathered in Fennec, not in MMA implementation,
// we gather the information here then pass to mmaHelper.init()
// Note that generateUserAttribute always return a non null HashMap.
final Map<String, Object> attributes = gatherUserAttributes(activity);
final String deviceId = getDeviceId(activity);
mmaHelper.setDeviceId(deviceId);
PrefsHelper.setPref(GeckoPreferences.PREFS_MMA_DEVICE_ID, deviceId);
// above two config setup required to be invoked before mmaHelper.init.
mmaHelper.init(activity, attributes);
- if (!isDefaultBrowser(activity)) {
+ if (!defaultBrowserStatus) {
mmaHelper.event(MmaDelegate.LAUNCH_BUT_NOT_DEFAULT_BROWSER);
}
mmaHelper.event(MmaDelegate.LAUNCH_BROWSER);
}
public static void stop() {
mmaHelper.stop();
@@ -97,23 +100,33 @@ public class MmaDelegate {
@NonNull
private static Map<String, Object> gatherUserAttributes(final Context context) {
final Map<String, Object> attributes = new HashMap<>();
attributes.put(USER_ATT_FOCUS_INSTALLED, ContextUtils.isPackageInstalled(context, PACKAGE_NAME_FOCUS));
attributes.put(USER_ATT_KLAR_INSTALLED, ContextUtils.isPackageInstalled(context, PACKAGE_NAME_KLAR));
attributes.put(USER_ATT_POCKET_INSTALLED, ContextUtils.isPackageInstalled(context, PACKAGE_NAME_POCKET));
- attributes.put(USER_ATT_DEFAULT_BROWSER, isDefaultBrowser(context));
+ attributes.put(USER_ATT_DEFAULT_BROWSER, defaultBrowserStatus);
attributes.put(USER_ATT_SIGNED_IN, FirefoxAccounts.firefoxAccountsExist(context));
attributes.put(USER_ATT_POCKET_TOP_SITES, ActivityStreamConfiguration.isPocketRecommendingTopSites(context));
return attributes;
}
+ public static void informDefaultBrowserStatus() {
+ // Method may be called before class was initialized
+ if (applicationContext == null || applicationContext.get() == null) return;
+
+ if (!defaultBrowserStatus && isDefaultBrowser(applicationContext.get())) {
+ defaultBrowserStatus = !defaultBrowserStatus;
+ track(CHANGED_DEFAULT_TO_FENNEC);
+ }
+ }
+
public static void track(String event) {
if (applicationContext != null && isMmaEnabled(applicationContext.get())) {
mmaHelper.event(event);
}
}
public static void track(String event, long value) {
--- a/mobile/android/docs/mma.rst
+++ b/mobile/android/docs/mma.rst
@@ -150,16 +150,20 @@ List of current Events related data that
* General app start event
{
"event" : "E_Launch_Browser"
}
* The user just dismissed on-boarding
{
"event" : "E_Dismiss_Onboarding"
}
+* User set Fennec as default browser and resumed the app
+{
+ "event" : "E_Changed_Default_To_Fennec"
+}
Deep Links:
Deep links are actions that can point Fennec to open certain pages or load features such as `show bookmark list` or
`open a SUMO page`. When users see a prompt Leanplum message, they can click the button(s) on it. These buttons can
trigger the following deep links
* Link to Set Default Browser settings (firefox://default_browser)
* Link to specific Add-on page (http://link_to_the_add_on_page)
* Link to sync signup/sign in (firefox://sign_up)