Backed out changeset 4a9917fd8fb6 (bug 1824253) for causing failures at browser_glean_telemetry_abandonment_groups.js. CLOSED TREE

This commit is contained in:
Butkovits Atila 2023-04-18 03:37:43 +03:00
Родитель c0b696292a
Коммит 4ec10a0b44
15 изменённых файлов: 291 добавлений и 48 удалений

Просмотреть файл

@ -538,6 +538,9 @@ pref("browser.urlbar.shortcuts.history", true);
pref("browser.urlbar.eventTelemetry.enabled", false);
// Whether search engagement telemetry should be recorded.
pref("browser.urlbar.searchEngagementTelemetry.enabled", false);
// When we send events to Urlbar extensions, we wait this amount of time in
// milliseconds for them to respond before timing out.
pref("browser.urlbar.extension.timeout", 400);

Просмотреть файл

@ -1167,8 +1167,10 @@ class TelemetryEvent {
`${method} event: ${JSON.stringify(eventInfo)}`
);
if (lazy.UrlbarPrefs.get("searchEngagementTelemetryEnabled")) {
Glean.urlbar[method].record(eventInfo);
}
}
#getInteractionType(
method,
@ -1346,18 +1348,33 @@ class TelemetryEvent {
};
#beginObservingPingPrefs() {
for (const p of Object.keys(this.#PING_PREFS)) {
this.onPrefChanged(p);
}
this.onPrefChanged("searchEngagementTelemetry.enabled");
lazy.UrlbarPrefs.addObserver(this);
}
onPrefChanged(pref) {
if (pref === "searchEngagementTelemetry.enabled") {
for (const p of Object.keys(this.#PING_PREFS)) {
this.onPrefChanged(p);
}
return;
}
if (!lazy.UrlbarPrefs.get("searchEngagementTelemetryEnabled")) {
return;
}
const metric = this.#PING_PREFS[pref];
if (metric) {
metric.set(lazy.UrlbarPrefs.get(pref));
}
}
onNimbusChanged(variable) {
if (variable === "searchEngagementTelemetryEnabled") {
this.onPrefChanged("searchEngagementTelemetry.enabled");
}
}
#previousSearchWordsSet = null;
}

Просмотреть файл

@ -129,6 +129,10 @@ const PREF_URLBAR_DEFAULTS = new Map([
// Applies URL highlighting and other styling to the text in the urlbar input.
["formatting.enabled", true],
// Whether search engagement telemetry should be recorded. This pref is a
// fallback for the Nimbus variable `searchEngagementTelemetryEnabled`.
["searchEngagementTelemetry.enabled", false],
// Interval time until taking pause impression telemetry.
["searchEngagementTelemetry.pauseImpressionIntervalMs", 1000],

Просмотреть файл

@ -12,7 +12,6 @@ $tags:
urlbar:
abandonment:
disabled: true
type: event
description: Recorded when the user abandons a search (blurring the urlbar).
extra_keys:
@ -130,7 +129,6 @@ urlbar:
- fx-search-telemetry@mozilla.com
expires: never
engagement:
disabled: true
type: event
description: Recorded when the user executes an action on a result.
extra_keys:
@ -325,7 +323,6 @@ urlbar:
- fx-search-telemetry@mozilla.com
expires: never
impression:
disabled: true
type: event
description: Recorded when urlbar results are shown to the user.
extra_keys:

Просмотреть файл

@ -8,6 +8,7 @@ support-files =
head-groups.js
head-interaction.js
head-n_chars_n_words.js
head-preferences.js
head-sap.js
head-search_mode.js
../../browser-tips/head.js
@ -22,6 +23,7 @@ skip-if =
[browser_glean_telemetry_abandonment_interaction_persisted_search_terms_disabled.js]
[browser_glean_telemetry_abandonment_interaction_persisted_search_terms_enabled.js]
[browser_glean_telemetry_abandonment_n_chars_n_words.js]
[browser_glean_telemetry_abandonment_preferences.js]
[browser_glean_telemetry_abandonment_sap.js]
[browser_glean_telemetry_abandonment_search_mode.js]
[browser_glean_telemetry_abandonment_tips.js]
@ -31,6 +33,7 @@ skip-if =
[browser_glean_telemetry_engagement_interaction_persisted_search_terms_disabled.js]
[browser_glean_telemetry_engagement_interaction_persisted_search_terms_enabled.js]
[browser_glean_telemetry_engagement_n_chars_n_words.js]
[browser_glean_telemetry_engagement_preferences.js]
[browser_glean_telemetry_engagement_sap.js]
[browser_glean_telemetry_engagement_search_mode.js]
[browser_glean_telemetry_engagement_selected_result.js]

Просмотреть файл

@ -0,0 +1,42 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test the Glean telemetry behavior with its preferences.
add_setup(async function() {
await initPreferencesTest();
});
add_task(async function enabled() {
await doSearchEngagementTelemetryTest({
enabled: true,
trigger: () => doBlur(),
assert: () => assertAbandonmentTelemetry([{ sap: "urlbar_newtab" }]),
});
});
add_task(async function disabled() {
await doSearchEngagementTelemetryTest({
enabled: false,
trigger: () => doBlur(),
assert: () => assertAbandonmentTelemetry([]),
});
});
add_task(async function nimbusEnabled() {
await doNimbusTest({
enabled: true,
trigger: () => doBlur(),
assert: () => assertAbandonmentTelemetry([{ sap: "urlbar_newtab" }]),
});
});
add_task(async function nimbusDisabled() {
await doNimbusTest({
enabled: false,
trigger: () => doBlur(),
assert: () => assertAbandonmentTelemetry([]),
});
});

Просмотреть файл

@ -11,12 +11,9 @@ Services.scriptloader.loadSubScript(
);
add_setup(async function() {
Services.fog.setMetricsFeatureConfig(
JSON.stringify({ "urlbar.abandonment": false })
);
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.searchEngagementTelemetry.enabled", true],
["browser.urlbar.searchTips.test.ignoreShowLimits", true],
["browser.urlbar.showSearchTerms.featureGate", true],
],
@ -33,7 +30,6 @@ add_setup(async function() {
await Services.search.moveEngine(engine, 0);
registerCleanupFunction(async function() {
Services.fog.setMetricsFeatureConfig("{}");
await SpecialPowers.popPrefEnv();
await Services.search.setDefault(
originalDefaultEngine,

Просмотреть файл

@ -0,0 +1,42 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test the Glean telemetry behavior with its preferences.
add_setup(async function() {
await initPreferencesTest();
});
add_task(async function enabled() {
await doSearchEngagementTelemetryTest({
enabled: true,
trigger: () => doEnter(),
assert: () => assertEngagementTelemetry([{ sap: "urlbar_newtab" }]),
});
});
add_task(async function disabled() {
await doSearchEngagementTelemetryTest({
enabled: false,
trigger: () => doEnter(),
assert: () => assertEngagementTelemetry([]),
});
});
add_task(async function nimbusEnabled() {
await doNimbusTest({
enabled: true,
trigger: () => doEnter(),
assert: () => assertEngagementTelemetry([{ sap: "urlbar_newtab" }]),
});
});
add_task(async function nimbusDisabled() {
await doNimbusTest({
enabled: false,
trigger: () => doEnter(),
assert: () => assertEngagementTelemetry([]),
});
});

Просмотреть файл

@ -17,15 +17,13 @@ ChromeUtils.defineESModuleGetters(this, {
add_setup(async function() {
makeProfileResettable();
Services.fog.setMetricsFeatureConfig(
JSON.stringify({ "urlbar.engagement": false })
);
await SpecialPowers.pushPrefEnv({
set: [["browser.urlbar.quickactions.enabled", false]],
set: [
["browser.urlbar.searchEngagementTelemetry.enabled", true],
["browser.urlbar.quickactions.enabled", false],
],
});
registerCleanupFunction(async function() {
Services.fog.setMetricsFeatureConfig("{}");
await SpecialPowers.popPrefEnv();
});
});

Просмотреть файл

@ -6,7 +6,41 @@
// Test the impression telemetry behavior with its preferences.
add_setup(async function() {
await setup();
await initPreferencesTest();
});
add_task(async function enabled() {
await doSearchEngagementTelemetryTest({
enabled: true,
trigger: () => waitForPauseImpression(),
assert: () =>
assertImpressionTelemetry([{ reason: "pause", sap: "urlbar_newtab" }]),
});
});
add_task(async function disabled() {
await doSearchEngagementTelemetryTest({
enabled: false,
trigger: () => waitForPauseImpression(),
assert: () => assertImpressionTelemetry([]),
});
});
add_task(async function nimbusEnabled() {
await doNimbusTest({
enabled: true,
trigger: () => waitForPauseImpression(),
assert: () =>
assertImpressionTelemetry([{ reason: "pause", sap: "urlbar_newtab" }]),
});
});
add_task(async function nimbusDisabled() {
await doNimbusTest({
enabled: false,
trigger: () => waitForPauseImpression(),
assert: () => assertImpressionTelemetry([]),
});
});
add_task(async function pauseImpressionIntervalMs() {
@ -16,6 +50,7 @@ add_task(async function pauseImpressionIntervalMs() {
);
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.searchEngagementTelemetry.enabled", true],
[
"browser.urlbar.searchEngagementTelemetry.pauseImpressionIntervalMs",
originalInterval + additionalInterval,

Просмотреть файл

@ -6,18 +6,22 @@
// Test for preference telemetry.
add_setup(async function() {
// Simulate initialization for TelemetryEvent.
// 1. Turn browser.urlbar.searchEngagementTelemetry.enabled on.
// 2. Remove all Glean data.
// 3. Call onPrefChanged() that will be called from TelemetryEvent constructor.
await SpecialPowers.pushPrefEnv({
set: [["browser.urlbar.searchEngagementTelemetry.enabled", true]],
});
await Services.fog.testFlushAllChildren();
Services.fog.testResetFOG();
// Create a new window in order to initialize TelemetryEvent of
// UrlbarController.
const win = await BrowserTestUtils.openNewBrowserWindow();
registerCleanupFunction(async function() {
await BrowserTestUtils.closeWindow(win);
});
gURLBar.controller.engagementEvent.onPrefChanged(
"searchEngagementTelemetry.enabled"
);
});
add_task(async function prefMaxRichResults() {
Assert.ok(UrlbarPrefs.get("maxRichResults"), "Sanity check");
Assert.equal(
Glean.urlbar.prefMaxResults.testGetValue(),
UrlbarPrefs.get("maxRichResults"),
@ -52,3 +56,66 @@ add_task(async function prefSuggestTopsites() {
"Record prefSuggestTopsites when the suggest.topsites pref is updated"
);
});
add_task(async function searchEngagementTelemetryEnabled() {
info("Disable search engagement telemetry");
await SpecialPowers.pushPrefEnv({
set: [["browser.urlbar.searchEngagementTelemetry.enabled", false]],
});
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.suggest.topsites", !UrlbarPrefs.get("suggest.topsites")],
["browser.urlbar.maxRichResults", 100],
],
});
Assert.notEqual(
Glean.urlbar.prefMaxResults.testGetValue(),
UrlbarPrefs.get("maxRichResults"),
"Did not record prefMaxResults"
);
Assert.notEqual(
Glean.urlbar.prefSuggestTopsites.testGetValue(),
UrlbarPrefs.get("suggest.topsites"),
"Did not record prefSuggestTopsites"
);
info("Enable search engagement telemetry");
await SpecialPowers.pushPrefEnv({
set: [["browser.urlbar.searchEngagementTelemetry.enabled", true]],
});
Assert.equal(
Glean.urlbar.prefMaxResults.testGetValue(),
UrlbarPrefs.get("maxRichResults"),
"Update prefMaxResults when search engagement telemetry is enabled"
);
Assert.equal(
Glean.urlbar.prefSuggestTopsites.testGetValue(),
UrlbarPrefs.get("suggest.topsites"),
"Update prefSuggestTopsites when search engagement telemetry is enabled"
);
});
add_task(async function nimbusSearchEngagementTelemetryEnabled() {
info("Disable search engagement telemetry");
await SpecialPowers.pushPrefEnv({
set: [["browser.urlbar.searchEngagementTelemetry.enabled", false]],
});
info("Enable search engagement telemetry from Nimbus");
// eslint-disable-next-line mozilla/valid-lazy
const doCleanup = await lazy.UrlbarTestUtils.initNimbusFeature({
searchEngagementTelemetryEnabled: true,
});
Assert.equal(
Glean.urlbar.prefMaxResults.testGetValue(),
UrlbarPrefs.get("maxRichResults"),
"Update prefMaxResults when search engagement telemetry is enabled"
);
Assert.equal(
Glean.urlbar.prefSuggestTopsites.testGetValue(),
UrlbarPrefs.get("suggest.topsites"),
"Update prefSuggestTopsites when search engagement telemetry is enabled"
);
doCleanup();
});

Просмотреть файл

@ -0,0 +1,36 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/* import-globals-from head.js */
async function doSearchEngagementTelemetryTest({ trigger, assert, enabled }) {
await SpecialPowers.pushPrefEnv({
set: [["browser.urlbar.searchEngagementTelemetry.enabled", enabled]],
});
await doTest(async browser => {
await openPopup("https://example.com");
await trigger();
await assert();
});
await SpecialPowers.popPrefEnv();
}
async function doNimbusTest({ trigger, assert, enabled }) {
const doCleanup = await setupNimbus({
searchEngagementTelemetryEnabled: enabled,
});
await doTest(async browser => {
await openPopup("https://example.com");
await trigger();
await assert();
});
doCleanup();
}

Просмотреть файл

@ -179,15 +179,6 @@ async function doPasteAndGo(data) {
async function doTest(testFn) {
await Services.fog.testFlushAllChildren();
Services.fog.testResetFOG();
// Enable recording telemetry for abandonment, engagement and impression.
Services.fog.setMetricsFeatureConfig(
JSON.stringify({
"urlbar.abandonment": false,
"urlbar.engagement": false,
"urlbar.impression": false,
})
);
gURLBar.controller.engagementEvent.reset();
await PlacesUtils.history.clear();
await PlacesUtils.bookmarks.eraseEverything();
@ -198,11 +189,7 @@ async function doTest(testFn) {
await QuickSuggest.blockedSuggestions._test_readyPromise;
await updateTopSites(() => true);
try {
await BrowserTestUtils.withNewTab(gBrowser, testFn);
} finally {
Services.fog.setMetricsFeatureConfig("{}");
}
}
async function initGroupTest() {
@ -232,6 +219,15 @@ async function initNCharsAndNWordsTest() {
await setup();
}
async function initPreferencesTest() {
/* import-globals-from head-preferences.js */
Services.scriptloader.loadSubScript(
"chrome://mochitests/content/browser/browser/components/urlbar/tests/engagementTelemetry/browser/head-preferences.js",
this
);
await setup();
}
async function initSapTest() {
/* import-globals-from head-sap.js */
Services.scriptloader.loadSubScript(

Просмотреть файл

@ -358,7 +358,7 @@ add_task(function initializeShowSearchSuggestionsFirstPref() {
// Tests whether observer.onNimbusChanged works.
add_task(async function onNimbusChanged() {
Services.prefs.setBoolPref(
"browser.urlbar.autoFill.adaptiveHistory.enabled",
"browser.urlbar.searchEngagementTelemetry.enabled",
false
);
@ -387,11 +387,11 @@ add_task(async function onNimbusChanged() {
UrlbarPrefs.addObserver(observer);
const doCleanup = await UrlbarTestUtils.initNimbusFeature({
autoFillAdaptiveHistoryEnabled: true,
searchEngagementTelemetryEnabled: true,
});
Assert.equal(observer.prefChangedList.length, 0);
Assert.ok(
observer.nimbusChangedList.includes("autoFillAdaptiveHistoryEnabled")
observer.nimbusChangedList.includes("searchEngagementTelemetryEnabled")
);
doCleanup();
});
@ -399,10 +399,10 @@ add_task(async function onNimbusChanged() {
// Tests whether observer.onPrefChanged works.
add_task(async function onPrefChanged() {
const doCleanup = await UrlbarTestUtils.initNimbusFeature({
autoFillAdaptiveHistoryEnabled: false,
searchEngagementTelemetryEnabled: false,
});
Services.prefs.setBoolPref(
"browser.urlbar.autoFill.adaptiveHistory.enabled",
"browser.urlbar.searchEngagementTelemetry.enabled",
false
);
@ -434,16 +434,19 @@ add_task(async function onPrefChanged() {
UrlbarPrefs.addObserver(observer);
Services.prefs.setBoolPref(
"browser.urlbar.autoFill.adaptiveHistory.enabled",
"browser.urlbar.searchEngagementTelemetry.enabled",
true
);
await deferred.promise;
Assert.equal(observer.prefChangedList.length, 1);
Assert.equal(observer.prefChangedList[0], "autoFill.adaptiveHistory.enabled");
Assert.equal(
observer.prefChangedList[0],
"searchEngagementTelemetry.enabled"
);
Assert.equal(observer.nimbusChangedList.length, 0);
Services.prefs.clearUserPref(
"browser.urlbar.autoFill.adaptiveHistory.enabled"
"browser.urlbar.searchEngagementTelemetry.enabled"
);
doCleanup();
});

Просмотреть файл

@ -222,6 +222,10 @@ urlbar:
type: boolean
setPref: browser.urlbar.resultMenu
description: Enable the per-result three-dot menu with options such as Dismiss and Learn More.
searchEngagementTelemetryEnabled:
type: boolean
fallbackPref: browser.urlbar.searchEngagementTelemetry.enabled
description: Whether search engagement telemetry should be enabled.
showSearchTermsFeatureGate:
type: boolean
fallbackPref: browser.urlbar.showSearchTerms.featureGate