Backed out 2 changesets (bug 1693927, bug 1693126) for failures on browser_urlbar_telemetry_quicksuggest.js. CLOSED TREE

Backed out changeset 681c90aa832e (bug 1693126)
Backed out changeset 7525ec04b82a (bug 1693927)
This commit is contained in:
Csoregi Natalia 2021-02-24 22:00:43 +02:00
parent 8b20784ab6
commit e50ad13694
8 changed files with 23 additions and 522 deletions

View File

@ -899,10 +899,11 @@ class TelemetryEvent {
let row = element.closest(".urlbarView-row");
if (row.result && row.result.providerName != "UrlbarProviderTopSites") {
// Element handlers go here.
if (element.classList.contains("urlbarView-help")) {
return row.result.type == UrlbarUtils.RESULT_TYPE.TIP
? "tiphelp"
: "help";
if (
row.result.type == UrlbarUtils.RESULT_TYPE.TIP &&
element.classList.contains("urlbarView-help")
) {
return "tiphelp";
}
}
// Now handle the result.

View File

@ -11,7 +11,6 @@ const { XPCOMUtils } = ChromeUtils.import(
);
XPCOMUtils.defineLazyModuleGetters(this, {
Services: "resource://gre/modules/Services.jsm",
UrlbarPrefs: "resource:///modules/UrlbarPrefs.jsm",
UrlbarQuickSuggest: "resource:///modules/UrlbarQuickSuggest.jsm",
UrlbarProvider: "resource:///modules/UrlbarUtils.jsm",
@ -19,9 +18,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
UrlbarUtils: "resource:///modules/UrlbarUtils.jsm",
});
// These prefs are relative to the `browser.urlbar` branch.
const EXPERIMENT_PREF = "quicksuggest.enabled";
const SUGGEST_PREF = "suggest.quicksuggest";
const ONBOARDING_COUNT_PREF = "quicksuggest.onboardingCount";
const ONBOARDING_MAX_COUNT_PREF = "quicksuggest.onboardingMaxCount";
@ -29,23 +25,13 @@ const ONBOARDING_MAX_COUNT_PREF = "quicksuggest.onboardingMaxCount";
const ONBOARDING_URL = "https://mozilla.org/";
const ONBOARDING_TEXT = "Learn more about Firefox Suggests";
const TELEMETRY_SCALAR_IMPRESSION =
"contextual.services.quicksuggest.impression";
const TELEMETRY_SCALAR_CLICK = "contextual.services.quicksuggest.click";
const TELEMETRY_SCALAR_HELP = "contextual.services.quicksuggest.help";
const TELEMETRY_EVENT_CATEGORY = "contextservices.quicksuggest";
/**
* A provider that returns a suggested url to the user based on what
* they have currently typed so they can navigate directly.
*/
class ProviderQuickSuggest extends UrlbarProvider {
constructor(...args) {
super(...args);
this._updateExperimentState();
UrlbarPrefs.addObserver(this);
}
// Whether we added a result during the most recent query.
_addedResultInLastQuery = false;
/**
* Returns the name of this provider.
@ -84,8 +70,8 @@ class ProviderQuickSuggest extends UrlbarProvider {
return (
queryContext.trimmedSearchString &&
!queryContext.searchMode &&
UrlbarPrefs.get(EXPERIMENT_PREF) &&
UrlbarPrefs.get(SUGGEST_PREF) &&
UrlbarPrefs.get("quicksuggest.enabled") &&
UrlbarPrefs.get("suggest.quicksuggest") &&
UrlbarPrefs.get("suggest.searches") &&
UrlbarPrefs.get("browser.search.suggest.enabled") &&
(!queryContext.isPrivate ||
@ -153,91 +139,16 @@ class ProviderQuickSuggest extends UrlbarProvider {
* it describes the search string and picked result.
*/
onEngagement(isPrivate, state, queryContext, details) {
if (!this._addedResultInLastQuery) {
return;
}
this._addedResultInLastQuery = false;
// Per spec, we update the onboarding count and telemetry only when the user
// picks a result, i.e., when `state` is "engagement".
if (state != "engagement") {
return;
}
// Get the index of the quick suggest result.
let resultIndex = queryContext.results.length - 1;
let lastResult = queryContext.results[resultIndex];
if (!lastResult?.payload.isSponsored) {
Cu.reportError(`Last result is not a quick suggest`);
return;
}
// Increment the onboarding count.
if (this._onboardingCount < this._onboardingMaxCount) {
if (
state == "engagement" &&
this._addedResultInLastQuery &&
this._onboardingCount < this._onboardingMaxCount
) {
this._onboardingCount++;
}
// Record telemetry. We want to record the 1-based index of the result, so
// add 1 to the 0-based resultIndex.
let telemetryResultIndex = resultIndex + 1;
// impression scalar
Services.telemetry.keyedScalarAdd(
TELEMETRY_SCALAR_IMPRESSION,
telemetryResultIndex,
1
);
if (details.selIndex == resultIndex) {
// click or help scalar
Services.telemetry.keyedScalarAdd(
details.selType == "help"
? TELEMETRY_SCALAR_HELP
: TELEMETRY_SCALAR_CLICK,
telemetryResultIndex,
1
);
}
this._addedResultInLastQuery = false;
}
/**
* Called when a urlbar pref changes. We use this to listen for changes to
* `browser.urlbar.suggest.quicksuggest` so we can record a telemetry event.
* We also need to listen for `browser.urlbar.quicksuggest.enabled` so we can
* enable/disable the event telemetry.
*
* @param {string} pref
* The name of the pref relative to `browser.urlbar`.
*/
onPrefChanged(pref) {
switch (pref) {
case EXPERIMENT_PREF:
this._updateExperimentState();
break;
case SUGGEST_PREF:
Services.telemetry.recordEvent(
TELEMETRY_EVENT_CATEGORY,
"enable_toggled",
UrlbarPrefs.get(SUGGEST_PREF) ? "enabled" : "disabled"
);
break;
}
}
/**
* Updates state based on the `browser.urlbar.quicksuggest.enabled` pref.
* Right now we only need to enable/disable event telemetry.
*/
_updateExperimentState() {
Services.telemetry.setEventRecordingEnabled(
TELEMETRY_EVENT_CATEGORY,
UrlbarPrefs.get(EXPERIMENT_PREF)
);
}
// Whether we added a result during the most recent query.
_addedResultInLastQuery = false;
get _onboardingCount() {
return UrlbarPrefs.get(ONBOARDING_COUNT_PREF);
}

View File

@ -337,7 +337,7 @@ Event Extra
``history``, ``keyword``, ``searchengine``, ``searchsuggestion``,
``switchtab``, ``remotetab``, ``extension``, ``oneoff``, ``keywordoffer``,
``canonized``, ``tip``, ``tiphelp``, ``formhistory``, ``tabtosearch``,
``help``, ``unknown``
``unknown``
In practice, ``tabtosearch`` should not appear in real event telemetry.
Opening a tab-to-search result enters search mode and entering search mode
does not currently mark the end of an engagement. It is noted here for
@ -413,8 +413,8 @@ TopSites Click
User's current locale.
Other telemetry relevant to the Address Bar
-------------------------------------------
Search probes relevant to the Address Bar
-----------------------------------------
SEARCH_COUNTS
This histogram tracks search engines and Search Access Points. It is augmented
@ -484,47 +484,6 @@ contextual.services.topsites.*
impression or click.
Note that these scalars are shared with the TopSites on the newtab page.
contextual.services.quicksuggest.*
These keyed scalars record impressions and clicks on Quick Suggest results,
also called Firefox Suggests results, in the address bar. The keys for each
scalar are the 1-based indexes of the Quick Suggest results, and the values
are the number of impressions or clicks for the corresponding indexes. For
example, for a Quick Suggest impression at 0-based index 9, the value for key
`10` will be incremented in the `contextual.services.quicksuggest.impression`
scalar.
The keyed scalars are:
- ``contextual.services.quicksuggest.impression``
Incremented when a Quick Suggest result is shown in an address bar
engagement where the user picks any result. The particular picked result
doesn't matter, and it doesn't need to be the Quick Suggest result.
- ``contextual.services.quicksuggest.click``
Incremented when the user picks a Quick Suggest result (not including the
help button).
- ``contextual.services.quicksuggest.help``
Incremented when the user picks the onboarding help button in a Quick
Suggest result.
contextservices.quicksuggest
This is event telemetry under the ``contextservices.quicksuggest`` category.
It's enabled only when the ``browser.urlbar.quicksuggest.enabled`` pref is
true. An event is recorded when the user toggles the
``browser.urlbar.suggest.quicksuggest`` pref, which corresponds to the
checkbox in about:preferences#search labeled "Show suggested and sponsored
results in the address bar". If the user never toggles the pref, then this
event is never recorded.
The full spec for this event is:
- Category: ``contextservices.quicksuggest``
- Method: ``enable_toggled``
- Objects: ``enabled``, ``disabled`` -- ``enabled`` is recorded when the
pref is flipped from false to true, and ``disabled`` is recorded when the
pref is flipped from true to false.
- Value: Not used
- Extra: Not used
Obsolete probes
---------------

View File

@ -263,8 +263,6 @@ support-files =
tags = search-telemetry
[browser_urlbar_telemetry_places.js]
tags = search-telemetry
[browser_urlbar_telemetry_quicksuggest.js]
tags = search-telemetry
[browser_urlbar_telemetry_remotetab.js]
tags = search-telemetry
[browser_urlbar_telemetry_searchmode.js]

View File

@ -52,6 +52,11 @@ async function assertIsQuickSuggest(index = -1) {
let result = await UrlbarTestUtils.getDetailsOfResultAt(window, index);
Assert.equal(result.type, UrlbarUtils.RESULT_TYPE.URL);
Assert.equal(result.url, `${TEST_URL}?q=frabbits`);
if (result.url != `${TEST_URL}?q=frabbits`) {
await new Promise(r => {});
}
return result;
}

View File

@ -1,304 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* This file tests urlbar telemetry for Quick Suggest results.
*/
"use strict";
XPCOMUtils.defineLazyModuleGetters(this, {
UrlbarQuickSuggest: "resource:///modules/UrlbarQuickSuggest.jsm",
});
const TEST_SJS =
"http://mochi.test:8888/browser/browser/components/urlbar/tests/browser/quicksuggest.sjs";
const TEST_URL = TEST_SJS + "?q=frabbits";
const TEST_SEARCH_STRING = "frab";
const TEST_DATA = [
{
id: 1,
url: TEST_URL,
title: "frabbits",
keywords: [TEST_SEARCH_STRING],
},
];
const TELEMETRY_SCALARS = {
IMPRESSION: "contextual.services.quicksuggest.impression",
CLICK: "contextual.services.quicksuggest.click",
HELP: "contextual.services.quicksuggest.help",
};
const TELEMETRY_EVENT_CATEGORY = "contextservices.quicksuggest";
const EXPERIMENT_PREF = "browser.urlbar.quicksuggest.enabled";
const SUGGEST_PREF = "suggest.quicksuggest";
const ONBOARDING_COUNT_PREF = "quicksuggest.onboardingCount";
add_task(async function init() {
await PlacesUtils.history.clear();
await UrlbarTestUtils.formHistory.clear();
await SpecialPowers.pushPrefEnv({
set: [
[EXPERIMENT_PREF, true],
["browser.urlbar.suggest.searches", true],
],
});
// Add a mock engine so we don't hit the network.
let engine = await Services.search.addEngineWithDetails("Test", {
template: "http://example.com/?search={searchTerms}",
});
let oldDefaultEngine = await Services.search.getDefault();
Services.search.setDefault(engine);
// Set up Quick Suggest.
await UrlbarQuickSuggest.init();
await UrlbarQuickSuggest._processSuggestionsJSON(TEST_DATA);
Services.telemetry.clearScalars();
registerCleanupFunction(async () => {
Services.search.setDefault(oldDefaultEngine);
await Services.search.removeEngine(engine);
});
});
// Tests the impression scalar.
add_task(async function impression() {
await BrowserTestUtils.withNewTab("about:blank", async () => {
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: TEST_SEARCH_STRING,
fireInputEvent: true,
});
let index = 1;
await assertIsQuickSuggest(index);
await UrlbarTestUtils.promisePopupClose(window, () => {
EventUtils.synthesizeKey("KEY_Enter");
});
assertScalars({ [TELEMETRY_SCALARS.IMPRESSION]: index + 1 });
Services.telemetry.clearScalars();
});
});
// Makes sure the impression scalar is not incremented when the urlbar
// engagement is abandoned.
add_task(async function noImpression_abandonment() {
await BrowserTestUtils.withNewTab("about:blank", async () => {
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: TEST_SEARCH_STRING,
fireInputEvent: true,
});
await assertIsQuickSuggest();
await UrlbarTestUtils.promisePopupClose(window, () => {
gURLBar.blur();
});
assertScalars({});
});
});
// Makes sure the impression scalar is not incremented when a Quick Suggest
// result is not present.
add_task(async function noImpression_noQuickSuggestResult() {
await BrowserTestUtils.withNewTab("about:blank", async () => {
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: "noImpression_noQuickSuggestResult",
fireInputEvent: true,
});
await assertNoQuickSuggestResults();
await UrlbarTestUtils.promisePopupClose(window, () => {
EventUtils.synthesizeKey("KEY_Enter");
});
assertScalars({});
});
});
// Tests the click scalar by picking a Quick Suggest result with the keyboard.
add_task(async function click_keyboard() {
await BrowserTestUtils.withNewTab("about:blank", async () => {
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: TEST_SEARCH_STRING,
fireInputEvent: true,
});
let index = 1;
await assertIsQuickSuggest(index);
await UrlbarTestUtils.promisePopupClose(window, () => {
EventUtils.synthesizeKey("KEY_ArrowDown");
EventUtils.synthesizeKey("KEY_Enter");
});
assertScalars({
[TELEMETRY_SCALARS.IMPRESSION]: index + 1,
[TELEMETRY_SCALARS.CLICK]: index + 1,
});
Services.telemetry.clearScalars();
});
});
// Tests the click scalar by picking a Quick Suggest result with the mouse.
add_task(async function click_mouse() {
await BrowserTestUtils.withNewTab("about:blank", async () => {
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: TEST_SEARCH_STRING,
fireInputEvent: true,
});
let index = 1;
let result = await assertIsQuickSuggest(index);
await UrlbarTestUtils.promisePopupClose(window, () => {
EventUtils.synthesizeMouseAtCenter(result.element.row, {});
});
assertScalars({
[TELEMETRY_SCALARS.IMPRESSION]: index + 1,
[TELEMETRY_SCALARS.CLICK]: index + 1,
});
Services.telemetry.clearScalars();
});
});
// Tests the help scalar by picking a Quick Suggest result help button with the
// keyboard.
add_task(async function help_keyboard() {
Services.prefs.clearUserPref(ONBOARDING_COUNT_PREF);
await BrowserTestUtils.withNewTab("about:blank", async () => {
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: TEST_SEARCH_STRING,
fireInputEvent: true,
});
let index = 1;
let result = await assertIsQuickSuggest(index);
let helpButton = result.element.row._elements.get("helpButton");
Assert.ok(helpButton, "The result has an onboarding help button");
await UrlbarTestUtils.promisePopupClose(window, () => {
EventUtils.synthesizeKey("KEY_ArrowDown", { repeat: 2 });
EventUtils.synthesizeKey("KEY_Enter");
});
assertScalars({
[TELEMETRY_SCALARS.IMPRESSION]: index + 1,
[TELEMETRY_SCALARS.HELP]: index + 1,
});
Services.telemetry.clearScalars();
});
});
// Tests the help scalar by picking a Quick Suggest result help button with the
// mouse.
add_task(async function help_mouse() {
Services.prefs.clearUserPref(ONBOARDING_COUNT_PREF);
await BrowserTestUtils.withNewTab("about:blank", async () => {
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: TEST_SEARCH_STRING,
fireInputEvent: true,
});
let index = 1;
let result = await assertIsQuickSuggest(index);
let helpButton = result.element.row._elements.get("helpButton");
Assert.ok(helpButton, "The result has an onboarding help button");
await UrlbarTestUtils.promisePopupClose(window, () => {
EventUtils.synthesizeMouseAtCenter(helpButton, {});
});
assertScalars({
[TELEMETRY_SCALARS.IMPRESSION]: index + 1,
[TELEMETRY_SCALARS.HELP]: index + 1,
});
Services.telemetry.clearScalars();
});
});
// Tests the contextservices.quicksuggest enable_toggled event telemetry by
// toggling the suggest.quicksuggest pref.
add_task(async function enableToggled() {
Services.telemetry.clearEvents();
// Toggle the suggest.quicksuggest pref twice. We should get two events.
let enabled = UrlbarPrefs.get(SUGGEST_PREF);
for (let i = 0; i < 2; i++) {
enabled = !enabled;
UrlbarPrefs.set(SUGGEST_PREF, enabled);
TelemetryTestUtils.assertEvents([
{
category: TELEMETRY_EVENT_CATEGORY,
method: "enable_toggled",
object: enabled ? "enabled" : "disabled",
},
]);
}
// Set the main quicksuggest.enabled pref to false and toggle the
// suggest.quicksuggest pref again. We shouldn't get any events.
await SpecialPowers.pushPrefEnv({
set: [[EXPERIMENT_PREF, false]],
});
enabled = !enabled;
UrlbarPrefs.set(SUGGEST_PREF, enabled);
TelemetryTestUtils.assertEvents([], { category: TELEMETRY_EVENT_CATEGORY });
await SpecialPowers.popPrefEnv();
UrlbarPrefs.clear(SUGGEST_PREF);
});
/**
* Checks the values of all the Quick Suggest scalars.
*
* @param {object} expectedIndexesByScalarName
* Maps scalar names to the expected 1-based indexes of results. If you
* expect a scalar to be incremented, then include it in this object. If you
* expect a scalar not to be incremented, don't include it.
*/
function assertScalars(expectedIndexesByScalarName) {
let scalars = TelemetryTestUtils.getProcessScalars("parent", true, true);
for (let scalarName of Object.values(TELEMETRY_SCALARS)) {
if (scalarName in expectedIndexesByScalarName) {
TelemetryTestUtils.assertKeyedScalar(
scalars,
scalarName,
expectedIndexesByScalarName[scalarName],
1
);
} else {
Assert.ok(
!(scalarName in scalars),
"Scalar should not be present: " + scalarName
);
}
}
}
/**
* Asserts that a result is a Quick Suggest result.
*
* @param {number} [index]
* The expected index of the Quick Suggest result. Pass -1 to use the index
* of the last result.
* @returns {result}
* The result at the given index.
*/
async function assertIsQuickSuggest(index = -1) {
if (index < 0) {
index = UrlbarTestUtils.getResultCount(window) - 1;
Assert.greater(index, -1, "Sanity check: Result count should be > 0");
}
let result = await UrlbarTestUtils.getDetailsOfResultAt(window, index);
Assert.equal(result.type, UrlbarUtils.RESULT_TYPE.URL);
Assert.equal(result.url, TEST_URL);
return result;
}
/**
* Asserts that none of the results are Quick Suggest results.
*/
async function assertNoQuickSuggestResults() {
for (let i = 0; i < UrlbarTestUtils.getResultCount(window); i++) {
let r = await UrlbarTestUtils.getDetailsOfResultAt(window, i);
Assert.ok(
r.type != UrlbarUtils.RESULT_TYPE.URL || !r.url.includes(TEST_URL),
`Result at index ${i} should not be a QuickSuggest result`
);
}
}

View File

@ -2720,18 +2720,3 @@ installation:
- agashlin@mozilla.com
- rtestard@mozilla.com
expiry_version: "94"
contextservices.quicksuggest:
enable_toggled:
objects: ["enabled", "disabled"]
release_channel_collection: opt-out
products:
- "firefox"
record_in_processes: ["main"]
description: >
This is recorded when the `browser.urlbar.suggest.quicksuggest` boolean
pref is toggled.
bug_numbers: [1693126]
notification_emails:
- fx-search@mozilla.com
expiry_version: never

View File

@ -6719,60 +6719,6 @@ contextual.services.topsites:
- main
contextual.services.quicksuggest:
impression:
bug_numbers:
- 1693927
description: >
A keyed uint recording how many times the user has viewed Firefox Suggests
(a.k.a. Quick Suggest) results in the urlbar. The key is the 1-based index
of each result.
expires: never
kind: uint
keyed: true
notification_emails:
- najiang@mozilla.com
release_channel_collection: opt-out
products:
- 'firefox'
record_in_processes:
- main
click:
bug_numbers:
- 1693927
description: >
A keyed uint recording how many times the user has clicked on Firefox
Suggests (a.k.a. Quick Suggest) results in the urlbar (not including the
help button). The key is the 1-based index of each result.
expires: never
kind: uint
keyed: true
notification_emails:
- najiang@mozilla.com
release_channel_collection: opt-out
products:
- 'firefox'
record_in_processes:
- main
help:
bug_numbers:
- 1693927
description: >
A keyed uint recording how many times the user has clicked on the help
button in Firefox Suggests (a.k.a. Quick Suggest) results in the urlbar.
The key is the 1-based index of each result.
expires: never
kind: uint
keyed: true
notification_emails:
- najiang@mozilla.com
release_channel_collection: opt-out
products:
- 'firefox'
record_in_processes:
- main
# The following section is for probes testing the Telemetry system. They will not be
# submitted in pings and are only used for testing.
telemetry.test: