зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 7d610bc570cd (bug 1813162) as requested by the dev, issue with the patch. CLOSED TREE
This commit is contained in:
Родитель
d5c1cc2201
Коммит
8b8b467a26
|
@ -675,9 +675,6 @@ pref("browser.search.separatePrivateDefault.ui.enabled", false);
|
|||
// The maximum amount of times the private default banner is shown.
|
||||
pref("browser.search.separatePrivateDefault.ui.banner.max", 0);
|
||||
|
||||
// Enables search SERP telemetry (impressions, engagements and abandonment)
|
||||
pref("browser.search.serpEventTelemetry.enabled", false);
|
||||
|
||||
// Enables the display of the Mozilla VPN banner in private browsing windows
|
||||
pref("browser.privatebrowsing.vpnpromourl", "https://vpn.mozilla.org/?utm_source=firefox-browser&utm_medium=firefox-%CHANNEL%-browser&utm_campaign=private-browsing-vpn-link");
|
||||
|
||||
|
|
|
@ -31,13 +31,6 @@ XPCOMUtils.defineLazyGetter(lazy, "logConsole", () => {
|
|||
});
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
lazy,
|
||||
"serpEventsEnabled",
|
||||
"browser.search.serpEventTelemetry.enabled",
|
||||
false
|
||||
);
|
||||
|
||||
/**
|
||||
* TelemetryHandler is the main class handling Search Engine Result Page (SERP)
|
||||
* telemetry. It primarily deals with tracking of what pages are loaded into tabs.
|
||||
|
@ -570,26 +563,6 @@ class TelemetryHandler {
|
|||
1
|
||||
);
|
||||
|
||||
if (lazy.serpEventsEnabled) {
|
||||
let partnerCode = "";
|
||||
if (info.code != "none" && info.code != null) {
|
||||
partnerCode = info.code;
|
||||
}
|
||||
|
||||
Glean.serp.impression.record({
|
||||
// The UUID generated by Services.uuid contains leading and trailing braces.
|
||||
// Need to trim them first.
|
||||
impression_id: Services.uuid
|
||||
.generateUUID()
|
||||
.toString()
|
||||
.slice(1, -1),
|
||||
provider: info.provider,
|
||||
tagged: info.type.startsWith("tagged"),
|
||||
partner_code: partnerCode,
|
||||
source,
|
||||
});
|
||||
}
|
||||
|
||||
lazy.logConsole.debug("Counting", payload, "for", url);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,46 +121,3 @@ newtab.search.ad:
|
|||
telemetry_id: *telemetry_id
|
||||
send_in_pings:
|
||||
- newtab
|
||||
|
||||
serp:
|
||||
impression:
|
||||
type: event
|
||||
description: >
|
||||
Recorded when a search engine results page (SERP) is shown to a user.
|
||||
bugs:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1813162
|
||||
data_reviews:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1813162
|
||||
data_sensitivity:
|
||||
- interaction
|
||||
notification_emails:
|
||||
- fx-search-telemetry@mozilla.com
|
||||
- rev-data@mozilla.com
|
||||
expires: never
|
||||
extra_keys:
|
||||
impression_id: &impression_id
|
||||
description: >
|
||||
A uuid to link SERP events to user's engagement events.
|
||||
type: string
|
||||
provider:
|
||||
description: >
|
||||
The name of the provider.
|
||||
type: string
|
||||
tagged:
|
||||
description: >
|
||||
Whether the search is tagged (true) or organic (false).
|
||||
type: boolean
|
||||
partner_code:
|
||||
description: >
|
||||
Any partner_code parsing in the URL or an empty string if not
|
||||
available.
|
||||
type: string
|
||||
source:
|
||||
description: >
|
||||
How the user arrived at the SERP.
|
||||
Possible values are:
|
||||
`urlbar`, `urlbar_handoff`, `urlbar_searchmode`, `urlbar_persisted`,
|
||||
`searchbar`, `contextmenu`, `webextension`, `system`, `reload`,
|
||||
`tabhistory`, `unknown`.
|
||||
This will be `unknown` if we cannot determine the source.
|
||||
type: string
|
||||
|
|
|
@ -77,7 +77,6 @@ add_setup(async function() {
|
|||
],
|
||||
// Ensure to add search suggestion telemetry as search_suggestion not search_formhistory.
|
||||
["browser.urlbar.maxHistoricalSearchSuggestions", 0],
|
||||
["browser.search.serpEventTelemetry.enabled", true],
|
||||
],
|
||||
});
|
||||
// Enable local telemetry recording for the duration of the tests.
|
||||
|
@ -135,15 +134,6 @@ async function track_ad_click(
|
|||
}
|
||||
);
|
||||
|
||||
assertImpressionEvents([
|
||||
{
|
||||
provider: "example",
|
||||
tagged: "true",
|
||||
partner_code: "ff",
|
||||
source: expectedScalarSource,
|
||||
},
|
||||
]);
|
||||
|
||||
let pageLoadPromise = BrowserTestUtils.waitForLocationChange(gBrowser);
|
||||
await SpecialPowers.spawn(tab.linkedBrowser, [], () => {
|
||||
content.document.getElementById("ad1").click();
|
||||
|
@ -162,18 +152,7 @@ async function track_ad_click(
|
|||
}
|
||||
);
|
||||
|
||||
assertImpressionEvents([
|
||||
{
|
||||
provider: "example",
|
||||
tagged: "true",
|
||||
partner_code: "ff",
|
||||
source: expectedScalarSource,
|
||||
},
|
||||
]);
|
||||
|
||||
await cleanupFn();
|
||||
|
||||
Services.fog.testResetFOG();
|
||||
}
|
||||
|
||||
add_task(async function test_source_urlbar() {
|
||||
|
|
|
@ -29,8 +29,6 @@ const TEST_PROVIDER_INFO = [
|
|||
},
|
||||
];
|
||||
|
||||
const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
||||
|
||||
function getPageUrl(useAdPage = false) {
|
||||
let page = useAdPage ? "searchTelemetryAd.html" : "searchTelemetry.html";
|
||||
return `https://example.com/browser/browser/components/search/test/browser/${page}`;
|
||||
|
@ -64,12 +62,6 @@ async function waitForIdle() {
|
|||
}
|
||||
}
|
||||
|
||||
function resetTelemetry() {
|
||||
searchCounts.clear();
|
||||
Services.telemetry.clearScalars();
|
||||
Services.fog.testResetFOG();
|
||||
}
|
||||
|
||||
SearchTestUtils.init(this);
|
||||
UrlbarTestUtils.init(this);
|
||||
|
||||
|
@ -82,10 +74,7 @@ add_setup(async function() {
|
|||
SearchSERPTelemetry.overrideSearchTelemetryForTests(TEST_PROVIDER_INFO);
|
||||
await waitForIdle();
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.urlbar.suggest.searches", true],
|
||||
["browser.search.serpEventTelemetry.enabled", true],
|
||||
],
|
||||
set: [["browser.urlbar.suggest.searches", true]],
|
||||
});
|
||||
// Enable local telemetry recording for the duration of the tests.
|
||||
let oldCanRecord = Services.telemetry.canRecordExtended;
|
||||
|
@ -145,15 +134,6 @@ add_task(async function test_search() {
|
|||
"browser.search.withads.urlbar": { "example:tagged": 1 },
|
||||
}
|
||||
);
|
||||
|
||||
assertImpressionEvents([
|
||||
{
|
||||
provider: "example",
|
||||
tagged: "true",
|
||||
partner_code: "ff",
|
||||
source: "urlbar",
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
add_task(async function test_reload() {
|
||||
|
@ -174,21 +154,6 @@ add_task(async function test_reload() {
|
|||
}
|
||||
);
|
||||
|
||||
assertImpressionEvents([
|
||||
{
|
||||
provider: "example",
|
||||
tagged: "true",
|
||||
partner_code: "ff",
|
||||
source: "urlbar",
|
||||
},
|
||||
{
|
||||
provider: "example",
|
||||
tagged: "true",
|
||||
partner_code: "ff",
|
||||
source: "reload",
|
||||
},
|
||||
]);
|
||||
|
||||
let pageLoadPromise = BrowserTestUtils.waitForLocationChange(gBrowser);
|
||||
await SpecialPowers.spawn(tab.linkedBrowser, [], () => {
|
||||
content.document.getElementById("ad1").click();
|
||||
|
@ -207,27 +172,13 @@ add_task(async function test_reload() {
|
|||
"browser.search.adclicks.reload": { "example:tagged": 1 },
|
||||
}
|
||||
);
|
||||
|
||||
assertImpressionEvents([
|
||||
{
|
||||
provider: "example",
|
||||
tagged: "true",
|
||||
partner_code: "ff",
|
||||
source: "urlbar",
|
||||
},
|
||||
{
|
||||
provider: "example",
|
||||
tagged: "true",
|
||||
partner_code: "ff",
|
||||
source: "reload",
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
let searchUrl;
|
||||
|
||||
add_task(async function test_fresh_search() {
|
||||
resetTelemetry();
|
||||
searchCounts.clear();
|
||||
Services.telemetry.clearScalars();
|
||||
|
||||
// Load a page via the address bar.
|
||||
await loadSearchPage();
|
||||
|
@ -243,15 +194,6 @@ add_task(async function test_fresh_search() {
|
|||
"browser.search.withads.urlbar": { "example:tagged": 1 },
|
||||
}
|
||||
);
|
||||
|
||||
assertImpressionEvents([
|
||||
{
|
||||
provider: "example",
|
||||
tagged: "true",
|
||||
partner_code: "ff",
|
||||
source: "urlbar",
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
add_task(async function test_click_ad() {
|
||||
|
@ -271,15 +213,6 @@ add_task(async function test_click_ad() {
|
|||
"browser.search.adclicks.urlbar": { "example:tagged": 1 },
|
||||
}
|
||||
);
|
||||
|
||||
assertImpressionEvents([
|
||||
{
|
||||
provider: "example",
|
||||
tagged: "true",
|
||||
partner_code: "ff",
|
||||
source: "urlbar",
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
add_task(async function test_go_back() {
|
||||
|
@ -301,21 +234,6 @@ add_task(async function test_go_back() {
|
|||
}
|
||||
);
|
||||
|
||||
assertImpressionEvents([
|
||||
{
|
||||
provider: "example",
|
||||
tagged: "true",
|
||||
partner_code: "ff",
|
||||
source: "urlbar",
|
||||
},
|
||||
{
|
||||
provider: "example",
|
||||
tagged: "true",
|
||||
partner_code: "ff",
|
||||
source: "tabhistory",
|
||||
},
|
||||
]);
|
||||
|
||||
let pageLoadPromise = BrowserTestUtils.waitForLocationChange(gBrowser);
|
||||
await SpecialPowers.spawn(tab.linkedBrowser, [], () => {
|
||||
content.document.getElementById("ad1").click();
|
||||
|
@ -335,26 +253,12 @@ add_task(async function test_go_back() {
|
|||
"browser.search.adclicks.tabhistory": { "example:tagged": 1 },
|
||||
}
|
||||
);
|
||||
|
||||
assertImpressionEvents([
|
||||
{
|
||||
provider: "example",
|
||||
tagged: "true",
|
||||
partner_code: "ff",
|
||||
source: "urlbar",
|
||||
},
|
||||
{
|
||||
provider: "example",
|
||||
tagged: "true",
|
||||
partner_code: "ff",
|
||||
source: "tabhistory",
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
// Conduct a search from the Urlbar with showSearchTerms enabled.
|
||||
add_task(async function test_fresh_search_with_urlbar_persisted() {
|
||||
resetTelemetry();
|
||||
searchCounts.clear();
|
||||
Services.telemetry.clearScalars();
|
||||
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["browser.urlbar.showSearchTerms.featureGate", true]],
|
||||
|
@ -372,15 +276,6 @@ add_task(async function test_fresh_search_with_urlbar_persisted() {
|
|||
}
|
||||
);
|
||||
|
||||
assertImpressionEvents([
|
||||
{
|
||||
provider: "example",
|
||||
tagged: "true",
|
||||
partner_code: "ff",
|
||||
source: "urlbar",
|
||||
},
|
||||
]);
|
||||
|
||||
// Do another search from the context of the default SERP.
|
||||
await loadSearchPage();
|
||||
await assertSearchSourcesTelemetry(
|
||||
|
@ -396,21 +291,6 @@ add_task(async function test_fresh_search_with_urlbar_persisted() {
|
|||
}
|
||||
);
|
||||
|
||||
assertImpressionEvents([
|
||||
{
|
||||
provider: "example",
|
||||
tagged: "true",
|
||||
partner_code: "ff",
|
||||
source: "urlbar",
|
||||
},
|
||||
{
|
||||
provider: "example",
|
||||
tagged: "true",
|
||||
partner_code: "ff",
|
||||
source: "urlbar_persisted",
|
||||
},
|
||||
]);
|
||||
|
||||
// Click on an ad.
|
||||
let pageLoadPromise = BrowserTestUtils.waitForLocationChange(gBrowser);
|
||||
await SpecialPowers.spawn(tab.linkedBrowser, [], () => {
|
||||
|
@ -431,20 +311,5 @@ add_task(async function test_fresh_search_with_urlbar_persisted() {
|
|||
}
|
||||
);
|
||||
|
||||
assertImpressionEvents([
|
||||
{
|
||||
provider: "example",
|
||||
tagged: "true",
|
||||
partner_code: "ff",
|
||||
source: "urlbar",
|
||||
},
|
||||
{
|
||||
provider: "example",
|
||||
tagged: "true",
|
||||
partner_code: "ff",
|
||||
source: "urlbar_persisted",
|
||||
},
|
||||
]);
|
||||
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
||||
|
|
|
@ -213,66 +213,3 @@ function clearSearchbarHistory(win = window) {
|
|||
info("cleanup the search history");
|
||||
return FormHistory.update({ op: "remove", fieldname: "searchbar-history" });
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the recorded Glean impression event has an impression_id property
|
||||
* pointing to a valid UUID and that the impression_id is unique.
|
||||
*
|
||||
* @param {Array} recordedEvents The recorded Glean impression events whose
|
||||
* impression_id properties we need to verify.
|
||||
*/
|
||||
function assertUUIDs(recordedEvents) {
|
||||
const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
||||
let impressionIdsSet = new Set();
|
||||
|
||||
for (let recordedEvent of recordedEvents) {
|
||||
let impressionId = recordedEvent.extra.impression_id;
|
||||
|
||||
Assert.equal(
|
||||
typeof impressionId,
|
||||
"string",
|
||||
"should be an impression_id on the event"
|
||||
);
|
||||
Assert.ok(
|
||||
UUID_REGEX.test(impressionId),
|
||||
"impression_id should be a valid UUID"
|
||||
);
|
||||
|
||||
Assert.ok(
|
||||
!impressionIdsSet.has(impressionId),
|
||||
"Should not have found a duplicate impression_id"
|
||||
);
|
||||
impressionIdsSet.add(impressionId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that we get the correct number of recorded Glean impression events
|
||||
* and that the recorded Glean impression events have the correct keys and
|
||||
* values.
|
||||
*
|
||||
* @param {Array} expectedEvents The expected impression events whose keys and
|
||||
* values we use to validate the recorded Glean impression events.
|
||||
*/
|
||||
function assertImpressionEvents(expectedEvents) {
|
||||
let recordedEvents = Glean.serp.impression.testGetValue();
|
||||
|
||||
Assert.equal(
|
||||
recordedEvents.length,
|
||||
expectedEvents.length,
|
||||
"should have the correct number of Glean events"
|
||||
);
|
||||
|
||||
for (let [idx, expectedEvent] of expectedEvents.entries()) {
|
||||
let recordedEvent = recordedEvents[idx].extra;
|
||||
for (let key of Object.keys(expectedEvent)) {
|
||||
Assert.equal(
|
||||
recordedEvent[key],
|
||||
expectedEvent[key],
|
||||
`the value for recorded key "${key}" should match the value for expected key "${key}"`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
assertUUIDs(recordedEvents);
|
||||
}
|
||||
|
|
|
@ -50,11 +50,6 @@ const TESTS = [
|
|||
expectedAdKey: "example:tagged",
|
||||
adUrls: ["https://www.example.com/ad2"],
|
||||
nonAdUrls: ["https://www.example.com/ad3"],
|
||||
impression: {
|
||||
provider: "example",
|
||||
tagged: "true",
|
||||
partner_code: "ff",
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "Tagged follow-on",
|
||||
|
@ -63,11 +58,6 @@ const TESTS = [
|
|||
expectedAdKey: "example:tagged-follow-on",
|
||||
adUrls: ["https://www.example.com/ad2"],
|
||||
nonAdUrls: ["https://www.example.com/ad3"],
|
||||
impression: {
|
||||
provider: "example",
|
||||
tagged: "true",
|
||||
partner_code: "tb",
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "Organic search matched code",
|
||||
|
@ -76,11 +66,6 @@ const TESTS = [
|
|||
expectedAdKey: "example:organic",
|
||||
adUrls: ["https://www.example.com/ad2"],
|
||||
nonAdUrls: ["https://www.example.com/ad3"],
|
||||
impression: {
|
||||
provider: "example",
|
||||
tagged: "false",
|
||||
partner_code: "foo",
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "Organic search non-matched code",
|
||||
|
@ -89,11 +74,6 @@ const TESTS = [
|
|||
expectedAdKey: "example:organic",
|
||||
adUrls: ["https://www.example.com/ad2"],
|
||||
nonAdUrls: ["https://www.example.com/ad3"],
|
||||
impression: {
|
||||
provider: "example",
|
||||
tagged: "false",
|
||||
partner_code: "other",
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "Organic search non-matched code 2",
|
||||
|
@ -102,11 +82,6 @@ const TESTS = [
|
|||
expectedAdKey: "example:organic",
|
||||
adUrls: ["https://www.example.com/ad2"],
|
||||
nonAdUrls: ["https://www.example.com/ad3"],
|
||||
impression: {
|
||||
provider: "example",
|
||||
tagged: "false",
|
||||
partner_code: "other",
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "Organic search expected organic matched code",
|
||||
|
@ -115,11 +90,6 @@ const TESTS = [
|
|||
expectedAdKey: "example:organic",
|
||||
adUrls: ["https://www.example.com/ad2"],
|
||||
nonAdUrls: ["https://www.example.com/ad3"],
|
||||
impression: {
|
||||
provider: "example",
|
||||
tagged: "false",
|
||||
partner_code: "",
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "Organic search no codes",
|
||||
|
@ -128,11 +98,6 @@ const TESTS = [
|
|||
expectedAdKey: "example:organic",
|
||||
adUrls: ["https://www.example.com/ad2"],
|
||||
nonAdUrls: ["https://www.example.com/ad3"],
|
||||
impression: {
|
||||
provider: "example",
|
||||
tagged: "false",
|
||||
partner_code: "",
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "Different engines using the same adUrl",
|
||||
|
@ -141,11 +106,6 @@ const TESTS = [
|
|||
expectedAdKey: "example2:organic",
|
||||
adUrls: ["https://www.example.com/ad2"],
|
||||
nonAdUrls: ["https://www.example.com/ad3"],
|
||||
impression: {
|
||||
provider: "example2",
|
||||
tagged: "false",
|
||||
partner_code: "",
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
|
@ -201,11 +161,6 @@ do_get_profile();
|
|||
|
||||
add_task(async function setup() {
|
||||
Services.prefs.setBoolPref(SearchUtils.BROWSER_SEARCH_PREF + "log", true);
|
||||
Services.prefs.setBoolPref(
|
||||
SearchUtils.BROWSER_SEARCH_PREF + "serpEventTelemetry.enabled",
|
||||
true
|
||||
);
|
||||
Services.fog.initializeFOG();
|
||||
await SearchSERPTelemetry.init();
|
||||
SearchSERPTelemetry.overrideSearchTelemetryForTests(TEST_PROVIDER_INFO);
|
||||
sinon.stub(BrowserSearchTelemetry, "shouldRecordSearchCount").returns(true);
|
||||
|
@ -240,36 +195,8 @@ add_task(async function test_parsing_search_urls() {
|
|||
}
|
||||
}
|
||||
|
||||
let recordedEvents = Glean.serp.impression.testGetValue();
|
||||
|
||||
Assert.equal(
|
||||
recordedEvents.length,
|
||||
1,
|
||||
"should only see one impression event"
|
||||
);
|
||||
|
||||
let recordedEvent = recordedEvents[0].extra;
|
||||
Assert.equal(
|
||||
recordedEvent.partner_code,
|
||||
test.impression.partner_code,
|
||||
"should see the correct partner code"
|
||||
);
|
||||
Assert.equal(
|
||||
recordedEvent.tagged,
|
||||
test.impression.tagged,
|
||||
"should see the correct tagged value"
|
||||
);
|
||||
Assert.equal(
|
||||
recordedEvent.provider,
|
||||
test.impression.provider,
|
||||
"should see the correct provider"
|
||||
);
|
||||
|
||||
if (test.tearDown) {
|
||||
test.tearDown();
|
||||
}
|
||||
|
||||
// We need to clear Glean events so they don't accumulate for each iteration.
|
||||
Services.fog.testResetFOG();
|
||||
}
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче