Bug 1272294 - only collect non-default search engine names if the user opted into telemetry, r=florian
MozReview-Commit-ID: 2mHHKBJyI6P
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -3651,28 +3651,27 @@ const BrowserSearch = {
loadAddEngines: function BrowserSearch_loadAddEngines() {
var newWindowPref = gPrefService.getIntPref("browser.link.open_newwindow");
var where = newWindowPref == 3 ? "tab" : "window";
var searchEnginesURL = formatURL("browser.search.searchEnginesURL", true);
openUILinkIn(searchEnginesURL, where);
},
+ get _isExtendedTelemetryEnabled() {
+ return Services.prefs.getBoolPref("toolkit.telemetry.enabled");
+ },
+
_getSearchEngineId: function (engine) {
- if (!engine) {
+ if (engine && engine.identifier) {
+ return engine.identifier;
+ }
+
+ if (!engine || (engine.name === undefined) || !this._isExtendedTelemetryEnabled)
return "other";
- }
-
- if (engine.identifier) {
- return engine.identifier;
- }
-
- if (!("name" in engine) || engine.name === undefined) {
- return "other";
- }
return "other-" + engine.name;
},
/**
* Helper to record a search with Telemetry.
*
* Telemetry records only search counts and nothing pertaining to the search itself.
--- a/browser/components/search/test/browser_contextSearchTabPosition.js
+++ b/browser/components/search/test/browser_contextSearchTabPosition.js
@@ -1,13 +1,14 @@
/* 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/. */
add_task(function* test() {
+ yield SpecialPowers.pushPrefEnv({set: [["toolkit.telemetry.enabled", true]]});
let engine = yield promiseNewEngine("testEngine.xml");
let histogramKey = "other-" + engine.name + ".contextmenu";
let numSearchesBefore = 0;
try {
let hs = Services.telemetry.getKeyedHistogramById("SEARCH_COUNTS").snapshot();
if (histogramKey in hs) {
numSearchesBefore = hs[histogramKey].sum;
--- a/browser/components/search/test/browser_healthreport.js
+++ b/browser/components/search/test/browser_healthreport.js
@@ -65,17 +65,18 @@ function test() {
case "engine-removed":
Services.obs.removeObserver(observer, "browser-search-engine-modified");
finish();
break;
}
}
Services.obs.addObserver(observer, "browser-search-engine-modified", false);
- Services.search.addEngine("http://mochi.test:8888/browser/browser/components/search/test/testEngine.xml",
- null, "data:image/x-icon,%00", false);
-
+ SpecialPowers.pushPrefEnv({set: [["toolkit.telemetry.enabled", true]]}).then(function() {
+ Services.search.addEngine("http://mochi.test:8888/browser/browser/components/search/test/testEngine.xml",
+ null, "data:image/x-icon,%00", false);
+ });
}
function resetPreferences() {
Preferences.resetBranch("datareporting.policy.");
Preferences.set("datareporting.policy.dataSubmissionPolicyBypassNotification", true);
}