Bug 1932183 – Pass followed sections to merino. r=home-newtab-reviewers,npypchenko
Differential Revision: https://phabricator.services.mozilla.com/D231758
This commit is contained in:
@@ -488,6 +488,13 @@ export const PREFS_CONFIG = new Map([
|
||||
value: true,
|
||||
},
|
||||
],
|
||||
[
|
||||
"discoverystream.sections.following",
|
||||
{
|
||||
title: "A comma-separated list of strings of followed section topics",
|
||||
value: "",
|
||||
},
|
||||
],
|
||||
[
|
||||
"discoverystream.spoc-positions",
|
||||
{
|
||||
|
||||
@@ -119,6 +119,7 @@ const PREF_CONTEXTUAL_CONTENT_FAKESPOT_CTA_URL =
|
||||
"discoverystream.contextualContent.fakespot.ctaUrl";
|
||||
|
||||
const PREF_SECTIONS_ENABLED = "discoverystream.sections.enabled";
|
||||
const PREF_SECTIONS_FOLLOWING = "discoverystream.sections.following";
|
||||
|
||||
let getHardcodedLayout;
|
||||
|
||||
@@ -1814,12 +1815,32 @@ export class DiscoveryStreamFeed {
|
||||
PREF_MERINO_FEED_EXPERIMENT
|
||||
);
|
||||
|
||||
// Raw string of followed topics, ex: "entertainment, news"
|
||||
const followedSectionsString = prefs[PREF_SECTIONS_FOLLOWING];
|
||||
|
||||
// Format followed sections into desired JSON shape for merino:
|
||||
// {
|
||||
// "sectionId": "business",
|
||||
// "isFollowed": true,
|
||||
// "isBlocked": false
|
||||
// }
|
||||
const followedSections = followedSectionsString
|
||||
? followedSectionsString.split(",").map(s => s.trim())
|
||||
: [];
|
||||
|
||||
const sections = followedSections.map(section => ({
|
||||
sectionId: section,
|
||||
isFollowed: true,
|
||||
isBlocked: false,
|
||||
}));
|
||||
|
||||
headers.append("content-type", "application/json");
|
||||
let body = {
|
||||
...(prefMerinoFeedExperiment ? this.getExperimentInfo() : {}),
|
||||
locale: this.locale,
|
||||
region: this.region,
|
||||
topics,
|
||||
sections,
|
||||
};
|
||||
|
||||
const sectionsEnabled = prefs[PREF_SECTIONS_ENABLED];
|
||||
|
||||
Reference in New Issue
Block a user