Bug 1294680 - instrument the 'Settings page' button, r=past. a=lizzard
authorFlorian Quèze <florian@queze.net>
Fri, 12 Aug 2016 15:57:49 +0200
changeset 342311 1ab4e3c7085d7271e527787904e5cd05b5537a65
parent 342310 c250152accdc9ae9056c43d62e20e5fa743cc87c
child 342312 eb93bd0c50d6bdf9a59202dc4b6a88927bb420bd
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspast, lizzard
bugs1294680
milestone49.0
Bug 1294680 - instrument the 'Settings page' button, r=past. a=lizzard
browser/components/search/content/searchReset.js
browser/components/search/test/browser_aboutSearchReset.js
toolkit/components/telemetry/Histograms.json
--- a/browser/components/search/content/searchReset.js
+++ b/browser/components/search/content/searchReset.js
@@ -7,28 +7,31 @@
 var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
 
 Cu.import("resource://gre/modules/Services.jsm");
 
 const TELEMETRY_RESULT_ENUM = {
   RESTORED_DEFAULT: 0,
   KEPT_CURRENT: 1,
   CHANGED_ENGINE: 2,
-  CLOSED_PAGE: 3
+  CLOSED_PAGE: 3,
+  OPENED_SETTINGS: 4
 };
 
 window.onload = function() {
   let defaultEngine = document.getElementById("defaultEngine");
   let originalDefault = Services.search.originalDefaultEngine;
   defaultEngine.textContent = originalDefault.name;
   defaultEngine.style.backgroundImage =
     'url("' + originalDefault.iconURI.spec + '")';
 
   document.getElementById("searchResetChangeEngine").focus();
   window.addEventListener("unload", recordPageClosed);
+  document.getElementById("linkSettingsPage")
+          .addEventListener("click", openingSettings);
 };
 
 function doSearch() {
   let queryString = "";
   let purpose = "";
   let params = window.location.href.match(/^about:searchreset\?([^#]*)/);
   if (params) {
     params = params[1].split("&");
@@ -49,16 +52,21 @@ function doSearch() {
                   .getInterface(Ci.nsIWebNavigation)
                   .QueryInterface(Ci.nsIDocShellTreeItem)
                   .rootTreeItem
                   .QueryInterface(Ci.nsIInterfaceRequestor)
                   .getInterface(Ci.nsIDOMWindow);
   win.openUILinkIn(submission.uri.spec, "current", false, submission.postData);
 }
 
+function openingSettings() {
+  record(TELEMETRY_RESULT_ENUM.OPENED_SETTINGS);
+  window.removeEventListener("unload", recordPageClosed);
+}
+
 function record(result) {
   Services.telemetry.getHistogramById("SEARCH_RESET_RESULT").add(result);
 }
 
 function keepCurrentEngine() {
   // Calling the currentEngine setter will force a correct loadPathHash to be
   // written for this engine, so that we don't prompt the user again.
   Services.search.currentEngine = Services.search.currentEngine;
--- a/browser/components/search/test/browser_aboutSearchReset.js
+++ b/browser/components/search/test/browser_aboutSearchReset.js
@@ -1,17 +1,18 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
 const TELEMETRY_RESULT_ENUM = {
   RESTORED_DEFAULT: 0,
   KEPT_CURRENT: 1,
   CHANGED_ENGINE: 2,
-  CLOSED_PAGE: 3
+  CLOSED_PAGE: 3,
+  OPENED_SETTINGS: 4
 };
 
 const kSearchStr = "a search";
 const kSearchPurpose = "searchbar";
 
 const kTestEngine = "testEngine.xml";
 
 function checkTelemetryRecords(expectedValue) {
@@ -96,16 +97,29 @@ var gTests = [
        "the default engine is back to the original one");
 
     checkTelemetryRecords(TELEMETRY_RESULT_ENUM.RESTORED_DEFAULT);
     Services.search.currentEngine = currentEngine;
   }
 },
 
 {
+  desc: "Click the settings link.",
+  run: function* () {
+    let loadPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser,
+                                                     false,
+                                                     "about:preferences#search")
+    gBrowser.contentDocument.getElementById("linkSettingsPage").click();
+    yield loadPromise;
+
+    checkTelemetryRecords(TELEMETRY_RESULT_ENUM.OPENED_SETTINGS);
+  }
+},
+
+{
   desc: "Load another page without clicking any of the buttons.",
   run: function* () {
     yield promiseTabLoadEvent(gBrowser.selectedTab, "about:mozilla");
 
     checkTelemetryRecords(TELEMETRY_RESULT_ENUM.CLOSED_PAGE);
   }
 },
 
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -5575,17 +5575,17 @@
   },
   "SEARCH_RESET_RESULT": {
     "alert_emails": ["fqueze@mozilla.com"],
     "bug_numbers": [1203168],
     "expires_in_version": "53",
     "kind": "enumerated",
     "n_values": 5,
     "releaseChannelCollection": "opt-out",
-    "description": "Result of showing the search reset prompt to the user. 0=restored original default, 1=kept current engine, 2=changed engine, 3=closed the page"
+    "description": "Result of showing the search reset prompt to the user. 0=restored original default, 1=kept current engine, 2=changed engine, 3=closed the page, 4=opened search settings"
   },
   "SEARCH_SERVICE_INIT_MS": {
     "expires_in_version": "never",
     "kind": "exponential",
     "high": 1000,
     "n_buckets": 15,
     "description": "Time (ms) it takes to initialize the search service"
   },