Bug 1368629 - Add histogram for Leanplum usage. r?sebastian draft
authorNevin Chen <cnevinchen@gmail.com>
Wed, 31 May 2017 01:40:21 +0800
changeset 606571 8bd44d3bca24992b2445e981b51ca3f53261dbe4
parent 605863 a418121d46250f91728b86d9eea331029c264c30
child 636794 d38a765833c31a23e5dca09ce3faa27539f5c7a8
push id67728
push userbmo:cnevinchen@gmail.com
push dateTue, 11 Jul 2017 03:49:24 +0000
reviewerssebastian
bugs1368629
milestone56.0a1
Bug 1368629 - Add histogram for Leanplum usage. r?sebastian MozReview-Commit-ID: CqoI2a06vIE
mobile/android/base/java/org/mozilla/gecko/mma/MmaDelegate.java
mobile/android/base/java/org/mozilla/gecko/mma/MmaLeanplumImp.java
toolkit/components/telemetry/Histograms.json
--- a/mobile/android/base/java/org/mozilla/gecko/mma/MmaDelegate.java
+++ b/mobile/android/base/java/org/mozilla/gecko/mma/MmaDelegate.java
@@ -13,16 +13,17 @@ import android.content.pm.PackageManager
 import android.content.pm.ResolveInfo;
 import android.net.Uri;
 import android.text.TextUtils;
 import android.util.Log;
 
 import org.mozilla.gecko.Experiments;
 import org.mozilla.gecko.MmaConstants;
 import org.mozilla.gecko.PrefsHelper;
+import org.mozilla.gecko.Telemetry;
 import org.mozilla.gecko.preferences.GeckoPreferences;
 import org.mozilla.gecko.switchboard.SwitchBoard;
 
 import java.lang.ref.WeakReference;
 
 
 public class MmaDelegate {
 
@@ -34,16 +35,17 @@ public class MmaDelegate {
     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 NEW_TAB = "E_Opened_New_Tab";
 
 
     private static final String TAG = "MmaDelegate";
+    private static final String HISTOGRAM_FENNEC_MMA_ENABLED = "FENNEC_MMA_ENABLED";
     private static final String KEY_PREF_BOOLEAN_MMA_ENABLED = "mma.enabled";
     private static final String[] PREFS = { KEY_PREF_BOOLEAN_MMA_ENABLED };
 
 
     private static boolean isGeckoPrefOn = false;
     private static MmaInterface mmaHelper = MmaConstants.getMma();
     private static WeakReference<Context> applicationContext;
 
@@ -55,16 +57,20 @@ public class MmaDelegate {
     public static void stop() {
         mmaHelper.stop();
     }
 
     private static void setupPrefHandler(final Activity activity) {
         PrefsHelper.PrefHandler handler = new PrefsHelper.PrefHandlerBase() {
             @Override
             public void prefValue(String pref, boolean value) {
+
+                final boolean healthReport = GeckoPreferences.getBooleanPref(activity, GeckoPreferences.PREFS_HEALTHREPORT_UPLOAD_ENABLED, true);
+                Telemetry.addToHistogram(HISTOGRAM_FENNEC_MMA_ENABLED, value && healthReport ? 1 : 0);
+
                 if (pref.equals(KEY_PREF_BOOLEAN_MMA_ENABLED)) {
                     Log.d(TAG, "prefValue() called with: pref = [" + pref + "], value = [" + value + "]");
                     if (value) {
                         mmaHelper.init(activity);
                         if (!isDefaultBrowser(activity)) {
                             mmaHelper.event(MmaDelegate.LAUNCH_BUT_NOT_DEFAULT_BROWSER);
                         }
                         isGeckoPrefOn = true;
--- a/mobile/android/base/java/org/mozilla/gecko/mma/MmaLeanplumImp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/mma/MmaLeanplumImp.java
@@ -11,16 +11,17 @@ import android.content.Context;
 import android.content.SharedPreferences;
 import android.content.pm.PackageManager;
 
 import com.leanplum.Leanplum;
 import com.leanplum.LeanplumActivityHelper;
 
 import org.mozilla.gecko.AppConstants;
 import org.mozilla.gecko.MmaConstants;
+import org.mozilla.gecko.Telemetry;
 
 import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
 
 
 public class MmaLeanplumImp implements MmaInterface {
 
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -11920,16 +11920,24 @@
     "record_in_processes": ["main", "content"],
     "expires_in_version": "60",
     "alert_emails": ["mobile-frontend@mozilla.com"],
     "kind": "enumerated",
     "n_values": 10,
     "description": "How often users load saved items when online/offline (0=RL online, 1=RL offline, 2=BM online, 3=BM offline)",
     "bug_numbers": [1243387]
   },
+  "FENNEC_MMA_ENABLED": {
+    "record_in_processes": ["main", "content"],
+    "expires_in_version": "60",
+    "alert_emails": ["mobile-frontend@mozilla.com"],
+    "kind": "boolean",
+    "description": "How many users actually have Leanplum enabled",
+    "bug_numbers": [1368629]
+  },
   "PERMISSIONS_SQL_CORRUPTED": {
     "record_in_processes": ["main", "content"],
     "expires_in_version": "never",
     "kind": "count",
     "description": "Record the permissions.sqlite init failure"
   },
   "DEFECTIVE_PERMISSIONS_SQL_REMOVED": {
     "record_in_processes": ["main", "content"],