Bug 1453667 - Remove BrowserUITelemetry from search. r?adw
MozReview-Commit-ID: L0Fj2d7BGdt
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -11,17 +11,16 @@ ChromeUtils.import("resource://gre/modul
ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
ChromeUtils.import("resource://gre/modules/NotificationDB.jsm");
const {WebExtensionPolicy} = Cu.getGlobalForObject(Services);
// lazy module getters
XPCOMUtils.defineLazyModuleGetters(this, {
- BrowserUITelemetry: "resource:///modules/BrowserUITelemetry.jsm",
BrowserUsageTelemetry: "resource:///modules/BrowserUsageTelemetry.jsm",
BrowserUtils: "resource://gre/modules/BrowserUtils.jsm",
BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.jsm",
CharsetMenu: "resource://gre/modules/CharsetMenu.jsm",
Color: "resource://gre/modules/Color.jsm",
ContentSearch: "resource:///modules/ContentSearch.jsm",
ContextualIdentityService: "resource://gre/modules/ContextualIdentityService.jsm",
CustomizableUI: "resource:///modules/CustomizableUI.jsm",
@@ -4164,27 +4163,16 @@ const BrowserSearch = {
},
loadAddEngines: function BrowserSearch_loadAddEngines() {
var newWindowPref = Services.prefs.getIntPref("browser.link.open_newwindow");
var where = newWindowPref == 3 ? "tab" : "window";
openTrustedLinkIn(this.searchEnginesURL, where);
},
- _getSearchEngineId(engine) {
- if (engine && engine.identifier) {
- return engine.identifier;
- }
-
- if (!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.
*
* @param engine
* (nsISearchEngine) The engine handling the search.
* @param source
@@ -4193,17 +4181,16 @@ const BrowserSearch = {
* @param details [optional]
* An optional parameter passed to |BrowserUsageTelemetry.recordSearch|.
* See its documentation for allowed options.
* Additionally, if the search was a suggested search, |details.selection|
* indicates where the item was in the suggestion list and how the user
* selected it: {selection: {index: The selected index, kind: "key" or "mouse"}}
*/
recordSearchInTelemetry(engine, source, details = {}) {
- BrowserUITelemetry.countSearchEvent(source, null, details.selection);
try {
BrowserUsageTelemetry.recordSearch(engine, source, details);
} catch (ex) {
Cu.reportError(ex);
}
},
/**
@@ -4217,18 +4204,16 @@ const BrowserSearch = {
* (string) Where the search originated from. See BrowserUsageTelemetry for
* allowed values.
* @param type
* (string) Indicates how the user selected the search item.
* @param where
* (string) Where was the search link opened (e.g. new tab, current tab, ..).
*/
recordOneoffSearchInTelemetry(engine, source, type, where) {
- let id = this._getSearchEngineId(engine) + "." + source;
- BrowserUITelemetry.countOneoffSearchEvent(id, type, where);
try {
const details = {type, isOneOff: true};
BrowserUsageTelemetry.recordSearch(engine, source, details);
} catch (ex) {
Cu.reportError(ex);
}
}
};
--- a/browser/base/content/test/urlbar/browser_urlbarSearchTelemetry.js
+++ b/browser/base/content/test/urlbar/browser_urlbarSearchTelemetry.js
@@ -1,12 +1,10 @@
"use strict";
-ChromeUtils.import("resource:///modules/BrowserUITelemetry.jsm");
-
const SUGGEST_URLBAR_PREF = "browser.urlbar.suggest.searches";
const TEST_ENGINE_BASENAME = "searchSuggestionEngine.xml";
// Must run first.
add_task(async function prepare() {
let suggestionsEnabled = Services.prefs.getBoolPref(SUGGEST_URLBAR_PREF);
Services.prefs.setBoolPref(SUGGEST_URLBAR_PREF, true);
let engine = await SearchTestUtils.promiseNewSearchEngine(
@@ -102,35 +100,24 @@ add_task(async function searchSuggestion
* counts.
*
* @param clickCallback Use this to open the urlbar popup and choose and click a
* result.
*/
async function compareCounts(clickCallback) {
// Search events triggered by clicks (not the Return key in the urlbar) are
// recorded in three places:
- // * BrowserUITelemetry
// * Telemetry histogram named "SEARCH_COUNTS"
// * FHR
let engine = Services.search.currentEngine;
let engineID = "org.mozilla.testsearchsuggestions";
// First, get the current counts.
- // BrowserUITelemetry
- let uiTelemCount = 0;
- let bucket = BrowserUITelemetry.currentBucket;
- let events = BrowserUITelemetry.getToolbarMeasures().countableEvents;
- if (events[bucket] &&
- events[bucket].search &&
- events[bucket].search.urlbar) {
- uiTelemCount = events[bucket].search.urlbar;
- }
-
// telemetry histogram SEARCH_COUNTS
let histogramCount = 0;
let histogramKey = engineID + ".urlbar";
let histogram;
try {
histogram = Services.telemetry.getKeyedHistogramById("SEARCH_COUNTS");
} catch (ex) {
// No searches performed yet, not a problem.
@@ -146,26 +133,16 @@ async function compareCounts(clickCallba
Object.defineProperty(engine.wrappedJSObject, "identifier",
{ value: engineID });
gURLBar.focus();
await clickCallback();
// Now get the new counts and compare them to the old.
- // BrowserUITelemetry
- events = BrowserUITelemetry.getToolbarMeasures().countableEvents;
- Assert.ok(bucket in events, "bucket should be recorded");
- events = events[bucket];
- Assert.ok("search" in events, "search should be recorded");
- events = events.search;
- Assert.ok("urlbar" in events, "urlbar should be recorded");
- Assert.equal(events.urlbar, uiTelemCount + 1,
- "clicked suggestion should be recorded");
-
// telemetry histogram SEARCH_COUNTS
histogram = Services.telemetry.getKeyedHistogramById("SEARCH_COUNTS");
let snapshot = histogram.snapshot();
Assert.ok(histogramKey in snapshot, "histogram with key should be recorded");
Assert.equal(snapshot[histogramKey].sum, histogramCount + 1,
"histogram sum should be incremented");
}
--- a/browser/components/search/content/search.xml
+++ b/browser/components/search/content/search.xml
@@ -1350,18 +1350,16 @@
<body><![CDATA[
// Make sure the engine list is refetched next time it's needed.
this._engines = null;
]]></body>
</method>
<method name="showSettings">
<body><![CDATA[
- BrowserUITelemetry.countSearchSettingsEvent(this.telemetryOrigin);
-
openPreferences("paneSearch", {origin: "contentSearch"});
// If the preference tab was already selected, the panel doesn't
// close itself automatically.
this.popup.hidePopup();
]]></body>
</method>
--- a/browser/components/search/test/browser_oneOffContextMenu.js
+++ b/browser/components/search/test/browser_oneOffContextMenu.js
@@ -30,21 +30,16 @@ add_task(async function init() {
);
await promiseNewEngine(TEST_ENGINE_BASENAME, {
setAsCurrent: false,
});
});
add_task(async function telemetry() {
- await doTest();
- checkTelemetry("other-" + TEST_ENGINE_NAME);
-});
-
-async function doTest() {
// Open the popup.
let promise = promiseEvent(searchPopup, "popupshown");
info("Opening search panel");
EventUtils.synthesizeMouseAtCenter(searchIcon, {});
await promise;
// Get the one-off button for the test engine.
let oneOffButton;
@@ -80,26 +75,9 @@ async function doTest() {
Assert.equal(tab.linkedBrowser.currentURI.spec,
"http://mochi.test:8888/browser/browser/components/search/test/",
"Expected search tab should have loaded");
BrowserTestUtils.removeTab(tab);
// Move the cursor out of the panel area to avoid messing with other tests.
await EventUtils.synthesizeNativeMouseMove(searchbar);
-}
-
-function checkTelemetry(expectedEngineName) {
- let propertyPath = [
- "countableEvents",
- "__DEFAULT__",
- "search-oneoff",
- expectedEngineName + ".oneoff-context-searchbar",
- "unknown",
- "tab-background",
- ];
- let telem = BrowserUITelemetry.getToolbarMeasures();
- for (let prop of propertyPath) {
- Assert.ok(prop in telem, "Property " + prop + " should be in the telemetry");
- telem = telem[prop];
- }
- Assert.equal(telem, 1, "Click count");
-}
+});