Bug 1535937 - Add custom telemetry for FxA toolbar menu r=janerik
authorVijay Budhram <vbudhram@mozilla.com>
Tue, 09 Apr 2019 13:30:59 +0000
changeset 468559 a16ab9d38fe748d125dad628afd99d442185f9e5
parent 468558 18a310712e500571d2080ad0c175427122d7423e
child 468560 edb31d22aafaf64e640079a4ad85f190f6e88371
push id35843
push usernbeleuzu@mozilla.com
push dateTue, 09 Apr 2019 22:08:13 +0000
treeherdermozilla-central@a31032a16330 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjanerik
bugs1535937
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1535937 - Add custom telemetry for FxA toolbar menu r=janerik Differential Revision: https://phabricator.services.mozilla.com/D25225
browser/base/content/browser-sync.js
browser/base/content/browser.js
browser/components/customizableui/content/panelUI.inc.xul
toolkit/components/telemetry/Events.yaml
--- a/browser/base/content/browser-sync.js
+++ b/browser/base/content/browser-sync.js
@@ -291,16 +291,17 @@ var gSync = {
     }
 
     this.enableSendTabIfValidTab();
 
     const anchor = document.getElementById("fxa-toolbar-menu-button");
     if (anchor.getAttribute("open") == "true") {
       PanelUI.hide();
     } else {
+      this.emitFxaToolbarTelemetry("toolbar_icon");
       PanelUI.showSubView(viewId, anchor, aEvent);
     }
   },
 
   updateFxAToolbarPanel(state = {}) {
     if (!gFxaToolbarEnabled) {
       return;
     }
@@ -354,16 +355,28 @@ var gSync = {
 
     if (canSendAllURIs) {
       document.getElementById("PanelUI-fxa-menu-sendtab-button").removeAttribute("disabled");
     } else {
       document.getElementById("PanelUI-fxa-menu-sendtab-button").setAttribute("disabled", true);
     }
   },
 
+  emitFxaToolbarTelemetry(type) {
+    if (!gFxaToolbarEnabled) {
+      return;
+    }
+    if (UIState.isReady()) {
+      const state = UIState.get();
+      const hasAvatar = state.avatarURL && !state.avatarURL.includes(FXA_NO_AVATAR_ZEROS);
+      let extraOptions = {"fxa_status": state.status, "fxa_avatar": hasAvatar ? "true" : "false"};
+      Services.telemetry.recordEvent("fxa_avatar_menu", "click", type, null, extraOptions);
+    }
+  },
+
   updatePanelPopup(state) {
     let defaultLabel = this.appMenuStatus.getAttribute("defaultlabel");
     // The localization string is for the signed in text, but it's the default text as well
     let defaultTooltiptext = this.appMenuStatus.getAttribute("signedinTooltiptext");
 
     const status = state.status;
     // Reset the status bar to its original state.
     this.appMenuLabel.setAttribute("label", defaultLabel);
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -479,16 +479,19 @@ function showFxaToolbarMenu(enable) {
     fxaPanelEl.addEventListener("ViewShowing", gSync.updateSendToDeviceTitle);
 
     mainWindowEl.setAttribute("fxastatus", "not_configured");
     // We have to manually update the sync state UI when toggling the FxA toolbar
     // because it could show an invalid icon if the user is logged in and no sync
     // event was performed yet.
     gSync.maybeUpdateUIState();
 
+    // Enabled FxA toolbar telemetry
+    Services.telemetry.setEventRecordingEnabled("fxa_avatar_menu", true);
+
     // We set an attribute here so that we can toggle the custom
     // badge depending on whether the FxA menu was ever accessed.
     if (!gFxaToolbarAccessed) {
       mainWindowEl.setAttribute("fxa_avatar_badged", "badged");
     } else {
       mainWindowEl.removeAttribute("fxa_avatar_badged");
     }
   } else {
--- a/browser/components/customizableui/content/panelUI.inc.xul
+++ b/browser/components/customizableui/content/panelUI.inc.xul
@@ -696,58 +696,68 @@
     </panelview>
 
     <panelview id="PanelUI-fxa" class="PanelUI-subView" descriptionheightworkaround="true">
       <vbox class="panel-subview-body">
         <vbox id="PanelUI-fxa-signin">
           <image class="fxaChooseWhatToSyncDevices"/>
           <label class="PanelUI-fxa-signin-instruction-callout">&fxa.signin.callout.label;</label>
           <label class="PanelUI-fxa-signin-instruction-label">&fxa.signin.description.label;</label>
-          <toolbarbutton class="PanelUI-fxa-signin-button" label="&fxa.signin.button.label;" oncommand="gSync.openFxAEmailFirstPage('fxa_discoverability_native');"/>
+          <toolbarbutton class="PanelUI-fxa-signin-button"
+                         label="&fxa.signin.button.label;"
+                         oncommand="gSync.openFxAEmailFirstPage('fxa_discoverability_native'); gSync.emitFxaToolbarTelemetry('login');"/>
         </vbox>
         <vbox id="PanelUI-fxa-unverified" class="PanelUI-fxa-unverified-instruction-box">
           <image class="fxaGraphicMail"/>
           <label class="PanelUI-fxa-signin-instruction-callout">&fxa.unverified.callout.label;</label>
           <label class="PanelUI-fxa-signin-instruction-label">&fxa.unverified.description.label;</label>
-          <toolbarbutton class="PanelUI-fxa-signin-button" label="&fxa.unverified.button.label;" oncommand="gSync.openPrefs('fxa_discoverability_native');"/>
+          <toolbarbutton class="PanelUI-fxa-signin-button"
+                         label="&fxa.unverified.button.label;"
+                         oncommand="gSync.openPrefs('fxa_discoverability_native'); gSync.emitFxaToolbarTelemetry('unver_sync_settings');"/>
         </vbox>
         <vbox id="PanelUI-fxa-menu">
           <hbox flex="1" align="center" class="fxa-avatar-subpanel">
             <image role="presentation" id="fxa-menu-avatar"/>
             <vbox flex="1">
               <label class="fxa-avatar-subpanel-description" >&fxa.menu.signedInAs.label;</label>
               <label id="fxa-menu-email"></label>
             </vbox>
           </hbox>
           <toolbarseparator/>
           <toolbarbutton id="PanelUI-fxa-menu-sendtab-button"
                          class="subviewbutton subviewbutton-iconic subviewbutton-nav"
                          closemenu="none"
-                         oncommand="gSync.showSendToDeviceView(this);"/>
+                         oncommand="gSync.showSendToDeviceView(this); gSync.emitFxaToolbarTelemetry('send_tab');"/>
           <toolbarbutton id="PanelUI-fxa-menu-remotetabs-button"
                          class="subviewbutton subviewbutton-iconic subviewbutton-nav"
                          label="&appMenuRemoteTabs.label;"
                          closemenu="none"
-                         oncommand="PanelUI.showSubView('PanelUI-remotetabs', this)"/>
+                         oncommand="PanelUI.showSubView('PanelUI-remotetabs', this); gSync.emitFxaToolbarTelemetry('sync_tabs');"/>
           <toolbarbutton id="PanelUI-fxa-menu-view-sidebar"
                          class="subviewbutton subviewbutton-iconic"
                          label="&appMenuRemoteTabs.sidebar.label;"
-                         oncommand="SidebarUI.toggle('viewTabsSidebar');">
+                         oncommand="SidebarUI.toggle('viewTabsSidebar'); gSync.emitFxaToolbarTelemetry('sync_tabs_sidebar');">
             <observes element="sidebar-box" attribute="positionend"/>
           </toolbarbutton>
           <toolbarseparator/>
-          <toolbarbutton class="subviewbutton" label="&fxa.menu.connectAnotherDevice2.label;" oncommand="gSync.openConnectAnotherDevice('fxa_discoverability_native');"/>
-          <toolbarbutton class="subviewbutton" label="&fxa.menu.manageAccount.label;" oncommand="gSync.openFxAManagePage('fxa_discoverability_native');"/>
-          <toolbarbutton class="subviewbutton" label="&fxa.menu.syncSettings.label;" oncommand="gSync.openPrefs('fxa_discoverability_native');"/>
+          <toolbarbutton class="subviewbutton"
+                         label="&fxa.menu.connectAnotherDevice2.label;"
+                         oncommand="gSync.openConnectAnotherDevice('fxa_discoverability_native'); gSync.emitFxaToolbarTelemetry('cad');"/>
+          <toolbarbutton class="subviewbutton"
+                         label="&fxa.menu.manageAccount.label;"
+                         oncommand="gSync.openFxAManagePage('fxa_discoverability_native'); gSync.emitFxaToolbarTelemetry('account_settings');"/>
+          <toolbarbutton class="subviewbutton"
+                         label="&fxa.menu.syncSettings.label;"
+                         oncommand="gSync.openPrefs('fxa_discoverability_native'); gSync.emitFxaToolbarTelemetry('sync_settings');"/>
           <toolbarseparator/>
           <toolbarbutton id="PanelUI-fxa-menu-syncnow-button"
                          label="&syncSyncNowItem.label;"
                          syncinglabel="&syncSyncNowItemSyncing.label;"
                          class="subviewbutton subviewbutton-iconic"
-                         oncommand="gSync.doSync();"
+                         oncommand="gSync.doSync(); gSync.emitFxaToolbarTelemetry('sync_now');"
                          closemenu="none"/>
         </vbox>
       </vbox>
     </panelview>
     <!-- This panelview is used to contain the dynamically created buttons for send tab to devices -->
     <panelview id="PanelUI-sendTabToDevice" flex="1" class="PanelUI-subView">
       <vbox class="panel-subview-body">
         <toolbarbutton id="PanelUI-sendTabToDevice-syncingDevices" class="subviewbutton subviewbutton-iconic pageAction-sendToDevice-notReady"
--- a/toolkit/components/telemetry/Events.yaml
+++ b/toolkit/components/telemetry/Events.yaml
@@ -335,16 +335,42 @@ normandy:
       Sent when a preference rollout ends due to the rolled-out
       preference becoming a new default.
     bug_numbers: [1443560]
     notification_emails: ["normandy-notifications@mozilla.com"]
     record_in_processes: [main]
     release_channel_collection: opt-out
     expiry_version: never
 
+fxa_avatar_menu:
+  click:
+    objects: [
+      "account_settings",
+      "cad",
+      "login",
+      "send_tab",
+      "sync_now",
+      "sync_settings",
+      "sync_tabs",
+      "sync_tabs_sidebar",
+      "toolbar_icon",
+      "unver_sync_settings"
+      ]
+    methods: ["click"]
+    release_channel_collection: opt-out
+    record_in_processes: ["main"]
+    description: This is recorded on interactions with the FxA avatar menu on the toolbar
+    bug_numbers: [1524665]
+    notification_emails: ["vbudhram@mozilla.com", "loines@mozilla.com"]
+    expiry_version: "71"
+    extra_keys:
+      fxa_status: >
+        The current state of the user. Possible states are "not_configured", "unverified",
+        "signedin" and "login_failed".
+      fxa_avatar: Boolean for whether or not account has set an avatar
 
 # This category contains event entries used for Telemetry tests.
 # They will not be sent out with any pings.
 telemetry.test:
   test:
     methods: ["test1", "test2"]
     objects: ["object1", "object2"]
     bug_numbers: [1286606]