Bug 1462725 - Rename study module; r=rhelmer draft
authorBianca Danforth <bdanforth@mozilla.com>
Mon, 04 Jun 2018 16:20:25 -0700
changeset 803871 175a029e1d0c3c536cc601e6382568832258aad5
parent 803870 edcc1ece90b8cc6a072703914bcfc1e6c87b7670
child 803872 5679a48de8e7e95c2b02619738582948032b2c19
push id112222
push userbdanforth@mozilla.com
push dateMon, 04 Jun 2018 23:26:13 +0000
reviewersrhelmer
bugs1462725, 1457226
milestone62.0a1
Bug 1462725 - Rename study module; r=rhelmer Module was renamed in order to be more consistent with references to this study elsewhere, as in the tracking bug 1457226. Also removed TelemetryEvents.sendEvent method, set log level to 'warn' and added milestone bug to search probe. MozReview-Commit-ID: KU82dQZLgxB
browser/app/profile/firefox.js
browser/components/nsBrowserGlue.js
browser/modules/SavantShieldStudy.jsm
browser/modules/ShieldStudySavant.jsm
browser/modules/moz.build
toolkit/components/telemetry/Events.yaml
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1721,9 +1721,9 @@ pref("app.normandy.shieldLearnMoreUrl", 
 #ifdef MOZ_DATA_REPORTING
 pref("app.shield.optoutstudies.enabled", true);
 #else
 pref("app.shield.optoutstudies.enabled", false);
 #endif
 
 // Savant Shield study preferences
 pref("shield.savant.enabled", false);
-pref("shield.savant.loglevel", "debug");
+pref("shield.savant.loglevel", "warn");
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -130,19 +130,19 @@ XPCOMUtils.defineLazyModuleGetters(this,
   PlacesUtils: "resource://gre/modules/PlacesUtils.jsm",
   PluralForm: "resource://gre/modules/PluralForm.jsm",
   PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.jsm",
   ProcessHangMonitor: "resource:///modules/ProcessHangMonitor.jsm",
   ReaderParent: "resource:///modules/ReaderParent.jsm",
   RemotePrompt: "resource:///modules/RemotePrompt.jsm",
   SafeBrowsing: "resource://gre/modules/SafeBrowsing.jsm",
   Sanitizer: "resource:///modules/Sanitizer.jsm",
+  SavantShieldStudy: "resource:///modules/SavantShieldStudy.jsm",
   SessionStore: "resource:///modules/sessionstore/SessionStore.jsm",
   ShellService: "resource:///modules/ShellService.jsm",
-  ShieldStudySavant: "resource:///modules/ShieldStudySavant.jsm",
   TabCrashHandler: "resource:///modules/ContentCrashHandlers.jsm",
   UIState: "resource://services-sync/UIState.jsm",
   UITour: "resource:///modules/UITour.jsm",
   WebChannel: "resource://gre/modules/WebChannel.jsm",
   WindowsRegistry: "resource://gre/modules/WindowsRegistry.jsm",
 });
 
 /* global ContentPrefServiceParent:false, ContentSearch:false,
@@ -1057,17 +1057,17 @@ BrowserGlue.prototype = {
     PageActions.init();
 
     this._firstWindowTelemetry(aWindow);
     this._firstWindowLoaded();
 
     // Set the default favicon size for UI views that use the page-icon protocol.
     PlacesUtils.favicons.setDefaultIconURIPreferredSize(16 * aWindow.devicePixelRatio);
 
-    ShieldStudySavant.init();
+    SavantShieldStudy.init();
   },
 
   _sendMediaTelemetry() {
     let win = Services.appShell.hiddenDOMWindow;
     let v = win.document.createElementNS("http://www.w3.org/1999/xhtml", "video");
     v.reportCanPlayTelemetry();
   },
 
rename from browser/modules/ShieldStudySavant.jsm
rename to browser/modules/SavantShieldStudy.jsm
--- a/browser/modules/ShieldStudySavant.jsm
+++ b/browser/modules/SavantShieldStudy.jsm
@@ -1,57 +1,57 @@
 /* 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/. */
 
 "use strict";
 
-var EXPORTED_SYMBOLS = ["ShieldStudySavant"];
+var EXPORTED_SYMBOLS = ["SavantShieldStudy"];
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 // See LOG_LEVELS in Console.jsm. Examples: "all", "info", "warn", & "error".
 const PREF_LOG_LEVEL = "shield.savant.loglevel";
 
 // Create a new instance of the ConsoleAPI so we can control the maxLogLevel with a pref.
 XPCOMUtils.defineLazyGetter(this, "log", () => {
   let ConsoleAPI = ChromeUtils.import("resource://gre/modules/Console.jsm", {}).ConsoleAPI;
   let consoleOptions = {
     maxLogLevelPref: PREF_LOG_LEVEL,
-    prefix: "ShieldStudySavant",
+    prefix: "SavantShieldStudy",
   };
   return new ConsoleAPI(consoleOptions);
 });
 
-class ShieldStudySavantClass {
+class SavantShieldStudyClass {
   constructor() {
-    this.SHIELD_STUDY_SAVANT_PREF = "shield.savant.enabled";
+    this.STUDY_PREF = "shield.savant.enabled";
     this.STUDY_TELEMETRY_CATEGORY = "savant";
   }
 
   init() {
     this.TelemetryEvents = new TelemetryEvents(this.STUDY_TELEMETRY_CATEGORY);
 
     // TODO: implement eligibility (#13)
     const isEligible = true;
     if (!isEligible) {
       this.endStudy("ineligible");
       return;
     }
     // check the pref in case Normandy flipped it on before we could add the pref listener
-    this.shouldCollect = Services.prefs.getBoolPref(this.SHIELD_STUDY_SAVANT_PREF);
+    this.shouldCollect = Services.prefs.getBoolPref(this.STUDY_PREF);
     if (this.shouldCollect) {
       this.TelemetryEvents.enableCollection();
     }
-    Services.prefs.addObserver(this.SHIELD_STUDY_SAVANT_PREF, this);
+    Services.prefs.addObserver(this.STUDY_PREF, this);
   }
 
   observe(subject, topic, data) {
-    if (topic === "nsPref:changed" && data === this.SHIELD_STUDY_SAVANT_PREF) {
+    if (topic === "nsPref:changed" && data === this.STUDY_PREF) {
       // toggle state of the pref
       this.shouldCollect = !this.shouldCollect;
       if (this.shouldCollect) {
         this.TelemetryEvents.enableCollection();
       } else {
         // The pref has been turned off
         this.endStudy("expired");
       }
@@ -59,46 +59,42 @@ class ShieldStudySavantClass {
   }
 
   sendEvent(method, object, value, extra) {
     this.TelemetryEvents.sendEvent(method, object, value, extra);
   }
 
   endStudy(reason) {
     this.TelemetryEvents.disableCollection();
-    // TODO: send endStudy ping with reason code
+    // Services.telemetry.recordEvent(this.STUDY_TELEMETRY_CATEGORY, "end_study", reason);
     this.uninit();
   }
 
   // Called on every Firefox shutdown and endStudy
   uninit() {
     // TODO: Make sure uninit() is called on every Firefox shutdown (look inside
     // nsBrowserGlue.js to see where Normandy uninits)
     // TODO: See what happens during Normandy's uninit method to ensure nothing
     // is forgotten.
-    Services.prefs.removeObserver(this.SHIELD_STUDY_SAVANT_PREF, this);
-    Services.prefs.clearUserPref(this.SHIELD_STUDY_SAVANT_PREF);
+    Services.prefs.removeObserver(this.STUDY_PREF, this);
+    Services.prefs.clearUserPref(this.STUDY_PREF);
     Services.prefs.clearUserPref(PREF_LOG_LEVEL);
   }
 }
 
-const ShieldStudySavant = new ShieldStudySavantClass();
+const SavantShieldStudy = new SavantShieldStudyClass();
 
 // references:
 // - https://hg.mozilla.org/mozilla-central/file/tip/toolkit/components/normandy/lib/TelemetryEvents.jsm
 // - https://hg.mozilla.org/mozilla-central/file/tip/toolkit/components/normandy/lib/PreferenceExperiments.jsm#l357
 class TelemetryEvents {
   constructor(studyCategory) {
     this.STUDY_TELEMETRY_CATEGORY = studyCategory;
   }
 
-  sendEvent(method, object, value, extra) {
-    Services.telemetry.recordEvent(this.STUDY_TELEMETRY_CATEGORY, method, object, value, extra);
-  }
-
   enableCollection() {
     log.debug("Study has been enabled; turning ON data collection.");
     Services.telemetry.setEventRecordingEnabled(this.STUDY_TELEMETRY_CATEGORY, true);
   }
 
   disableCollection() {
     log.debug("Study has been disabled; turning OFF data collection.");
     Services.telemetry.setEventRecordingEnabled(this.STUDY_TELEMETRY_CATEGORY, false);
--- a/browser/modules/moz.build
+++ b/browser/modules/moz.build
@@ -162,18 +162,18 @@ EXTRA_JS_MODULES += [
     'PageStyleHandler.jsm',
     'PermissionUI.jsm',
     'PingCentre.jsm',
     'PluginContent.jsm',
     'ProcessHangMonitor.jsm',
     'ReaderParent.jsm',
     'RemotePrompt.jsm',
     'Sanitizer.jsm',
+    'SavantShieldStudy.jsm',
     'SchedulePressure.jsm',
-    'ShieldStudySavant.jsm',
     'SiteDataManager.jsm',
     'SitePermissions.jsm',
     'TabsPopup.jsm',
     'ThemeVariableMap.jsm',
     'TransientPrefs.jsm',
     'webrtcUI.jsm',
     'ZoomUI.jsm',
 ]
--- a/toolkit/components/telemetry/Events.yaml
+++ b/toolkit/components/telemetry/Events.yaml
@@ -93,17 +93,17 @@ savant:
     objects: ["about_home", "about_newtab", "contextmenu", "oneoff",
               "suggestion", "alias", "enter", "searchbar", "urlbar"]
     release_channel_collection: opt-out
     record_in_processes: ["main"]
     description: >
       This is recorded on each search navigation.
       The value field records the action used to trigger the search:
         "enter", "oneoff", "suggestion", "alias", null (for contextmenu)
-    bug_numbers: [1316281, 1457226]
+    bug_numbers: [1316281, 1457226, 1462725]
     notification_emails:
       - "bdanforth@mozilla.com"
       - "shong@mozilla.com"
     expiry_version: "65"
     extra_keys:
       subcategory: The broad event category for this probe. E.g. navigation
       engine: The id of the search engine used.