Bug 1930629 - Fix Bing follow-on searches selected from suggestion list that are incorrectly recorded as organic:none in telemetry. a=dmeehan

Original Revision: https://phabricator.services.mozilla.com/D228892

Differential Revision: https://phabricator.services.mozilla.com/D228919
This commit is contained in:
Stephanie Cunnane 2024-11-14 19:04:05 +00:00
parent 22fab1ecf3
commit 0091962ce7
2 changed files with 72 additions and 2 deletions

View file

@ -929,6 +929,9 @@ class TelemetryHandler {
}
let queries = new URLSearchParams(url.split("#")[0].split("?")[1]);
queries.forEach((v, k) => {
queries.set(k.toLowerCase(), v);
});
let isSPA = !!searchProviderInfo.isSPA;
if (isSPA) {
@ -964,7 +967,7 @@ class TelemetryHandler {
let type = "organic";
let code;
if (searchProviderInfo.codeParamName) {
code = queries.get(searchProviderInfo.codeParamName);
code = queries.get(searchProviderInfo.codeParamName.toLowerCase());
if (code) {
// The code is only included if it matches one of the specific ones.
if (searchProviderInfo.taggedCodes.includes(code)) {
@ -986,7 +989,9 @@ class TelemetryHandler {
// Especially Bing requires lots of extra work related to cookies.
for (let followOnCookie of searchProviderInfo.followOnCookies) {
if (followOnCookie.extraCodeParamName) {
let eCode = queries.get(followOnCookie.extraCodeParamName);
let eCode = queries.get(
followOnCookie.extraCodeParamName.toLowerCase()
);
if (
!eCode ||
!followOnCookie.extraCodePrefixes.some(p => eCode.startsWith(p))

View file

@ -74,6 +74,32 @@ const TEST_PROVIDER_INFO = [
},
],
},
{
telemetryId: "example4",
searchPageRegexp: /^https:\/\/www\.example4\.com\/search/,
queryParamNames: ["a", "q"],
codeParamName: "abc",
taggedCodes: ["ff", "tb"],
expectedOrganicCodes: ["baz"],
organicCodes: ["foo"],
followOnParamNames: ["a"],
followOnCookies: [
{
host: "www.example4.com",
name: "_dummyCookieName",
codeParamName: "abc",
extraCodePrefixes: ["xyz"],
extraCodeParamName: "dummyExtraCodeParamName",
},
],
extraAdServersRegexps: [/^https:\/\/www\.example\.com\/ad2/],
components: [
{
type: SearchSERPTelemetryUtils.COMPONENTS.AD_LINK,
default: true,
},
],
},
];
const TESTS = [
@ -169,6 +195,45 @@ const TESTS = [
is_signed_in: "false",
},
},
{
setUp() {
Services.cookies.removeAll();
Services.cookies.add(
"www.example4.com",
"/",
"_dummyCookieName",
"abc=tb&def=ghi",
false,
false,
false,
Date.now() + 1000 * 60 * 60,
{},
Ci.nsICookie.SAMESITE_NONE,
Ci.nsICookie.SCHEME_HTTPS
);
},
tearDown() {
Services.cookies.removeAll();
},
title:
"Tagged follow-on with cookie and unexpected extraCodeParam casing in URL",
trackingUrl:
"https://www.example4.com/search?q=test&a=next&DUMMYEXTRACODEPARAMNAME=xyz",
expectedSearchCountEntry: "example4:tagged-follow-on:tb",
expectedAdKey: "example4:tagged-follow-on",
adUrls: ["https://www.example.com/ad2"],
nonAdUrls: ["https://www.example.com/ad3"],
impression: {
provider: "example4",
tagged: "true",
partner_code: "tb",
source: "unknown",
is_shopping_page: "false",
is_private: "false",
shopping_tab_displayed: "false",
is_signed_in: "false",
},
},
{
title: "Organic search matched code",
trackingUrl: "https://www.example.com/search?q=test&abc=foo",