Bug 1210283 - Add more UI Telemetry probes for managing Home Panels. r=liuche, a=sylvestre
authorMark Finkle <mfinkle@mozilla.com>
Sat, 03 Oct 2015 00:37:48 -0400
changeset 296350 b8cdb043ac3e8c816220ecad911a434e51411c8c
parent 296349 4e6a6482a65a91ca18974aa56e57da233a47ed22
child 296351 62ffae819bfb4244b776bcb3a58aaae6d30c5810
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersliuche, sylvestre
bugs1210283
milestone43.0a2
Bug 1210283 - Add more UI Telemetry probes for managing Home Panels. r=liuche, a=sylvestre
mobile/android/base/TelemetryContract.java
mobile/android/base/preferences/PanelsPreferenceCategory.java
--- a/mobile/android/base/TelemetryContract.java
+++ b/mobile/android/base/TelemetryContract.java
@@ -44,18 +44,30 @@ public interface TelemetryContract {
 
         // Loading a URL.
         LOAD_URL("loadurl.1"),
 
         LOCALE_BROWSER_RESET("locale.browser.reset.1"),
         LOCALE_BROWSER_SELECTED("locale.browser.selected.1"),
         LOCALE_BROWSER_UNSELECTED("locale.browser.unselected.1"),
 
-        // Set default panel.
-        PANEL_SET_DEFAULT("setdefault.1"),
+        // Hide a built-in home panel.
+        PANEL_HIDE("panel.hide.1"),
+
+        // Move a home panel up or down.
+        PANEL_MOVE("panel.move.1"),
+
+        // Remove a custom home panel.
+        PANEL_REMOVE("panel.remove.1"),
+
+        // Set default home panel.
+        PANEL_SET_DEFAULT("panel.setdefault.1"),
+
+        // Show a hidden built-in home panel.
+        PANEL_SHOW("panel.show.1"),
 
         // Pinning an item.
         PIN("pin.1"),
 
         // Outcome of data policy notification: can be true or false.
         POLICY_NOTIFICATION_SUCCESS("policynotification.success.1"),
 
         // Sanitizing private data.
--- a/mobile/android/base/preferences/PanelsPreferenceCategory.java
+++ b/mobile/android/base/preferences/PanelsPreferenceCategory.java
@@ -160,65 +160,81 @@ public class PanelsPreferenceCategory ex
         final String defaultPanelId = mConfigEditor.getDefaultPanelId();
         if (defaultPanelId != null && defaultPanelId.equals(id)) {
             return;
         }
 
         mConfigEditor.setDefault(id);
         mConfigEditor.apply();
 
-        Telemetry.sendUIEvent(TelemetryContract.Event.PANEL_SET_DEFAULT, Method.NONE, id);
+        Telemetry.sendUIEvent(TelemetryContract.Event.PANEL_SET_DEFAULT, Method.DIALOG, id);
     }
 
     @Override
     protected void onPrepareForRemoval() {
         if (mLoadTask != null) {
             mLoadTask.cancel();
         }
     }
 
     @Override
     public void uninstall(CustomListPreference pref) {
-        mConfigEditor.uninstall(pref.getKey());
+        final String id = pref.getKey();
+        mConfigEditor.uninstall(id);
         mConfigEditor.apply();
 
+        Telemetry.sendUIEvent(TelemetryContract.Event.PANEL_REMOVE, Method.DIALOG, id);
+
         super.uninstall(pref);
     }
 
     public void moveUp(PanelsPreference pref) {
         final int panelIndex = pref.getIndex();
         if (panelIndex > 0) {
             final String panelKey = pref.getKey();
             mConfigEditor.moveTo(panelKey, panelIndex - 1);
             final State state = mConfigEditor.apply();
+
+            Telemetry.sendUIEvent(TelemetryContract.Event.PANEL_MOVE, Method.DIALOG, panelKey);
+
             refresh(state, panelKey);
         }
     }
 
     public void moveDown(PanelsPreference pref) {
         final int panelIndex = pref.getIndex();
         if (panelIndex < getPreferenceCount() - 1) {
             final String panelKey = pref.getKey();
             mConfigEditor.moveTo(panelKey, panelIndex + 1);
             final State state = mConfigEditor.apply();
+
+            Telemetry.sendUIEvent(TelemetryContract.Event.PANEL_MOVE, Method.DIALOG, panelKey);
+
             refresh(state, panelKey);
         }
     }
 
     /**
      * Update the hide/show state of the preference and save the HomeConfig
      * changes.
      *
      * @param pref Preference to update
      * @param toHide New hidden state of the preference
      */
     protected void setHidden(PanelsPreference pref, boolean toHide) {
-        mConfigEditor.setDisabled(pref.getKey(), toHide);
+        final String id = pref.getKey();
+        mConfigEditor.setDisabled(id, toHide);
         mConfigEditor.apply();
 
+        if (toHide) {
+            Telemetry.sendUIEvent(TelemetryContract.Event.PANEL_HIDE, Method.DIALOG, id);
+        } else {
+            Telemetry.sendUIEvent(TelemetryContract.Event.PANEL_SHOW, Method.DIALOG, id);
+        }
+
         pref.setHidden(toHide);
         setDefaultFromConfig();
     }
 
     /**
      * When the default panel is removed or disabled, find an enabled panel
      * if possible and set it as mDefaultReference.
      */