Bug 1392951 - Implement telemetry probe for home page setup. r=liuche,mconley
authorEvan Tseng <evan@tseng.io>
Fri, 06 Oct 2017 16:13:05 +0800
changeset 679055 c4492a71092ec7ea0962b1c3f323406891f4a870
parent 679054 c63d0efbbcfd4a33e325ae4a41be043d6a247405
child 679056 074c0e2a308b4185b30ed56d72c806a646b6048f
push id84141
push userbmo:schien@mozilla.com
push dateThu, 12 Oct 2017 11:13:04 +0000
reviewersliuche, mconley
bugs1392951
milestone58.0a1
Bug 1392951 - Implement telemetry probe for home page setup. r=liuche,mconley - Send a ping when user type in "Home page" box. - String is longer than 4 letters and with at least one ".". - String is not deleted after 3 seconds. - Send a ping when "Use Current Page" is clicked. - Send a ping when "Use Bookmark" is clicked. - Send the number of "|" is detected in "Home page" box. MozReview-Commit-ID: 6bYK0eCkYym
browser/components/preferences/in-content/main.js
toolkit/components/telemetry/Scalars.yaml
--- a/browser/components/preferences/in-content/main.js
+++ b/browser/components/preferences/in-content/main.js
@@ -294,16 +294,18 @@ var gMainPane = {
     setEventListener("layers.acceleration.disabled", "change",
       gMainPane.updateHardwareAcceleration);
     setEventListener("connectionSettings", "command",
       gMainPane.showConnections);
     setEventListener("browserContainersCheckbox", "command",
       gMainPane.checkBrowserContainers);
     setEventListener("browserContainersSettings", "command",
       gMainPane.showContainerSettings);
+    setEventListener("browserHomePage", "input",
+      gMainPane.onBrowserHomePageChange);
 
     // Initializes the fonts dropdowns displayed in this pane.
     this._rebuildFonts();
 
     this.updateOnScreenKeyboardVisibility();
 
     // Show translation preferences if we may:
     const prefName = "browser.translation.ui.show";
@@ -738,30 +740,50 @@ var gMainPane = {
   setHomePageToCurrent() {
     let homePage = document.getElementById("browser.startup.homepage");
     let tabs = this._getTabsForHomePage();
     function getTabURI(t) {
       return t.linkedBrowser.currentURI.spec;
     }
 
     // FIXME Bug 244192: using dangerous "|" joiner!
-    if (tabs.length)
+    if (tabs.length) {
       homePage.value = tabs.map(getTabURI).join("|");
+    }
+
+    Services.telemetry.scalarAdd("preferences.use_current_page", 1);
   },
 
   /**
    * Displays a dialog in which the user can select a bookmark to use as home
    * page.  If the user selects a bookmark, that bookmark's name is displayed in
    * UI and the bookmark's address is stored to the home page preference.
    */
   setHomePageToBookmark() {
     var rv = { urls: null, names: null };
     gSubDialog.open("chrome://browser/content/preferences/selectBookmark.xul",
       "resizable=yes, modal=yes", rv,
       this._setHomePageToBookmarkClosed.bind(this, rv));
+    Services.telemetry.scalarAdd("preferences.use_bookmark", 1);
+  },
+
+  onBrowserHomePageChange() {
+    if (this.telemetryHomePageTimer) {
+      clearTimeout(this.telemetryHomePageTimer);
+    }
+    let browserHomePage = document.querySelector("#browserHomePage").value;
+    // The length of the home page URL string should be more then four,
+    // and it should contain at least one ".", for example, "https://mozilla.org".
+    if (browserHomePage.length > 4 && browserHomePage.includes(".")) {
+      this.telemetryHomePageTimer = setTimeout(() => {
+        let homePageNumber = browserHomePage.split("|").length;
+        Services.telemetry.scalarAdd("preferences.browser_home_page_change", 1);
+        Services.telemetry.keyedScalarAdd("preferences.browser_home_page_count", homePageNumber, 1);
+      }, 3000);
+    }
   },
 
   _setHomePageToBookmarkClosed(rv, aEvent) {
     if (aEvent.detail.button != "accept")
       return;
     if (rv.urls && rv.names) {
       var homePage = document.getElementById("browser.startup.homepage");
 
--- a/toolkit/components/telemetry/Scalars.yaml
+++ b/toolkit/components/telemetry/Scalars.yaml
@@ -540,16 +540,74 @@ preferences:
     expires: "62"
     kind: uint
     keyed: true
     notification_emails:
       - chsiang@mozilla.com
     release_channel_collection: opt-in
     record_in_processes:
       - main
+  browser_home_page_change:
+    bug_numbers:
+      - 1392951
+    description: >-
+      The number of times the home page has been changed.
+      Recorded when a user changes his/her home page successfully.
+    expires: "62"
+    kind: uint
+    keyed: true
+    notification_emails:
+      - chsiang@mozilla.com
+    release_channel_collection: opt-out
+    record_in_processes:
+      - main
+  browser_home_page_count:
+    bug_numbers:
+      - 1392951
+    description: >-
+      Each key is the number of home page urls when users change their home page,
+      multiple home pages can be set (delineated with a "|"),
+      and each value is the number of times that key is recorded.
+      The telemetry data will be recorded if a user changes his/her home page successfully.
+    expires: "62"
+    kind: uint
+    keyed: true
+    notification_emails:
+      - chsiang@mozilla.com
+    release_channel_collection: opt-out
+    record_in_processes:
+      - main
+  use_current_page:
+    bug_numbers:
+      - 1392951
+    description: >-
+      The number of times the Use Current Page button has been clicked.
+      Recorded when a a user clicks the "Use Current Page" button.
+    expires: "62"
+    kind: uint
+    keyed: true
+    notification_emails:
+      - chsiang@mozilla.com
+    release_channel_collection: opt-out
+    record_in_processes:
+      - main
+  use_bookmark:
+    bug_numbers:
+      - 1392951
+    description: >-
+      The number of times the "Use Bookmark..." button has been clicked.
+      Recorded when a a user clicks the "Use Bookmark..." button.
+    expires: "62"
+    kind: uint
+    keyed: true
+    notification_emails:
+      - chsiang@mozilla.com
+    release_channel_collection: opt-out
+    record_in_processes:
+      - main
 
 # The following section contains WebRTC nICEr scalars
 # For more info on ICE, see https://tools.ietf.org/html/rfc5245
 # For more info on STUN, see https://tools.ietf.org/html/rfc5389
 # For more info on TURN, see https://tools.ietf.org/html/rfc5766
 webrtc.nicer:
   stun_retransmits:
     bug_numbers: