зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1381460 - Add telemetry search event for Activity Stream. r=Dexter data-r=bsmedberg
MozReview-Commit-ID: GLbDNLglvDY --HG-- extra : rebase_source : 2aee316d1b8354f67c7b3236f75f5e4b104f8705
This commit is contained in:
Родитель
6b45e4e6cf
Коммит
dafc6cbd15
|
@ -2082,12 +2082,7 @@ class Search extends React.Component {
|
|||
}
|
||||
onInputMount(input) {
|
||||
if (input) {
|
||||
// The first "newtab" parameter here is called the "healthReportKey" and needs
|
||||
// to be "newtab" so that BrowserUsageTelemetry.jsm knows to handle events with
|
||||
// this name, and can add the appropriate telemetry probes for search. Without the
|
||||
// correct name, certain tests like browser_UsageTelemetry_content.js will fail (See
|
||||
// github ticket #2348 for more details)
|
||||
this.controller = new ContentSearchUIController(input, input.parentNode, "newtab", "newtab");
|
||||
this.controller = new ContentSearchUIController(input, input.parentNode, "activitystream", "newtab");
|
||||
addEventListener("ContentSearchClient", this);
|
||||
} else {
|
||||
this.controller = null;
|
||||
|
|
|
@ -45,6 +45,7 @@ const KNOWN_SEARCH_SOURCES = [
|
|||
"newtab",
|
||||
"searchbar",
|
||||
"urlbar",
|
||||
"activitystream"
|
||||
];
|
||||
|
||||
const KNOWN_ONEOFF_SOURCES = [
|
||||
|
@ -451,6 +452,9 @@ let BrowserUsageTelemetry = {
|
|||
case "newtab":
|
||||
this._recordSearch(engine, "about_newtab", "enter");
|
||||
break;
|
||||
case "activitystream":
|
||||
this._recordSearch(engine, "activitystream", "enter");
|
||||
break;
|
||||
case "contextmenu":
|
||||
this._recordSearch(engine, "contextmenu");
|
||||
break;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
const BASE_PROBE_NAME = "browser.engagement.navigation.";
|
||||
const SCALAR_CONTEXT_MENU = BASE_PROBE_NAME + "contextmenu";
|
||||
const SCALAR_ABOUT_NEWTAB = BASE_PROBE_NAME + "about_newtab";
|
||||
const SCALAR_ABOUT_ACTIVITYSTREAM = BASE_PROBE_NAME + "activitystream";
|
||||
|
||||
add_task(async function setup() {
|
||||
// Create two new search engines. Mark one as the default engine, so
|
||||
|
@ -90,14 +91,24 @@ add_task(async function test_context_menu() {
|
|||
});
|
||||
|
||||
add_task(async function test_about_newtab() {
|
||||
// Test newtab search event.
|
||||
const ACTIVITY_STREAM_ENABLED = Services.prefs.getBoolPref("browser.newtabpage.activity-stream.enabled");
|
||||
if (ACTIVITY_STREAM_ENABLED === true) {
|
||||
Services.prefs.setBoolPref("browser.newtabpage.activity-stream.enabled", false);
|
||||
}
|
||||
// Let's reset the counts.
|
||||
Services.telemetry.clearScalars();
|
||||
Services.telemetry.clearEvents();
|
||||
let search_hist = getAndClearKeyedHistogram("SEARCH_COUNTS");
|
||||
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:newtab", false);
|
||||
// browser.newtab.preload preloads a new tab before pref change actually happens.
|
||||
// We need to throw away the first tab we open because it will not be up to date.
|
||||
await BrowserTestUtils.removeTab(tab);
|
||||
tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:newtab", false);
|
||||
await ContentTask.spawn(tab.linkedBrowser, null, async function() {
|
||||
await ContentTaskUtils.waitForCondition(() => !content.document.hidden);
|
||||
await ContentTaskUtils.waitForCondition(() => content.document.querySelector("#newtab-search-text"));
|
||||
});
|
||||
|
||||
info("Trigger a simple serch, just text + enter.");
|
||||
|
@ -120,5 +131,55 @@ add_task(async function test_about_newtab() {
|
|||
events = (events.parent || []).filter(e => e[1] == "navigation" && e[2] == "search");
|
||||
checkEvents(events, [["navigation", "search", "about_newtab", "enter", {engine: "other-MozSearch"}]]);
|
||||
|
||||
Services.prefs.clearUserPref("browser.newtabpage.activity-stream.enabled");
|
||||
|
||||
await BrowserTestUtils.removeTab(tab);
|
||||
});
|
||||
|
||||
add_task(async function test_about_newtab_activitystream() {
|
||||
// Test activitystream search event.
|
||||
const ACTIVITY_STREAM_ENABLED = Services.prefs.getBoolPref("browser.newtabpage.activity-stream.enabled");
|
||||
if (ACTIVITY_STREAM_ENABLED === false) {
|
||||
Services.prefs.setBoolPref("browser.newtabpage.activity-stream.enabled", true);
|
||||
}
|
||||
// Let's reset the counts.
|
||||
Services.telemetry.clearScalars();
|
||||
Services.telemetry.clearEvents();
|
||||
let search_hist = getSearchCountsHistogram();
|
||||
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:newtab", false);
|
||||
// browser.newtab.preload preloads a new tab before pref change actually happens.
|
||||
// We need to throw away the first tab we open because it will not be up to date.
|
||||
await BrowserTestUtils.removeTab(tab);
|
||||
tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:newtab", false);
|
||||
await ContentTask.spawn(tab.linkedBrowser, null, async function() {
|
||||
await ContentTaskUtils.waitForCondition(() => !content.document.hidden);
|
||||
});
|
||||
|
||||
info("Trigger a simple serch, just text + enter.");
|
||||
let p = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
|
||||
await ContentTask.spawn(tab.linkedBrowser, null, async function() {
|
||||
await ContentTaskUtils.waitForCondition(() => content.document.querySelector("#newtab-search-text"));
|
||||
});
|
||||
await typeInSearchField(tab.linkedBrowser, "test query", "newtab-search-text");
|
||||
await BrowserTestUtils.synthesizeKey("VK_RETURN", {}, tab.linkedBrowser);
|
||||
await p;
|
||||
|
||||
// Check if the scalars contain the expected values.
|
||||
const scalars = getParentProcessScalars(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true, false);
|
||||
checkKeyedScalar(scalars, SCALAR_ABOUT_ACTIVITYSTREAM, "search_enter", 1);
|
||||
Assert.equal(Object.keys(scalars[SCALAR_ABOUT_ACTIVITYSTREAM]).length, 1,
|
||||
"This search must only increment one entry in the scalar.");
|
||||
|
||||
// Make sure SEARCH_COUNTS contains identical values.
|
||||
checkKeyedHistogram(search_hist, "other-MozSearch.activitystream", 1);
|
||||
|
||||
// Also check events.
|
||||
let events = Services.telemetry.snapshotBuiltinEvents(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, false);
|
||||
events = (events.parent || []).filter(e => e[1] == "navigation" && e[2] == "search");
|
||||
checkEvents(events, [["navigation", "search", "activitystream", "enter", {engine: "other-MozSearch"}]]);
|
||||
|
||||
Services.prefs.clearUserPref("browser.newtabpage.activity-stream.enabled");
|
||||
|
||||
await BrowserTestUtils.removeTab(tab);
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
navigation:
|
||||
search:
|
||||
objects: ["about_home", "about_newtab", "contextmenu", "oneoff",
|
||||
"suggestion", "alias", "enter", "searchbar", "urlbar"]
|
||||
"suggestion", "alias", "enter", "searchbar", "urlbar", "activitystream"]
|
||||
release_channel_collection: opt-out
|
||||
record_in_processes: ["main"]
|
||||
description: >
|
||||
|
|
|
@ -248,6 +248,20 @@ browser.engagement.navigation:
|
|||
record_in_processes:
|
||||
- 'main'
|
||||
|
||||
activitystream:
|
||||
bug_numbers:
|
||||
- 1381460
|
||||
description: >
|
||||
Count search events originating from Activity Stream. This is currently only tracking simple searches and saving them in the 'search_enter' key.
|
||||
expires: never
|
||||
kind: uint
|
||||
keyed: true
|
||||
notification_emails:
|
||||
- aoprea@mozilla.com
|
||||
release_channel_collection: opt-out
|
||||
record_in_processes:
|
||||
- 'main'
|
||||
|
||||
# The following section contains the browser usage scalars.
|
||||
browser.usage:
|
||||
graphite:
|
||||
|
|
Загрузка…
Ссылка в новой задаче