Bug 1004889 - Add UI telemetry for the main menu r=rnewman
authorMark Finkle <mfinkle@mozilla.com>
Fri, 02 May 2014 11:00:19 -0400
changeset 181783 0610c2dcc6f5c9dec754b158b8086567770e5087
parent 181782 e3c1fffb0145233bde8fad42deef96dc13db632b
child 181784 34516556f823394bb0822fa093c1bf3d62c85b63
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewersrnewman
bugs1004889
milestone32.0a1
Bug 1004889 - Add UI telemetry for the main menu r=rnewman
mobile/android/base/BrowserApp.java
mobile/android/base/TelemetryContract.java
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -2342,16 +2342,20 @@ abstract public class BrowserApp extends
 
     @Override
     public boolean onOptionsItemSelected(MenuItem item) {
         Tab tab = null;
         Intent intent = null;
 
         final int itemId = item.getItemId();
 
+        // Track the menu action. We don't know much about the context, but we can use this to determine
+        // the frequency of use for various actions.
+        Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.MENU, getResources().getResourceEntryName(itemId));
+
         if (itemId == R.id.bookmark) {
             tab = Tabs.getInstance().getSelectedTab();
             if (tab != null) {
                 if (item.isChecked()) {
                     tab.removeBookmark();
                     Toast.makeText(this, R.string.bookmark_removed, Toast.LENGTH_SHORT).show();
                     item.setIcon(R.drawable.ic_menu_bookmark_add);
                 } else {
--- a/mobile/android/base/TelemetryContract.java
+++ b/mobile/android/base/TelemetryContract.java
@@ -41,16 +41,19 @@ public interface TelemetryContract {
         public static final String SAVE = "save.1";
 
         // Stop holding a resource (reader, bookmark, etc) for viewing later.
         // Note: Only used in JavaScript for now, but here for completeness.
         public static final String UNSAVE = "unsave.1";
 
         // Loading a URL.
         public static final String LOAD_URL = "loadurl.1";
+
+        // Generic action, usually for tracking menu and toolbar actions.
+        public static final String ACTION = "action.1";
     }
 
     /**
      * Holds event methods. Intended for use in
      * Telemetry.sendUIEvent() as the "method" parameter.
      */
     public interface Method {
         // Action triggered from a list.
@@ -60,16 +63,19 @@ public interface TelemetryContract {
         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";
 
+        // Action occurred via the main menu.
+        public static final String MENU = "menu";
+
         // Action occurred via a context menu.
         public static final String CONTEXT_MENU = "contextmenu";
 
         // Action triggered from a view grid item, like a thumbnail.
         public static final String GRID_ITEM = "griditem";
 
         // Action triggered from a view list item, like a row of a list.
         public static final String LIST_ITEM = "listitem";