Bug 1371198 - Update follow-on search telemetry to v0.9.0, and enable its telemetry reporting for most users. r=past
authorMark Banner <standard8@mozilla.com>
Wed, 14 Jun 2017 13:41:56 +0100
changeset 363919 a1a64d1a69200226dc412f6786e1d30e9890d1e3
parent 363918 7710bc9cca30b2aaa8c5200b95aad27f87439906
child 363920 7f1e5af6138bbcbd7c3ef73d37e50b91c52e18e1
push id44727
push usermbanner@mozilla.com
push dateWed, 14 Jun 2017 13:58:07 +0000
treeherderautoland@a1a64d1a6920 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspast
bugs1371198
milestone56.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 1371198 - Update follow-on search telemetry to v0.9.0, and enable its telemetry reporting for most users. r=past
browser/extensions/followonsearch/bootstrap.js
browser/extensions/followonsearch/content/followonsearch-fs.js
browser/extensions/followonsearch/install.rdf
--- a/browser/extensions/followonsearch/bootstrap.js
+++ b/browser/extensions/followonsearch/bootstrap.js
@@ -4,34 +4,19 @@
 
 "use strict";
 
 const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Timer.jsm");
 
-XPCOMUtils.defineLazyModuleGetter(this, "UpdateUtils",
-  "resource://gre/modules/UpdateUtils.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "TelemetryEnvironment",
-  "resource://gre/modules/TelemetryEnvironment.jsm");
-
-// The amount of people to be part of the telemetry reporting.
-const REPORTING_THRESHOLD = {
-  // "default": 1.0, // 100% - self builds, linux distros etc.
-  "nightly": 0.1, // 10%
-  "beta": 0.1,  // 10%
-  "release": 0.1,  // 10%
-};
-
 // Preferences this add-on uses.
 const kPrefPrefix = "extensions.followonsearch.";
-const PREF_COHORT_SAMPLE = `${kPrefPrefix}cohortSample`;
 const PREF_LOGGING = `${kPrefPrefix}logging`;
-const PREF_CHANNEL_OVERRIDE = `${kPrefPrefix}override`;
 
 const kExtensionID = "followonsearch@mozilla.com";
 const kSaveTelemetryMsg = `${kExtensionID}:save-telemetry`;
 const kShutdownMsg = `${kExtensionID}:shutdown`;
 
 const frameScript = `chrome://followonsearch/content/followonsearch-fs.js?q=${Math.random()}`;
 
 const validSearchTypes = [
@@ -84,32 +69,26 @@ function activateTelemetry() {
   if (gTelemetryActivated) {
     return;
   }
 
   gTelemetryActivated = true;
 
   Services.mm.addMessageListener(kSaveTelemetryMsg, handleSaveTelemetryMsg);
   Services.mm.loadFrameScript(frameScript, true);
-
-  // Record the fact we're saving the extra data as a telemetry environment
-  // value.
-  TelemetryEnvironment.setExperimentActive(kExtensionID, "active");
 }
 
 /**
  * Deactivites recording of telemetry if it isn't already deactivated.
  */
 function deactivateTelemetry() {
   if (!gTelemetryActivated) {
     return;
   }
 
-  TelemetryEnvironment.setExperimentInactive(kExtensionID);
-
   Services.mm.removeMessageListener(kSaveTelemetryMsg, handleSaveTelemetryMsg);
   Services.mm.removeDelayedFrameScript(frameScript);
   Services.mm.broadcastAsyncMessage(kShutdownMsg);
 
   gTelemetryActivated = false;
 }
 
 /**
@@ -132,54 +111,23 @@ var cohortManager = {
     }
 
     this._definedThisSession = true;
     this.enableForUser = false;
 
     try {
       let distId = Services.prefs.getCharPref("distribution.id", "");
       if (distId) {
-        log("It is a distribution, not setting up nor enabling.");
+        log("It is a distribution, not setting up nor enabling telemetry.");
         return;
       }
     } catch (e) {}
 
-    let cohortSample;
-    try {
-      cohortSample = Services.prefs.getFloatPref(PREF_COHORT_SAMPLE, undefined);
-    } catch (e) {}
-    if (!cohortSample) {
-      cohortSample = Math.random().toString().substr(0, 8);
-      cohortSample = Services.prefs.setCharPref(PREF_COHORT_SAMPLE, cohortSample);
-    }
-    log(`Cohort Sample value is ${cohortSample}`);
-
-    let updateChannel = UpdateUtils.getUpdateChannel(false);
-    log(`Update channel is ${updateChannel}`);
-    if (!(updateChannel in REPORTING_THRESHOLD)) {
-      let prefOverride = "default";
-      try {
-        prefOverride = Services.prefs.getCharPref(PREF_CHANNEL_OVERRIDE, "default");
-      } catch (e) {}
-      if (prefOverride in REPORTING_THRESHOLD) {
-        updateChannel = prefOverride;
-      } else {
-        // Don't enable, we don't know about the channel, and it isn't overriden.
-        return;
-      }
-    }
-
-    log("Not enabling extra telemetry due to bug 1371198");
-
-    // if (cohortSample <= REPORTING_THRESHOLD[updateChannel]) {
-    //   log("Enabling telemetry for user");
-    //   this.enableForUser = true;
-    // } else {
-    //   log("Not enabling telemetry for user - outside threshold.");
-    // }
+    log("Enabling telemetry for user");
+    this.enableForUser = true;
   },
 };
 
 /**
  * Called when the add-on is installed.
  *
  * @param {Object} data Data about the add-on.
  * @param {Number} reason Indicates why the extension is being installed.
--- a/browser/extensions/followonsearch/content/followonsearch-fs.js
+++ b/browser/extensions/followonsearch/content/followonsearch-fs.js
@@ -2,145 +2,136 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* eslint-env mozilla/frame-script */
 
 "use strict";
 
 const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
-Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.importGlobalProperties(["URLSearchParams"]);
 
 const kExtensionID = "followonsearch@mozilla.com";
 const kSaveTelemetryMsg = `${kExtensionID}:save-telemetry`;
 const kShutdownMsg = `${kExtensionID}:shutdown`;
 
 /**
  * A map of search domains with their expected codes.
  */
-let searchDomains = {
-  "search.yahoo.co.jp": {
-    "search": "p",
-    "followOnSearch": "ai",
-    "prefix": "fr",
-    "codes": ["mozff"],
-    "sap": "yahoo",
-  },
-  "www.bing.com": {
-    "search": "q",
-    "prefix": "pc",
-    "reportPrefix": "form",
-    "codes": ["MOZI"],
-    "sap": "bing",
-  },
-};
-
-// The yahoo domains to watch for.
-const yahooDomains = new Set([
-  "search.yahoo.com", "ca.search.yahoo.com", "hk.search.yahoo.com",
-  "tw.search.yahoo.com",
-]);
-
-// Add Yahoo domains to search domains
-for (let domain of yahooDomains) {
-  searchDomains[domain] = {
-    "search": "p",
-    "followOnSearch": "fr2",
-    "prefix": "hspart",
-    "reportPrefix": "hsimp",
-    "codes": ["mozilla"],
-    "sap": "yahoo",
-  };
-}
-
-const yahooLegacyDomains = new Set([
-  "no.search.yahoo.com", "ar.search.yahoo.com", "br.search.yahoo.com",
-  "ch.search.yahoo.com", "cl.search.yahoo.com", "de.search.yahoo.com",
-  "uk.search.yahoo.com", "es.search.yahoo.com", "espanol.search.yahoo.com",
-  "fi.search.yahoo.com", "fr.search.yahoo.com", "nl.search.yahoo.com",
-  "id.search.yahoo.com", "in.search.yahoo.com", "it.search.yahoo.com",
-  "mx.search.yahoo.com", "se.search.yahoo.com", "sg.search.yahoo.com",
-]);
-
-// Add Yahoo legacy domains to search domains
-for (let domain of yahooLegacyDomains) {
-  searchDomains[domain] = {
-    "search": "p",
-    "followOnSearch": "fr2",
-    "prefix": "fr",
-    "codes": ["moz35"],
-    "sap": "yahoo",
-  };
-}
+let searchDomains = [{
+  "domains": [ "search.yahoo.co.jp" ],
+  "search": "p",
+  "followOnSearch": "ai",
+  "prefix": "fr",
+  "codes": ["mozff"],
+  "sap": "yahoo",
+}, {
+  "domains": [ "www.bing.com" ],
+  "search": "q",
+  "prefix": "pc",
+  "reportPrefix": "form",
+  "codes": ["MOZI"],
+  "sap": "bing",
+}, {
+  // The Yahoo domains to watch for.
+  "domains": [
+    "search.yahoo.com", "ca.search.yahoo.com", "hk.search.yahoo.com",
+    "tw.search.yahoo.com"
+  ],
+  "search": "p",
+  "followOnSearch": "fr2",
+  "prefix": "hspart",
+  "reportPrefix": "hsimp",
+  "codes": ["mozilla"],
+  "sap": "yahoo",
+}, {
+  // The Yahoo legacy domains.
+  "domains": [
+    "no.search.yahoo.com", "ar.search.yahoo.com", "br.search.yahoo.com",
+    "ch.search.yahoo.com", "cl.search.yahoo.com", "de.search.yahoo.com",
+    "uk.search.yahoo.com", "es.search.yahoo.com", "espanol.search.yahoo.com",
+    "fi.search.yahoo.com", "fr.search.yahoo.com", "nl.search.yahoo.com",
+    "id.search.yahoo.com", "in.search.yahoo.com", "it.search.yahoo.com",
+    "mx.search.yahoo.com", "se.search.yahoo.com", "sg.search.yahoo.com",
+  ],
+  "search": "p",
+  "followOnSearch": "fr2",
+  "prefix": "fr",
+  "codes": ["moz35"],
+  "sap": "yahoo",
+}, {
+  // The Google domains.
+  "domains": [
+    "www.google.com", "www.google.ac", "www.google.ad", "www.google.ae",
+    "www.google.com.af", "www.google.com.ag", "www.google.com.ai",
+    "www.google.al", "www.google.am", "www.google.co.ao", "www.google.com.ar",
+    "www.google.as", "www.google.at", "www.google.com.au", "www.google.az",
+    "www.google.ba", "www.google.com.bd", "www.google.be", "www.google.bf",
+    "www.google.bg", "www.google.com.bh", "www.google.bi", "www.google.bj",
+    "www.google.com.bn", "www.google.com.bo", "www.google.com.br",
+    "www.google.bs", "www.google.bt", "www.google.co.bw", "www.google.by",
+    "www.google.com.bz", "www.google.ca", "www.google.com.kh", "www.google.cc",
+    "www.google.cd", "www.google.cf", "www.google.cat", "www.google.cg",
+    "www.google.ch", "www.google.ci", "www.google.co.ck", "www.google.cl",
+    "www.google.cm", "www.google.cn", "www.google.com.co", "www.google.co.cr",
+    "www.google.com.cu", "www.google.cv", "www.google.cx", "www.google.com.cy",
+    "www.google.cz", "www.google.de", "www.google.dj", "www.google.dk",
+    "www.google.dm", "www.google.com.do", "www.google.dz", "www.google.com.ec",
+    "www.google.ee", "www.google.com.eg", "www.google.es", "www.google.com.et",
+    "www.google.eu", "www.google.fi", "www.google.com.fj", "www.google.fm",
+    "www.google.fr", "www.google.ga", "www.google.ge", "www.google.gf",
+    "www.google.gg", "www.google.com.gh", "www.google.com.gi", "www.google.gl",
+    "www.google.gm", "www.google.gp", "www.google.gr", "www.google.com.gt",
+    "www.google.gy", "www.google.com.hk", "www.google.hn", "www.google.hr",
+    "www.google.ht", "www.google.hu", "www.google.co.id", "www.google.iq",
+    "www.google.ie", "www.google.co.il", "www.google.im", "www.google.co.in",
+    "www.google.io", "www.google.is", "www.google.it", "www.google.je",
+    "www.google.com.jm", "www.google.jo", "www.google.co.jp", "www.google.co.ke",
+    "www.google.ki", "www.google.kg", "www.google.co.kr", "www.google.com.kw",
+    "www.google.kz", "www.google.la", "www.google.com.lb", "www.google.com.lc",
+    "www.google.li", "www.google.lk", "www.google.co.ls", "www.google.lt",
+    "www.google.lu", "www.google.lv", "www.google.com.ly", "www.google.co.ma",
+    "www.google.md", "www.google.me", "www.google.mg", "www.google.mk",
+    "www.google.ml", "www.google.com.mm", "www.google.mn", "www.google.ms",
+    "www.google.com.mt", "www.google.mu", "www.google.mv", "www.google.mw",
+    "www.google.com.mx", "www.google.com.my", "www.google.co.mz",
+    "www.google.com.na", "www.google.ne", "www.google.nf", "www.google.com.ng",
+    "www.google.com.ni", "www.google.nl", "www.google.no", "www.google.com.np",
+    "www.google.nr", "www.google.nu", "www.google.co.nz", "www.google.com.om",
+    "www.google.com.pk", "www.google.com.pa", "www.google.com.pe",
+    "www.google.com.ph", "www.google.pl", "www.google.com.pg", "www.google.pn",
+    "www.google.com.pr", "www.google.ps", "www.google.pt", "www.google.com.py",
+    "www.google.com.qa", "www.google.ro", "www.google.rs", "www.google.ru",
+    "www.google.rw", "www.google.com.sa", "www.google.com.sb", "www.google.sc",
+    "www.google.se", "www.google.com.sg", "www.google.sh", "www.google.si",
+    "www.google.sk", "www.google.com.sl", "www.google.sn", "www.google.sm",
+    "www.google.so", "www.google.st", "www.google.sr", "www.google.com.sv",
+    "www.google.td", "www.google.tg", "www.google.co.th", "www.google.com.tj",
+    "www.google.tk", "www.google.tl", "www.google.tm", "www.google.to",
+    "www.google.tn", "www.google.com.tr", "www.google.tt", "www.google.com.tw",
+    "www.google.co.tz", "www.google.com.ua", "www.google.co.ug",
+    "www.google.co.uk", "www.google.us", "www.google.com.uy", "www.google.co.uz",
+    "www.google.com.vc", "www.google.co.ve", "www.google.vg", "www.google.co.vi",
+    "www.google.com.vn", "www.google.vu", "www.google.ws", "www.google.co.za",
+    "www.google.co.zm", "www.google.co.zw",
+  ],
+  "search": "q",
+  "prefix": "client",
+  "codes": ["firefox-b-ab", "firefox-b"],
+  "sap": "google",
+}];
 
-const googleDomains = new Set([
-  "www.google.com", "www.google.ac", "www.google.ad", "www.google.ae",
-  "www.google.com.af", "www.google.com.ag", "www.google.com.ai",
-  "www.google.al", "www.google.am", "www.google.co.ao", "www.google.com.ar",
-  "www.google.as", "www.google.at", "www.google.com.au", "www.google.az",
-  "www.google.ba", "www.google.com.bd", "www.google.be", "www.google.bf",
-  "www.google.bg", "www.google.com.bh", "www.google.bi", "www.google.bj",
-  "www.google.com.bn", "www.google.com.bo", "www.google.com.br",
-  "www.google.bs", "www.google.bt", "www.google.co.bw", "www.google.by",
-  "www.google.com.bz", "www.google.ca", "www.google.com.kh", "www.google.cc",
-  "www.google.cd", "www.google.cf", "www.google.cat", "www.google.cg",
-  "www.google.ch", "www.google.ci", "www.google.co.ck", "www.google.cl",
-  "www.google.cm", "www.google.cn", "www.google.com.co", "www.google.co.cr",
-  "www.google.com.cu", "www.google.cv", "www.google.cx", "www.google.com.cy",
-  "www.google.cz", "www.google.de", "www.google.dj", "www.google.dk",
-  "www.google.dm", "www.google.com.do", "www.google.dz", "www.google.com.ec",
-  "www.google.ee", "www.google.com.eg", "www.google.es", "www.google.com.et",
-  "www.google.eu", "www.google.fi", "www.google.com.fj", "www.google.fm",
-  "www.google.fr", "www.google.ga", "www.google.ge", "www.google.gf",
-  "www.google.gg", "www.google.com.gh", "www.google.com.gi", "www.google.gl",
-  "www.google.gm", "www.google.gp", "www.google.gr", "www.google.com.gt",
-  "www.google.gy", "www.google.com.hk", "www.google.hn", "www.google.hr",
-  "www.google.ht", "www.google.hu", "www.google.co.id", "www.google.iq",
-  "www.google.ie", "www.google.co.il", "www.google.im", "www.google.co.in",
-  "www.google.io", "www.google.is", "www.google.it", "www.google.je",
-  "www.google.com.jm", "www.google.jo", "www.google.co.jp", "www.google.co.ke",
-  "www.google.ki", "www.google.kg", "www.google.co.kr", "www.google.com.kw",
-  "www.google.kz", "www.google.la", "www.google.com.lb", "www.google.com.lc",
-  "www.google.li", "www.google.lk", "www.google.co.ls", "www.google.lt",
-  "www.google.lu", "www.google.lv", "www.google.com.ly", "www.google.co.ma",
-  "www.google.md", "www.google.me", "www.google.mg", "www.google.mk",
-  "www.google.ml", "www.google.com.mm", "www.google.mn", "www.google.ms",
-  "www.google.com.mt", "www.google.mu", "www.google.mv", "www.google.mw",
-  "www.google.com.mx", "www.google.com.my", "www.google.co.mz",
-  "www.google.com.na", "www.google.ne", "www.google.nf", "www.google.com.ng",
-  "www.google.com.ni", "www.google.nl", "www.google.no", "www.google.com.np",
-  "www.google.nr", "www.google.nu", "www.google.co.nz", "www.google.com.om",
-  "www.google.com.pk", "www.google.com.pa", "www.google.com.pe",
-  "www.google.com.ph", "www.google.pl", "www.google.com.pg", "www.google.pn",
-  "www.google.com.pr", "www.google.ps", "www.google.pt", "www.google.com.py",
-  "www.google.com.qa", "www.google.ro", "www.google.rs", "www.google.ru",
-  "www.google.rw", "www.google.com.sa", "www.google.com.sb", "www.google.sc",
-  "www.google.se", "www.google.com.sg", "www.google.sh", "www.google.si",
-  "www.google.sk", "www.google.com.sl", "www.google.sn", "www.google.sm",
-  "www.google.so", "www.google.st", "www.google.sr", "www.google.com.sv",
-  "www.google.td", "www.google.tg", "www.google.co.th", "www.google.com.tj",
-  "www.google.tk", "www.google.tl", "www.google.tm", "www.google.to",
-  "www.google.tn", "www.google.com.tr", "www.google.tt", "www.google.com.tw",
-  "www.google.co.tz", "www.google.com.ua", "www.google.co.ug",
-  "www.google.co.uk", "www.google.us", "www.google.com.uy", "www.google.co.uz",
-  "www.google.com.vc", "www.google.co.ve", "www.google.vg", "www.google.co.vi",
-  "www.google.com.vn", "www.google.vu", "www.google.ws", "www.google.co.za",
-  "www.google.co.zm", "www.google.co.zw",
-]);
-
-// Add Google domains to search domains
-for (let domain of googleDomains) {
-  searchDomains[domain] = {
-    "search": "q",
-    "prefix": "client",
-    "codes": ["firefox-b-ab", "firefox-b"],
-    "sap": "google",
-  };
+function getSearchDomainCodes(host) {
+  for (let domainInfo of searchDomains) {
+    if (domainInfo.domains.includes(host)) {
+      return domainInfo;
+    }
+  }
+  return null;
 }
 
 /**
  * Used for debugging to log messages.
  *
  * @param {String} message The message to log.
  */
 function log(message) {
@@ -159,35 +150,36 @@ let gLastSearch = null;
 var webProgressListener = {
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener, Ci.nsISupportsWeakReference]),
   onLocationChange(aWebProgress, aRequest, aLocation, aFlags)
   {
     try {
       if (!aWebProgress.isTopLevel ||
           // Not a URL
           (!aLocation.schemeIs("http") && !aLocation.schemeIs("https")) ||
-          // Not a domain we handle
-          !(aLocation.host in searchDomains) ||
           // Doesn't have a query string or a ref
           (!aLocation.query && !aLocation.ref) ||
           // Is the same as our last search (avoids reloads)
           aLocation.spec == gLastSearch) {
         return;
       }
-      let domainInfo = searchDomains[aLocation.host];
+      let domainInfo = getSearchDomainCodes(aLocation.host);
+      if (!domainInfo) {
+        return;
+      }
 
       let queries = new URLSearchParams(aLocation.query);
       let code = queries.get(domainInfo.prefix);
       if (queries.get(domainInfo.search)) {
         if (domainInfo.codes.includes(code)) {
           if (domainInfo.reportPrefix &&
               queries.get(domainInfo.reportPrefix)) {
             code = queries.get(domainInfo.reportPrefix);
           }
-          if (googleDomains.has(aLocation.host) && aLocation.ref) {
+          if (domainInfo.sap == "google" && aLocation.ref) {
             log(`${aLocation.host} search with code ${code} - Follow on`);
             sendSaveTelemetryMsg(code, domainInfo.sap, "follow-on");
           } else if (queries.get(domainInfo.followOnSearch)) {
             log(`${aLocation.host} search with code ${code} - Follow on`);
             sendSaveTelemetryMsg(code, domainInfo.sap, "follow-on");
           } else {
             log(`${aLocation.host} search with code ${code} - First search via Firefox`);
             sendSaveTelemetryMsg(code, domainInfo.sap, "sap");
--- a/browser/extensions/followonsearch/install.rdf
+++ b/browser/extensions/followonsearch/install.rdf
@@ -2,17 +2,17 @@
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 <RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
      xmlns:em="http://www.mozilla.org/2004/em-rdf#">
   <Description about="urn:mozilla:install-manifest">
     <em:id>followonsearch@mozilla.com</em:id>
     <em:name>Follow-on Search Telemetry</em:name>
-    <em:version>0.8.0</em:version>
+    <em:version>0.9.0</em:version>
     <em:type>2</em:type>
     <em:bootstrap>true</em:bootstrap>
     <em:multiprocessCompatible>true</em:multiprocessCompatible>
     <em:targetApplication>
       <Description>
         <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
         <em:minVersion>52.0</em:minVersion>
         <em:maxVersion>59.*</em:maxVersion>