From 086c044dc34dfc0f74fbe41f4ecb402b2cd34884 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:13:33 +0200 Subject: Merging upstream version 125.0.1. Signed-off-by: Daniel Baumann --- browser/components/newtab/lib/ActivityStream.sys.mjs | 4 ++-- .../newtab/lib/ActivityStreamMessageChannel.sys.mjs | 2 +- .../components/newtab/lib/DiscoveryStreamFeed.sys.mjs | 19 +++++++++++++++++-- .../components/newtab/lib/DownloadsManager.sys.mjs | 2 +- .../newtab/lib/PersonalityProvider/RecipeExecutor.mjs | 4 ++-- browser/components/newtab/lib/PrefsFeed.sys.mjs | 4 ++-- .../newtab/lib/RecommendationProvider.sys.mjs | 2 +- browser/components/newtab/lib/SectionsManager.sys.mjs | 4 ++-- browser/components/newtab/lib/Store.sys.mjs | 2 +- browser/components/newtab/lib/TelemetryFeed.sys.mjs | 10 ++++++++-- browser/components/newtab/lib/TopSitesFeed.sys.mjs | 6 +++--- 11 files changed, 40 insertions(+), 19 deletions(-) (limited to 'browser/components/newtab/lib') diff --git a/browser/components/newtab/lib/ActivityStream.sys.mjs b/browser/components/newtab/lib/ActivityStream.sys.mjs index f2287fe45e..f46e8aadf0 100644 --- a/browser/components/newtab/lib/ActivityStream.sys.mjs +++ b/browser/components/newtab/lib/ActivityStream.sys.mjs @@ -306,7 +306,7 @@ export const PREFS_CONFIG = new Map([ "discoverystream.config", { title: "Configuration for the new pocket new tab", - getValue: ({ geo, locale }) => { + getValue: () => { return JSON.stringify({ api_key_pref: "extensions.pocket.oAuthConsumerKey", collapsible: true, @@ -689,7 +689,7 @@ export class ActivityStream { } } - observe(subject, topic, data) { + observe(subject, topic) { switch (topic) { case "intl:app-locales-changed": case lazy.Region.REGION_TOPIC: diff --git a/browser/components/newtab/lib/ActivityStreamMessageChannel.sys.mjs b/browser/components/newtab/lib/ActivityStreamMessageChannel.sys.mjs index de9d2cb800..5392a421ca 100644 --- a/browser/components/newtab/lib/ActivityStreamMessageChannel.sys.mjs +++ b/browser/components/newtab/lib/ActivityStreamMessageChannel.sys.mjs @@ -67,7 +67,7 @@ export class ActivityStreamMessageChannel { * @param {object} store A redux store * @return {function} Redux middleware */ - middleware(store) { + middleware() { return next => action => { const skipMain = action.meta && action.meta.skipMain; if (au.isSendToOneContent(action)) { diff --git a/browser/components/newtab/lib/DiscoveryStreamFeed.sys.mjs b/browser/components/newtab/lib/DiscoveryStreamFeed.sys.mjs index 257036b9da..ee08462503 100644 --- a/browser/components/newtab/lib/DiscoveryStreamFeed.sys.mjs +++ b/browser/components/newtab/lib/DiscoveryStreamFeed.sys.mjs @@ -331,7 +331,7 @@ export class DiscoveryStreamFeed { }, }); }, - error(error) {}, + error() {}, }); } } @@ -606,6 +606,13 @@ export class DiscoveryStreamFeed { ) { ctaButtonVariant = pocketConfig.ctaButtonVariant; } + let spocMessageVariant = ""; + if ( + pocketConfig.spocMessageVariant === "variant-a" || + pocketConfig.spocMessageVariant === "variant-b" + ) { + spocMessageVariant = pocketConfig.spocMessageVariant; + } const prepConfArr = arr => { return arr @@ -681,6 +688,9 @@ export class DiscoveryStreamFeed { // For now button variants are for experimentation and English only. ctaButtonSponsors: this.locale.startsWith("en-") ? ctaButtonSponsors : [], ctaButtonVariant: this.locale.startsWith("en-") ? ctaButtonVariant : "", + spocMessageVariant: this.locale.startsWith("en-") + ? spocMessageVariant + : "", }); sendUpdate({ @@ -2040,6 +2050,7 @@ export class DiscoveryStreamFeed { `onboardingExperience` Show new users some UI explaining Pocket above the Pocket section. `ctaButtonSponsors` An array of sponsors we want to show a cta button on the card for. `ctaButtonVariant` Sets the variant for the cta sponsor button. + `spocMessageVariant` Sets the variant for the sponsor message dialog. */ getHardcodedLayout = ({ spocsUrl = SPOCS_URL, @@ -2063,6 +2074,7 @@ getHardcodedLayout = ({ onboardingExperience = false, ctaButtonSponsors = [], ctaButtonVariant = "", + spocMessageVariant = "", }) => ({ lastUpdate: Date.now(), spocs: { @@ -2144,7 +2156,9 @@ getHardcodedLayout = ({ link_url: "https://getpocket.com/firefox/new_tab_learn_more", icon: "chrome://global/skin/icons/pocket.svg", }, - properties: {}, + properties: { + spocMessageVariant, + }, styles: { ".ds-message": "margin-bottom: -20px", }, @@ -2162,6 +2176,7 @@ getHardcodedLayout = ({ onboardingExperience, ctaButtonSponsors, ctaButtonVariant, + spocMessageVariant, }, widgets: { positions: widgetPositions.map(position => { diff --git a/browser/components/newtab/lib/DownloadsManager.sys.mjs b/browser/components/newtab/lib/DownloadsManager.sys.mjs index f095645d41..a9a57222ee 100644 --- a/browser/components/newtab/lib/DownloadsManager.sys.mjs +++ b/browser/components/newtab/lib/DownloadsManager.sys.mjs @@ -16,7 +16,7 @@ ChromeUtils.defineESModuleGetters(lazy, { const DOWNLOAD_CHANGED_DELAY_TIME = 1000; // time in ms to delay timer for downloads changed events export class DownloadsManager { - constructor(store) { + constructor() { this._downloadData = null; this._store = null; this._downloadItems = new Map(); diff --git a/browser/components/newtab/lib/PersonalityProvider/RecipeExecutor.mjs b/browser/components/newtab/lib/PersonalityProvider/RecipeExecutor.mjs index 4f420c0812..ed15f8a59a 100644 --- a/browser/components/newtab/lib/PersonalityProvider/RecipeExecutor.mjs +++ b/browser/components/newtab/lib/PersonalityProvider/RecipeExecutor.mjs @@ -161,7 +161,7 @@ export class RecipeExecutor { * Config: * Not configurable */ - conditionallyNmfTag(item, config) { + conditionallyNmfTag(item) { let nestedNmfTags = {}; let parentTags = {}; let parentWeights = {}; @@ -1052,7 +1052,7 @@ export class RecipeExecutor { } else if (config.operation === "overwrite") { op = (a, b) => b; } else if (config.operation === "count") { - op = (a, b) => a + 1; + op = a => a + 1; } else { return null; } diff --git a/browser/components/newtab/lib/PrefsFeed.sys.mjs b/browser/components/newtab/lib/PrefsFeed.sys.mjs index 1c6f9b0d45..bb2502ac55 100644 --- a/browser/components/newtab/lib/PrefsFeed.sys.mjs +++ b/browser/components/newtab/lib/PrefsFeed.sys.mjs @@ -79,7 +79,7 @@ export class PrefsFeed { /** * Handler for when experiment data updates. */ - onExperimentUpdated(event, reason) { + onExperimentUpdated() { const value = lazy.NimbusFeatures.newtab.getAllVariables() || {}; this.store.dispatch( ac.BroadcastToContent({ @@ -238,7 +238,7 @@ export class PrefsFeed { } } - observe(subject, topic, data) { + observe(subject, topic) { switch (topic) { case lazy.Region.REGION_TOPIC: this.store.dispatch( diff --git a/browser/components/newtab/lib/RecommendationProvider.sys.mjs b/browser/components/newtab/lib/RecommendationProvider.sys.mjs index 03e976544f..875c90492b 100644 --- a/browser/components/newtab/lib/RecommendationProvider.sys.mjs +++ b/browser/components/newtab/lib/RecommendationProvider.sys.mjs @@ -242,7 +242,7 @@ export class RecommendationProvider { ); } - async observe(subject, topic, data) { + async observe(subject, topic) { switch (topic) { case "idle-daily": await this.updatePersonalizationScores(); diff --git a/browser/components/newtab/lib/SectionsManager.sys.mjs b/browser/components/newtab/lib/SectionsManager.sys.mjs index 96bba0c9ea..069ddbb224 100644 --- a/browser/components/newtab/lib/SectionsManager.sys.mjs +++ b/browser/components/newtab/lib/SectionsManager.sys.mjs @@ -31,7 +31,7 @@ ChromeUtils.defineESModuleGetters(lazy, { * `${feed_pref_name}.options`. */ -const BUILT_IN_SECTIONS = ({ newtab, pocketNewtab }) => ({ +const BUILT_IN_SECTIONS = ({ pocketNewtab }) => ({ "feeds.section.topstories": options => ({ id: "topstories", pref: { @@ -107,7 +107,7 @@ const BUILT_IN_SECTIONS = ({ newtab, pocketNewtab }) => ({ shouldSendImpressionStats: true, dedupeFrom: ["highlights"], }), - "feeds.section.highlights": options => ({ + "feeds.section.highlights": () => ({ id: "highlights", pref: { titleString: { diff --git a/browser/components/newtab/lib/Store.sys.mjs b/browser/components/newtab/lib/Store.sys.mjs index 3a4fdfa98d..ea66c36f50 100644 --- a/browser/components/newtab/lib/Store.sys.mjs +++ b/browser/components/newtab/lib/Store.sys.mjs @@ -144,7 +144,7 @@ export class Store { this._messageChannel.simulateMessagesForExistingTabs(); } - async _initIndexedDB(telemetryKey) { + async _initIndexedDB() { // "snippets" is the name of one storage space, but these days it is used // not for snippet-related data (snippets were removed in bug 1715158), // but storage for impression or session data for all ASRouter messages. diff --git a/browser/components/newtab/lib/TelemetryFeed.sys.mjs b/browser/components/newtab/lib/TelemetryFeed.sys.mjs index 99bed168a8..1a9e9e3d34 100644 --- a/browser/components/newtab/lib/TelemetryFeed.sys.mjs +++ b/browser/components/newtab/lib/TelemetryFeed.sys.mjs @@ -714,8 +714,8 @@ export class TelemetryFeed { }); const session = this.sessions.get(au.getPortIdOfSender(action)); switch (action.data?.event) { - case "CLICK": - const { card_type, topic, recommendation_id, tile_id, shim } = + case "CLICK": { + const { card_type, topic, recommendation_id, tile_id, shim, feature } = action.data.value ?? {}; if ( action.data.source === "POPULAR_TOPICS" || @@ -725,6 +725,11 @@ export class TelemetryFeed { newtab_visit_id: session.session_id, topic, }); + } else if (action.data.source === "FEATURE_HIGHLIGHT") { + Glean.newtab.tooltipClick.record({ + newtab_visit_id: session.session_id, + feature, + }); } else if (["spoc", "organic"].includes(card_type)) { Glean.pocket.click.record({ newtab_visit_id: session.session_id, @@ -739,6 +744,7 @@ export class TelemetryFeed { } } break; + } case "SAVE_TO_POCKET": Glean.pocket.save.record({ newtab_visit_id: session.session_id, diff --git a/browser/components/newtab/lib/TopSitesFeed.sys.mjs b/browser/components/newtab/lib/TopSitesFeed.sys.mjs index db21411fdd..796211085b 100644 --- a/browser/components/newtab/lib/TopSitesFeed.sys.mjs +++ b/browser/components/newtab/lib/TopSitesFeed.sys.mjs @@ -165,7 +165,7 @@ class TopSitesTelemetry { {}, ...Object.entries(this.allSponsoredTiles) .filter( - ([k, v]) => + ([, v]) => v.display_fail_reason === null || v.display_fail_reason === undefined ) @@ -196,8 +196,8 @@ class TopSitesTelemetry { clearTilesForProvider(provider) { Object.entries(this.allSponsoredTiles) - .filter(([k, v]) => k.startsWith(provider)) - .map(([k, v]) => delete this.allSponsoredTiles[k]); + .filter(([k]) => k.startsWith(provider)) + .map(([k]) => delete this.allSponsoredTiles[k]); } _getAdvertiser(tile) { -- cgit v1.2.3