Bug 997487 - Add awesomescreen session and cancel button UITelemetry. r=liuche, f=mfinkle, a=sledru
authorMichael Comella <michael.l.comella@gmail.com>
Wed, 14 May 2014 11:29:42 -0700
changeset 200284 bd1c4f80a39c6e76f3417ff0be261f91b1627167
parent 200283 b753b027758e3b8963b07c7a55b7790a4cc14459
child 200285 b766031e174d42acde7c7c897c25ad78eb305620
push id486
push userasasaki@mozilla.com
push dateMon, 14 Jul 2014 18:39:42 +0000
treeherdermozilla-release@d33428174ff1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersliuche, sledru
bugs997487
milestone31.0a2
Bug 997487 - Add awesomescreen session and cancel button UITelemetry. r=liuche, f=mfinkle, a=sledru
mobile/android/base/BrowserApp.java
mobile/android/base/TelemetryContract.java
mobile/android/base/toolbar/BrowserToolbar.java
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -598,22 +598,16 @@ abstract public class BrowserApp extends
         });
 
         mBrowserToolbar.setOnFocusChangeListener(new View.OnFocusChangeListener() {
             @Override
             public void onFocusChange(View v, boolean hasFocus) {
                 if (isHomePagerVisible()) {
                     mHomePager.onToolbarFocusChange(hasFocus);
                 }
-
-                if (hasFocus) {
-                    Telemetry.startUISession(TelemetryContract.Session.URLBAR_FOCUSED);
-                } else {
-                    Telemetry.stopUISession(TelemetryContract.Session.URLBAR_FOCUSED);
-                }
             }
         });
 
         mBrowserToolbar.setOnStartEditingListener(new BrowserToolbar.OnStartEditingListener() {
             public void onStartEditing() {
                 // Temporarily disable doorhanger notifications.
                 mDoorHangerPopup.disable();
             }
@@ -1540,23 +1534,27 @@ abstract public class BrowserApp extends
         animator.setUseHardwareLayer(false);
 
         mBrowserToolbar.startEditing(url, animator);
 
         final String panelId = selectedTab.getMostRecentHomePanel();
         showHomePagerWithAnimator(panelId, animator);
 
         animator.start();
+        Telemetry.startUISession(TelemetryContract.Session.AWESOMESCREEN);
     }
 
     private void commitEditingMode() {
         if (!mBrowserToolbar.isEditing()) {
             return;
         }
 
+        Telemetry.stopUISession(TelemetryContract.Session.AWESOMESCREEN,
+                                TelemetryContract.Reason.COMMIT);
+
         final String url = mBrowserToolbar.commitEdit();
 
         // HACK: We don't know the url that will be loaded when hideHomePager is initially called
         // in BrowserToolbar's onStopEditing listener so on the awesomescreen, hideHomePager will
         // use the url "about:home" and return without taking any action. hideBrowserSearch is
         // then called, but since hideHomePager changes both HomePager and LayerView visibility
         // and exited without taking an action, no Views are displayed and graphical corruption is
         // visible instead.
--- a/mobile/android/base/TelemetryContract.java
+++ b/mobile/android/base/TelemetryContract.java
@@ -10,16 +10,19 @@ package org.mozilla.gecko;
  */
 public interface TelemetryContract {
 
     /**
      * Holds event names. Intended for use with
      * Telemetry.sendUIEvent() as the "action" parameter.
      */
     public interface Event {
+        // Cancel a state, action, etc.
+        public static final String CANCEL = "cancel.1";
+
         // Outcome of data policy notification: can be true or false.
         public static final String POLICY_NOTIFICATION_SUCCESS = "policynotification.success.1:";
 
         // Top site pinned.
         public static final String TOP_SITES_PIN = "pin.1";
 
         // Top site un-pinned.
         public static final String TOP_SITES_UNPIN = "unpin.1";
@@ -58,16 +61,22 @@ public interface TelemetryContract {
     /**
      * Holds event methods. Intended for use in
      * Telemetry.sendUIEvent() as the "method" parameter.
      */
     public interface Method {
         // Action triggered from a list.
         public static final String LIST = "list";
 
+        // Action triggered from the action bar (including the toolbar).
+        public static final String ACTIONBAR = "actionbar";
+
+        // Action triggered by hitting the Android back button.
+        public static final String BACK = "back";
+
         // Action triggered from a button.
         public static final String BUTTON = "button";
 
         // Action triggered from a dialog.
         public static final String DIALOG = "dialog";
 
         // Action occurred via an intent.
         public static final String INTENT = "intent";
@@ -92,32 +101,35 @@ public interface TelemetryContract {
         public static final String PAGEACTION = "pageaction";
     }
 
     /**
      * Holds session names. Intended for use with
      * Telemetry.startUISession() as the "sessionName" parameter.
      */
     public interface Session {
+        // Awesomescreen (including frecency search) is active.
+        public static final String AWESOMESCREEN = "awesomescreen.1";
+
         // Started when a user enters about:home.
         public static final String HOME = "home.1";
 
         // Started when a user enters a given home panel.
         // Session name is dynamic, encoded as "homepanel.1:<panel_id>"
         public static final String HOME_PANEL = "homepanel.1:";
 
         // Started when a Reader viewer becomes active in the foreground.
         // Note: Only used in JavaScript for now, but here for completeness.
         public static final String READER = "reader.1";
 
-        // URL bar focused.
-        public static final String URLBAR_FOCUSED = "urlbar.1";
-
         // Awesomescreen frecency search is active.
         public static final String FRECENCY = "frecency.1";
     }
 
     /**
      * Holds reasons for stopping a session. Intended for use in
      * Telemetry.stopUISession() as the "reason" parameter.
      */
-    public interface Reason {}
+    public interface Reason {
+        // Changes were committed.
+        public static final String COMMIT = "commit";
+    }
 }
--- a/mobile/android/base/toolbar/BrowserToolbar.java
+++ b/mobile/android/base/toolbar/BrowserToolbar.java
@@ -14,16 +14,18 @@ import org.json.JSONObject;
 import org.mozilla.gecko.BrowserApp;
 import org.mozilla.gecko.GeckoAppShell;
 import org.mozilla.gecko.GeckoApplication;
 import org.mozilla.gecko.GeckoProfile;
 import org.mozilla.gecko.LightweightTheme;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.Tab;
 import org.mozilla.gecko.Tabs;
+import org.mozilla.gecko.Telemetry;
+import org.mozilla.gecko.TelemetryContract;
 import org.mozilla.gecko.animation.PropertyAnimator;
 import org.mozilla.gecko.animation.PropertyAnimator.PropertyAnimationListener;
 import org.mozilla.gecko.animation.ViewHelper;
 import org.mozilla.gecko.menu.GeckoMenu;
 import org.mozilla.gecko.menu.MenuPopup;
 import org.mozilla.gecko.toolbar.ToolbarDisplayLayout.OnStopListener;
 import org.mozilla.gecko.toolbar.ToolbarDisplayLayout.OnTitleChangeListener;
 import org.mozilla.gecko.toolbar.ToolbarDisplayLayout.UpdateFlags;
@@ -368,16 +370,19 @@ public class BrowserToolbar extends Them
                 return Tabs.getInstance().getSelectedTab().showForwardHistory();
             }
         });
 
         if (editCancel != null) {
             editCancel.setOnClickListener(new OnClickListener() {
                 @Override
                 public void onClick(View v) {
+                    Telemetry.sendUIEvent(TelemetryContract.Event.CANCEL,
+                                          TelemetryContract.Method.ACTIONBAR,
+                                          Integer.toString(editCancel.getId()));
                     cancelEdit();
                 }
             });
         }
 
         if (hasSoftMenuButton) {
             menuButton.setVisibility(View.VISIBLE);
             menuIcon.setVisibility(View.VISIBLE);
@@ -396,16 +401,18 @@ public class BrowserToolbar extends Them
     }
 
     public void refresh() {
         urlDisplayLayout.dismissSiteIdentityPopup();
     }
 
     public boolean onBackPressed() {
         if (isEditing()) {
+            Telemetry.sendUIEvent(TelemetryContract.Event.CANCEL,
+                                  TelemetryContract.Method.BACK);
             cancelEdit();
             return true;
         }
 
         return urlDisplayLayout.dismissSiteIdentityPopup();
     }
 
     public boolean onKey(int keyCode, KeyEvent event) {
@@ -1069,16 +1076,17 @@ public class BrowserToolbar extends Them
     }
 
     /**
      * Exits edit mode without updating the toolbar title.
      *
      * @return the url that was entered
      */
     public String cancelEdit() {
+        Telemetry.stopUISession(TelemetryContract.Session.AWESOMESCREEN);
         return stopEditing();
     }
 
     /**
      * Exits edit mode, updating the toolbar title with the url that was just entered.
      *
      * @return the url that was entered
      */