зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1907097 - Add telemetry for when ads_blocked are counted - r=scunnane
Differential Revision: https://phabricator.services.mozilla.com/D216208
This commit is contained in:
Родитель
4b678501ae
Коммит
b13d4d952b
|
@ -889,6 +889,7 @@ class SearchAdImpression {
|
|||
opacityProperty: true,
|
||||
})
|
||||
) {
|
||||
Glean.serp.adsBlockedCount.hidden_parent.add();
|
||||
return {
|
||||
adsVisible: 0,
|
||||
adsHidden: adsLoaded,
|
||||
|
@ -901,6 +902,7 @@ class SearchAdImpression {
|
|||
elementRect.bottom < 0 &&
|
||||
innerWindowHeight + scrollY + elementRect.bottom < 0
|
||||
) {
|
||||
Glean.serp.adsBlockedCount.beyond_viewport.add();
|
||||
return {
|
||||
adsVisible: 0,
|
||||
adsHidden: adsLoaded,
|
||||
|
@ -933,6 +935,7 @@ class SearchAdImpression {
|
|||
})
|
||||
) {
|
||||
adsHidden += 1;
|
||||
Glean.serp.adsBlockedCount.hidden_child.add();
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -459,6 +459,26 @@ serp:
|
|||
send_in_pings:
|
||||
- serp-categorization
|
||||
|
||||
ads_blocked_count:
|
||||
type: labeled_counter
|
||||
description: >
|
||||
Counts the specific type of block.
|
||||
bugs:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1907097
|
||||
data_reviews:
|
||||
- https://phabricator.services.mozilla.com/D216208
|
||||
notification_emails:
|
||||
- fx-search-telemetry@mozilla.com
|
||||
- rev-data@mozilla.com
|
||||
expires: never
|
||||
data_sensitivity:
|
||||
- technical
|
||||
labels:
|
||||
- beyond_viewport
|
||||
- hidden_parent
|
||||
- hidden_child
|
||||
|
||||
|
||||
search_with:
|
||||
reporting_url:
|
||||
type: url
|
||||
|
|
|
@ -35,6 +35,8 @@ support-files = ["searchTelemetryAd_searchbox_with_content.html", "serp.css"]
|
|||
["browser_search_telemetry_adImpression_component_skipCount_parent.js"]
|
||||
support-files = ["searchTelemetryAd_searchbox_with_content.html", "serp.css"]
|
||||
|
||||
["browser_search_telemetry_adblock_count.js"]
|
||||
|
||||
["browser_search_telemetry_categorization_timing.js"]
|
||||
|
||||
["browser_search_telemetry_content.js"]
|
||||
|
|
|
@ -0,0 +1,170 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
https://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
const BUILDER_URL = "https://example.com/document-builder.sjs?html=";
|
||||
|
||||
/**
|
||||
* This HTML file contains three ads:
|
||||
* - An ad that is well above the possible viewport.
|
||||
* - The numbers of ads are unique to help ensure counts are correct.
|
||||
*/
|
||||
const TEST_URI = `
|
||||
<!DOCTYPE html>
|
||||
<main>
|
||||
<style>
|
||||
.ad_parent {
|
||||
display: none;
|
||||
}
|
||||
/*
|
||||
This is if the ad blocker doesn't block the parent component but
|
||||
instead blocks the child.
|
||||
*/
|
||||
.ad_with_children div {
|
||||
display: none;
|
||||
}
|
||||
.ad_far_above {
|
||||
position: absolute;
|
||||
top: -9999px;
|
||||
}
|
||||
</style>
|
||||
<div class="ad_far_above">
|
||||
<a href="https://example.com/ad">Ad link</a>
|
||||
</div>
|
||||
<div class="ad_parent">
|
||||
<a href="https://example.com/ad">Ad link</a>
|
||||
</div>
|
||||
<div class="ad_parent">
|
||||
<a href="https://example.com/ad">Ad link</a>
|
||||
</div>
|
||||
<div class="ad_with_children">
|
||||
<span>Element</span>
|
||||
<div class="child">
|
||||
<a href="https://example.com/ad">Ad link</a>
|
||||
</div>
|
||||
<div class="child">
|
||||
<a href="https://example.com/ad">Ad link</a>
|
||||
</div>
|
||||
<div class="child">
|
||||
<a href="https://example.com/ad">Ad link</a>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
`;
|
||||
const URL =
|
||||
"https://example.org/document-builder.sjs?html=" +
|
||||
encodeURIComponent(TEST_URI) +
|
||||
"&s=foobar&abc=ff";
|
||||
|
||||
const TEST_PROVIDER_INFO = [
|
||||
{
|
||||
telemetryId: "example",
|
||||
searchPageRegexp: /^https:\/\/example\.org\/document-builder\.sjs/,
|
||||
queryParamNames: ["s"],
|
||||
codeParamName: "abc",
|
||||
taggedCodes: ["ff"],
|
||||
extraAdServersRegexps: [/^https:\/\/example\.com\/ad/],
|
||||
components: [
|
||||
{
|
||||
type: SearchSERPTelemetryUtils.COMPONENTS.AD_CAROUSEL,
|
||||
included: {
|
||||
parent: {
|
||||
selector: ".ad_with_children",
|
||||
},
|
||||
children: [
|
||||
{
|
||||
selector: ".child",
|
||||
countChildren: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
type: SearchSERPTelemetryUtils.COMPONENTS.AD_SITELINK,
|
||||
included: {
|
||||
parent: {
|
||||
selector: ".ad_parent",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
type: SearchSERPTelemetryUtils.COMPONENTS.AD_LINK,
|
||||
default: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
add_setup(async function () {
|
||||
SearchSERPTelemetry.overrideSearchTelemetryForTests(TEST_PROVIDER_INFO);
|
||||
await waitForIdle();
|
||||
// Enable local telemetry recording for the duration of the tests.
|
||||
let oldCanRecord = Services.telemetry.canRecordExtended;
|
||||
Services.telemetry.canRecordExtended = true;
|
||||
|
||||
registerCleanupFunction(async () => {
|
||||
SearchSERPTelemetry.overrideSearchTelemetryForTests();
|
||||
Services.telemetry.canRecordExtended = oldCanRecord;
|
||||
resetTelemetry();
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function test_adblock_count() {
|
||||
let { cleanup } = await openSerpInNewTab(URL);
|
||||
|
||||
assertSERPTelemetry([
|
||||
{
|
||||
impression: {
|
||||
is_signed_in: "false",
|
||||
is_private: "false",
|
||||
source: "unknown",
|
||||
is_shopping_page: "false",
|
||||
partner_code: "ff",
|
||||
provider: "example",
|
||||
shopping_tab_displayed: "false",
|
||||
tagged: "true",
|
||||
},
|
||||
adImpressions: [
|
||||
{
|
||||
component: SearchSERPTelemetryUtils.COMPONENTS.AD_LINK,
|
||||
ads_loaded: "1",
|
||||
ads_visible: "0",
|
||||
ads_hidden: "1",
|
||||
},
|
||||
{
|
||||
component: SearchSERPTelemetryUtils.COMPONENTS.AD_SITELINK,
|
||||
ads_loaded: "2",
|
||||
ads_visible: "0",
|
||||
ads_hidden: "2",
|
||||
},
|
||||
{
|
||||
component: SearchSERPTelemetryUtils.COMPONENTS.AD_CAROUSEL,
|
||||
ads_loaded: "3",
|
||||
ads_visible: "0",
|
||||
ads_hidden: "3",
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
||||
await Services.fog.testFlushAllChildren();
|
||||
|
||||
Assert.equal(
|
||||
1,
|
||||
Glean.serp.adsBlockedCount.beyond_viewport.testGetValue(),
|
||||
"Number of ads blocked due to being beyond the viewport."
|
||||
);
|
||||
Assert.equal(
|
||||
2,
|
||||
Glean.serp.adsBlockedCount.hidden_parent.testGetValue(),
|
||||
"Number of parent elements blocked."
|
||||
);
|
||||
Assert.equal(
|
||||
3,
|
||||
Glean.serp.adsBlockedCount.hidden_child.testGetValue(),
|
||||
"Number of child elements blocked."
|
||||
);
|
||||
|
||||
await cleanup();
|
||||
});
|
Загрузка…
Ссылка в новой задаче