Bug 1749243 - Update Fx98 MfM utm_content values to add region r=pdahiya

Differential Revision: https://phabricator.services.mozilla.com/D135903
This commit is contained in:
Meg Viar 2022-01-20 19:11:22 +00:00
Родитель c5d4f89a03
Коммит 66ac5d98fc
2 изменённых файлов: 80 добавлений и 9 удалений

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

@ -35,7 +35,7 @@ var gMoreFromMozillaPane = {
return this._option;
},
getURL(url, option, hasEmail) {
getURL(url, region, option, hasEmail) {
const URL_PARAMS = {
utm_source: "about-prefs",
utm_campaign: "morefrommozilla",
@ -44,21 +44,23 @@ var gMoreFromMozillaPane = {
// UTM content param used in analytics to record
// UI template used to open URL
const utm_content = {
default: "fxvt-default",
simple: "fxvt-113-a-na",
advanced: "fxvt-113-b-na",
default: "default",
simple: "fxvt-113-a",
advanced: "fxvt-113-b",
};
let pageUrl = new URL(url);
for (let [key, val] of Object.entries(URL_PARAMS)) {
pageUrl.searchParams.append(key, val);
}
// Append '-email' to utm_content when URL is opened
// Append region by product to utm_cotent and also
// append '-email' when URL is opened
// from send email link in QRCode box
if (option) {
pageUrl.searchParams.set(
"utm_content",
`${utm_content[option]}${hasEmail ? "-email" : ""}`
`${utm_content[option]}-${region}${hasEmail ? "-email" : ""}`
);
}
return pageUrl.toString();
@ -70,6 +72,7 @@ var gMoreFromMozillaPane = {
id: "firefox-mobile",
title_string_id: "more-from-moz-firefox-mobile-title",
description_string_id: "more-from-moz-firefox-mobile-description",
region: "global",
button: {
id: "fxMobile",
type: "link",
@ -102,6 +105,7 @@ var gMoreFromMozillaPane = {
id: "mozilla-vpn",
title_string_id: "more-from-moz-mozilla-vpn-title",
description_string_id: "more-from-moz-mozilla-vpn-description",
region: "global",
button: {
id: "mozillaVPN",
label_string_id: "more-from-moz-button-mozilla-vpn",
@ -116,6 +120,7 @@ var gMoreFromMozillaPane = {
id: "mozilla-rally",
title_string_id: "more-from-moz-mozilla-rally-title",
description_string_id: "more-from-moz-mozilla-rally-description",
region: "na",
button: {
id: "mozillaRally",
label_string_id: "more-from-moz-button-mozilla-rally",
@ -175,7 +180,7 @@ var gMoreFromMozillaPane = {
if (isLink) {
actionElement.setAttribute(
"href",
this.getURL(product.button.actionURL, this.option)
this.getURL(product.button.actionURL, product.region, this.option)
);
actionElement.setAttribute("target", "_blank");
} else {
@ -184,6 +189,7 @@ var gMoreFromMozillaPane = {
mainWindow.openTrustedLinkIn(
gMoreFromMozillaPane.getURL(
product.button.actionURL,
product.region,
gMoreFromMozillaPane.option
),
"tab"
@ -229,7 +235,12 @@ var gMoreFromMozillaPane = {
);
qrc_btn.setAttribute(
"href",
this.getURL(product.qrcode.button.actionURL, this.option, true)
this.getURL(
product.qrcode.button.actionURL,
product.region,
this.option,
true
)
);
}

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

@ -222,7 +222,7 @@ add_task(async function test_aboutpreferences_clickBtnVPN() {
);
Assert.equal(
searchParams.get("utm_content"),
"fxvt-113-a-na",
"fxvt-113-a-global",
"utm_content set"
);
@ -241,6 +241,66 @@ add_task(async function test_aboutpreferences_clickBtnVPN() {
BrowserTestUtils.removeTab(tab);
});
add_task(async function test_aboutpreferences_clickBtnMobile() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.preferences.moreFromMozilla", true],
["browser.preferences.moreFromMozilla.template", "simple"],
],
});
await openPreferencesViaOpenPreferencesAPI("paneMoreFromMozilla", {
leaveOpen: true,
});
let doc = gBrowser.contentDocument;
let tab = gBrowser.selectedTab;
let productCards = doc.querySelectorAll("vbox.simple");
Assert.ok(productCards, "Simple template loaded");
const expectedUrl = "https://www.mozilla.org/firefox/browsers/mobile/";
let mobileUrl = new URL(doc.getElementById("simple-fxMobile").href);
Assert.ok(mobileUrl.href.startsWith(expectedUrl));
let searchParams = mobileUrl.searchParams;
Assert.equal(
searchParams.get("utm_source"),
"about-prefs",
"expected utm_source sent"
);
Assert.equal(
searchParams.get("utm_campaign"),
"morefrommozilla",
"utm_campaign set"
);
Assert.equal(
searchParams.get("utm_medium"),
"firefox-desktop",
"utm_medium set"
);
Assert.equal(
searchParams.get("utm_content"),
"fxvt-113-a-global",
"default-global",
"utm_content set"
);
// Since we're not running MfM experiments in this release, we want to be sure that
// our URL params aren't claiming that we are.
Assert.ok(
!searchParams.has("entrypoint_variation"),
"entrypoint_variation should not be set"
);
Assert.ok(
!searchParams.has("entrypoint_experiment"),
"entrypoint_experiment should not be set"
);
BrowserTestUtils.removeTab(tab);
});
add_task(async function test_aboutpreferences_search() {
await SpecialPowers.pushPrefEnv({
set: [