Bug 1029834 - Make contextmenu/menu telemetry more consistent. r=mfinkle
authorChenxia Liu <liuche@mozilla.com>
Wed, 25 Jun 2014 14:10:49 -0700
changeset 190719 9ef3bd020eede2e5eabc78e5f61a3b18b7e43c74
parent 190718 d41a6d09ccd63c52e1cdef5fec50dcd181fe2c18
child 190720 6929caed9dc4a2e67ad97ec0cf24a3b58d5cc919
push id7462
push usercliu@mozilla.com
push dateWed, 25 Jun 2014 21:15:51 +0000
treeherderfx-team@9ef3bd020eed [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs1029834
milestone33.0a1
Bug 1029834 - Make contextmenu/menu telemetry more consistent. r=mfinkle
mobile/android/base/BrowserApp.java
mobile/android/chrome/content/SelectionHandler.js
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -753,43 +753,53 @@ public class BrowserApp extends GeckoApp
     @Override
     public boolean onContextItemSelected(MenuItem item) {
         final int itemId = item.getItemId();
         if (itemId == R.id.pasteandgo) {
             String text = Clipboard.getText();
             if (!TextUtils.isEmpty(text)) {
                 Tabs.getInstance().loadUrl(text);
                 Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, TelemetryContract.Method.CONTEXT_MENU);
+                Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.CONTEXT_MENU, "pasteandgo");
             }
             return true;
         }
 
         if (itemId == R.id.site_settings) {
+            // This can be selected from either the browser menu or the contextmenu, depending on the size and version (v11+) of the phone.
             GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Permissions:Get", null));
+            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
+                Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.CONTEXT_MENU, "site_settings");
+            }
             return true;
         }
 
         if (itemId == R.id.paste) {
             String text = Clipboard.getText();
             if (!TextUtils.isEmpty(text)) {
                 enterEditingMode(text);
+                Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.CONTEXT_MENU, "paste");
             }
             return true;
         }
 
         if (itemId == R.id.subscribe) {
+            // This can be selected from either the browser menu or the contextmenu, depending on the size and version (v11+) of the phone.
             Tab tab = Tabs.getInstance().getSelectedTab();
             if (tab != null && tab.hasFeeds()) {
                 JSONObject args = new JSONObject();
                 try {
                     args.put("tabId", tab.getId());
                 } catch (JSONException e) {
                     Log.e(LOGTAG, "error building json arguments");
                 }
                 GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Feeds:Subscribe", args.toString()));
+                if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
+                    Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.CONTEXT_MENU, "subscribe");
+                }
             }
             return true;
         }
 
         if (itemId == R.id.add_search_engine) {
             // This can be selected from either the browser menu or the contextmenu, depending on the size and version (v11+) of the phone.
             Tab tab = Tabs.getInstance().getSelectedTab();
             if (tab != null && tab.hasOpenSearch()) {
@@ -810,16 +820,17 @@ public class BrowserApp extends GeckoApp
         }
 
         if (itemId == R.id.copyurl) {
             Tab tab = Tabs.getInstance().getSelectedTab();
             if (tab != null) {
                 String url = tab.getURL();
                 if (url != null) {
                     Clipboard.setText(url);
+                    Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.CONTEXT_MENU, "copyurl");
                 }
             }
             return true;
         }
 
         if (itemId == R.id.add_to_launcher) {
             Tab tab = Tabs.getInstance().getSelectedTab();
             if (tab == null) {
--- a/mobile/android/chrome/content/SelectionHandler.js
+++ b/mobile/android/chrome/content/SelectionHandler.js
@@ -513,17 +513,18 @@ var SelectionHandler = {
    * Actionbar methods.
    */
   actions: {
     SELECT_ALL: {
       label: Strings.browser.GetStringFromName("contextmenu.selectAll"),
       id: "selectall_action",
       icon: "drawable://ab_select_all",
       action: function(aElement) {
-        SelectionHandler.startSelection(aElement)
+        SelectionHandler.startSelection(aElement);
+        UITelemetry.addEvent("action.1", "actionbar", null, "select_all");
       },
       order: 5,
       selector: {
         matches: function(aElement) {
           return (aElement.textLength != 0);
         }
       }
     },
@@ -536,32 +537,34 @@ var SelectionHandler = {
         let start = aElement.selectionStart;
         let end   = aElement.selectionEnd;
 
         SelectionHandler.copySelection();
         aElement.value = aElement.value.substring(0, start) + aElement.value.substring(end)
 
         // copySelection closes the selection. Show a caret where we just cut the text.
         SelectionHandler.attachCaret(aElement);
+        UITelemetry.addEvent("action.1", "actionbar", null, "cut");
       },
       order: 4,
       selector: {
         matches: function(aElement) {
           return SelectionHandler.isElementEditableText(aElement) ?
             SelectionHandler.isSelectionActive() : false;
         }
       }
     },
 
     COPY: {
       label: Strings.browser.GetStringFromName("contextmenu.copy"),
       id: "copy_action",
       icon: "drawable://ab_copy",
       action: function() {
         SelectionHandler.copySelection();
+        UITelemetry.addEvent("action.1", "actionbar", null, "copy");
       },
       order: 3,
       selector: {
         matches: function(aElement) {
           // Don't include "copy" for password fields.
           // mozIsTextField(true) tests for only non-password fields.
           if (aElement instanceof Ci.nsIDOMHTMLInputElement && !aElement.mozIsTextField(true)) {
             return false;
@@ -576,16 +579,17 @@ var SelectionHandler = {
       id: "paste_action",
       icon: "drawable://ab_paste",
       action: function(aElement) {
         if (aElement && (aElement instanceof Ci.nsIDOMNSEditableElement)) {
           let target = aElement.QueryInterface(Ci.nsIDOMNSEditableElement);
           target.editor.paste(Ci.nsIClipboard.kGlobalClipboard);
           target.focus();
           SelectionHandler._closeSelection();
+          UITelemetry.addEvent("action.1", "actionbar", null, "paste");
         }
       },
       order: 2,
       selector: {
         matches: function(aElement) {
           if (SelectionHandler.isElementEditableText(aElement)) {
             let flavors = ["text/unicode"];
             return Services.clipboard.hasDataMatchingFlavors(flavors, flavors.length, Ci.nsIClipboard.kGlobalClipboard);
@@ -596,16 +600,17 @@ var SelectionHandler = {
     },
 
     SHARE: {
       label: Strings.browser.GetStringFromName("contextmenu.share"),
       id: "share_action",
       icon: "drawable://ic_menu_share",
       action: function() {
         SelectionHandler.shareSelection();
+        UITelemetry.addEvent("action.1", "actionbar", null, "share");
       },
       selector: {
         matches: function() {
           return SelectionHandler.isSelectionActive();
         }
       }
     },
 
@@ -613,31 +618,33 @@ var SelectionHandler = {
       label: function() {
         return Strings.browser.formatStringFromName("contextmenu.search", [Services.search.defaultEngine.name], 1);
       },
       id: "search_action",
       icon: "drawable://ab_search",
       action: function() {
         SelectionHandler.searchSelection();
         SelectionHandler._closeSelection();
+        UITelemetry.addEvent("action.1", "actionbar", null, "search");
       },
       order: 1,
       selector: {
         matches: function() {
           return SelectionHandler.isSelectionActive();
         }
       }
     },
 
     CALL: {
       label: Strings.browser.GetStringFromName("contextmenu.call"),
       id: "call_action",
       icon: "drawable://phone",
       action: function() {
         SelectionHandler.callSelection();
+        UITelemetry.addEvent("action.1", "actionbar", null, "call");
       },
       order: 1,
       selector: {
         matches: function () {
           return SelectionHandler._getSelectedPhoneNumber() != null;
         }
       }
     }