summaryrefslogtreecommitdiffstats
path: root/browser/components/search/SearchSERPTelemetry.sys.mjs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--browser/components/search/SearchSERPTelemetry.sys.mjs58
1 files changed, 32 insertions, 26 deletions
diff --git a/browser/components/search/SearchSERPTelemetry.sys.mjs b/browser/components/search/SearchSERPTelemetry.sys.mjs
index 2a9ed88db1..dc261f1300 100644
--- a/browser/components/search/SearchSERPTelemetry.sys.mjs
+++ b/browser/components/search/SearchSERPTelemetry.sys.mjs
@@ -70,13 +70,6 @@ ChromeUtils.defineLazyGetter(lazy, "logConsole", () => {
});
});
-XPCOMUtils.defineLazyPreferenceGetter(
- lazy,
- "serpEventsEnabled",
- "browser.search.serpEventTelemetry.enabled",
- true
-);
-
const CATEGORIZATION_PREF =
"browser.search.serpEventTelemetryCategorization.enabled";
@@ -500,11 +493,7 @@ class TelemetryHandler {
// from something that happened in content. We keep this separate from
// source because legacy telemetry should not change its reporting.
let inContentSource;
- if (
- lazy.serpEventsEnabled &&
- info.hasComponents &&
- this.#browserContentSourceMap.has(browser)
- ) {
+ if (info.hasComponents && this.#browserContentSourceMap.has(browser)) {
inContentSource = this.#browserContentSourceMap.get(browser);
this.#browserContentSourceMap.delete(browser);
}
@@ -517,7 +506,7 @@ class TelemetryHandler {
}
let impressionId;
- if (lazy.serpEventsEnabled && info.hasComponents) {
+ if (info.hasComponents) {
// The UUID generated by Services.uuid contains leading and trailing braces.
// Need to trim them first.
impressionId = Services.uuid.generateUUID().toString().slice(1, -1);
@@ -535,7 +524,7 @@ class TelemetryHandler {
let item = this._browserInfoByURL.get(urlKey);
let impressionInfo;
- if (lazy.serpEventsEnabled && info.hasComponents) {
+ if (info.hasComponents) {
let partnerCode = "";
if (info.code != "none" && info.code != null) {
partnerCode = info.code;
@@ -547,6 +536,7 @@ class TelemetryHandler {
source: inContentSource ?? source,
isShoppingPage: info.isShoppingPage,
isPrivate: lazy.PrivateBrowsingUtils.isBrowserPrivate(browser),
+ isSignedIn: info.isSignedIn,
};
}
@@ -560,6 +550,8 @@ class TelemetryHandler {
searchBoxSubmitted: false,
categorizationInfo: null,
adsClicked: 0,
+ adsHidden: 0,
+ adsLoaded: 0,
adsVisible: 0,
searchQuery: info.searchQuery,
});
@@ -577,6 +569,8 @@ class TelemetryHandler {
searchBoxSubmitted: false,
categorizationInfo: null,
adsClicked: 0,
+ adsHidden: 0,
+ adsLoaded: 0,
adsVisible: 0,
searchQuery: info.searchQuery,
}),
@@ -1056,19 +1050,27 @@ class TelemetryHandler {
}
let isShoppingPage = false;
let hasComponents = false;
- if (lazy.serpEventsEnabled) {
- if (searchProviderInfo.shoppingTab?.regexp) {
- isShoppingPage = searchProviderInfo.shoppingTab.regexp.test(url);
- }
- if (searchProviderInfo.components?.length) {
- hasComponents = true;
- }
+ let isSignedIn = false;
+ if (searchProviderInfo.shoppingTab?.regexp) {
+ isShoppingPage = searchProviderInfo.shoppingTab.regexp.test(url);
+ }
+ if (searchProviderInfo.components?.length) {
+ hasComponents = true;
+ }
+ if (searchProviderInfo.accountCookies) {
+ isSignedIn = searchProviderInfo.accountCookies.some(cookieObj => {
+ return Services.cookies
+ .getCookiesFromHost(cookieObj.host, {})
+ .some(c => c.name == cookieObj.name);
+ });
}
+
return {
provider: searchProviderInfo.telemetryId,
type,
code,
isShoppingPage,
+ isSignedIn,
hasComponents,
searchQuery,
isSPA,
@@ -1341,10 +1343,6 @@ class ContentHandler {
* The search provider info associated with the item.
*/
#maybeRecordSERPTelemetry(wrappedChannel, item, info) {
- if (!lazy.serpEventsEnabled) {
- return;
- }
-
if (wrappedChannel._recordedClick) {
lazy.logConsole.debug("Click already recorded.");
return;
@@ -1644,7 +1642,6 @@ class ContentHandler {
}
let telemetryState = item.browserTelemetryStateMap.get(browser);
if (
- lazy.serpEventsEnabled &&
info.adImpressions &&
telemetryState &&
!telemetryState.adImpressionsReported
@@ -1652,6 +1649,8 @@ class ContentHandler {
for (let [componentType, data] of info.adImpressions.entries()) {
// Not all ad impressions are sponsored.
if (AD_COMPONENTS.includes(componentType)) {
+ telemetryState.adsHidden += data.adsHidden;
+ telemetryState.adsLoaded += data.adsLoaded;
telemetryState.adsVisible += data.adsVisible;
}
@@ -1755,6 +1754,7 @@ class ContentHandler {
shopping_tab_displayed: info.shoppingTabDisplayed,
is_shopping_page: impressionInfo.isShoppingPage,
is_private: impressionInfo.isPrivate,
+ is_signed_in: impressionInfo.isSignedIn,
});
lazy.logConsole.debug(`Reported Impression:`, {
impressionId,
@@ -1805,6 +1805,8 @@ class ContentHandler {
tagged: impressionInfo.tagged,
is_shopping_page: impressionInfo.isShoppingPage,
num_ads_clicked: telemetryState.adsClicked,
+ num_ads_hidden: telemetryState.adsHidden,
+ num_ads_loaded: telemetryState.adsLoaded,
num_ads_visible: telemetryState.adsVisible,
});
};
@@ -1844,6 +1846,10 @@ class ContentHandler {
* @typedef {object} CategorizationExtraParams
* @property {number} num_ads_clicked
* The total number of ads clicked on a SERP.
+ * @property {number} num_ads_hidden
+ * The total number of ads hidden from the user when categorization occured.
+ * @property {number} num_ads_loaded
+ * The total number of ads loaded when categorization occured.
* @property {number} num_ads_visible
* The total number of ads visible to the user when categorization occured.
*/