Bug 1368629 - Add histogram for Leanplum usage. r?sebastian draft
authorNevin Chen <cnevinchen@gmail.com>
Wed, 31 May 2017 01:40:21 +0800
changeset 586539 e9944334a52c9d360ac93ce9372d6cf57e4905cc
parent 586519 e15fb840661215dc3928c3bf1fea0ca0379511f9
child 631027 2a02e2219a68e3962d6c48871e80ea6c758b73f0
push id61448
push userbmo:cnevinchen@gmail.com
push dateTue, 30 May 2017 17:41:14 +0000
reviewerssebastian
bugs1368629
milestone55.0a1
Bug 1368629 - Add histogram for Leanplum usage. r?sebastian MozReview-Commit-ID: CqoI2a06vIE
mobile/android/base/java/org/mozilla/gecko/mma/MmaLeanplumImp.java
toolkit/components/telemetry/Histograms.json
--- a/mobile/android/base/java/org/mozilla/gecko/mma/MmaLeanplumImp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/mma/MmaLeanplumImp.java
@@ -10,22 +10,26 @@ import android.app.Activity;
 import android.content.Context;
 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;
 
 
 public class MmaLeanplumImp implements MmaInterface {
+
+    private static final String HISTOGRAM_FENNEC_LEANPLUM_ENABLE = "FENNEC_LEANPLUM_ENABLE";
+
     @Override
     public void init(final Activity activity) {
         if (activity == null) {
             return;
         }
         Leanplum.setApplicationContext(activity.getApplicationContext());
 
         LeanplumActivityHelper.enableLifecycleCallbacks(activity.getApplication());
@@ -54,16 +58,17 @@ public class MmaLeanplumImp implements M
         //
         // I put it under runOnUiThread because in current Leanplum's SDK design, this should be run in main thread.
         activity.runOnUiThread(new Runnable() {
             @Override
             public void run() {
                 LeanplumActivityHelper.onResume(activity);
             }
         });
+        Telemetry.addToHistogram(HISTOGRAM_FENNEC_LEANPLUM_ENABLE, 1);
     }
 
     @Override
     public void start(Context context) {
 
     }
 
     @Override
@@ -76,16 +81,17 @@ public class MmaLeanplumImp implements M
     public void track(String leanplumEvent, double value) {
         Leanplum.track(leanplumEvent, value);
 
     }
 
     @Override
     public void stop() {
         Leanplum.stop();
+        Telemetry.addToHistogram(HISTOGRAM_FENNEC_LEANPLUM_ENABLE, 0);
     }
 
     private static boolean isPackageInstalled(final Context context, String packageName) {
         try {
             PackageManager pm = context.getPackageManager();
             pm.getPackageInfo(packageName, 0);
             return true;
         } catch (PackageManager.NameNotFoundException e) {
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -11727,16 +11727,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_LEANPLUM_ENABLE": {
+    "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"],