Bug 997487 - Add awesomescreen session and cancel button UITelemetry. r=liuche f=mfinkle
authorMichael Comella <michael.l.comella@gmail.com>
Wed, 14 May 2014 11:29:42 -0700
changeset 183114 ccabfe66be68bc7ac43075c1440ff122a1543523
parent 183113 39e1fdf059c5de4a8a4e3e43e37bf83862544360
child 183115 f20466641641cd77d850580b860ff85921801082
push id6798
push usermichael.l.comella@gmail.com
push dateWed, 14 May 2014 18:30:18 +0000
treeherderfx-team@ccabfe66be68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersliuche
bugs997487
milestone32.0a1
Bug 997487 - Add awesomescreen session and cancel button UITelemetry. r=liuche f=mfinkle
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
@@ -653,22 +653,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();
             }
@@ -1605,23 +1599,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
@@ -17,16 +17,19 @@ public interface TelemetryContract {
      * Telemetry.sendUIEvent() as the "action" parameter.
      *
      * Please keep this list sorted.
      */
     public interface Event {
         // Generic action, usually for tracking menu and toolbar actions.
         public static final String ACTION = "action.1";
 
+        // Cancel a state, action, etc.
+        public static final String CANCEL = "cancel.1";
+
         // Launching (opening) an external application.
         // Note: Only used in JavaScript for now, but here for completeness.
         public static final String LAUNCH = "launch.1";
 
         // Loading a URL.
         public static final String LOAD_URL = "loadurl.1";
 
         public static final String LOCALE_BROWSER_RESET = "locale.browser.reset.1";
@@ -66,16 +69,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";
@@ -100,35 +109,38 @@ 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";
 
         // Started the very first time we believe the application has been launched.
         public static final String FIRSTRUN = "firstrun.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
@@ -15,16 +15,18 @@ import org.mozilla.gecko.BrowserApp;
 import org.mozilla.gecko.EventDispatcher;
 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;
@@ -370,16 +372,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);
@@ -398,16 +403,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) {
@@ -1070,16 +1077,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
      */