Feast "Saved from web" recipe state - #16412
Open
andresilva-guardian wants to merge 30 commits into
Open
Conversation
…with text variables
…essibility and a margin
…ssion configuration
…thub.com/guardian/dotcom-rendering into afs/feast-contextual-nudge-braze-banners
…eastContextualNudge" This reverts commit e279321.
andresilva-guardian
changed the base branch from
main
to
afs/feast-contextual-nudge-braze-banners
July 20, 2026 09:17
…ze network requests
andresilva-guardian
marked this pull request as ready for review
July 21, 2026 15:06
|
Hello 👋! When you're ready to run Chromatic, please apply the You will need to reapply the label each time you want to run Chromatic. |
…722105844 in package.json and pnpm-lock.yaml
Base automatically changed from
afs/feast-contextual-nudge-braze-banners
to
main
July 27, 2026 10:44
Contributor
Author
|
@copilot resolve the merge conflicts in this pull request |
Merge conflicts resolved in 4 files:
TypeScript passes with no errors. |
…nd remove deprecated handler
… calls to use dynamic base URL
… tests accordingly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this change?
We have added support for checking and updating whether a recipe has already been saved to a reader's Feast "Saved from web" list.
On the client, we added
src/lib/feast/savedFromWeb.tswithgetFeastSavedFromTheWebRecipesandaddFeastRecipeToSavedFromWebList, which call a proxy route at/api/feast-saved-recipesthat forwards the reader's bearer token straight through to the Feast API's/v2/saved-from-webendpoints (GET, to check which recipe ids are saved; PUT/:recipeId, to add a recipe to the list). We go through a server-side proxy rather than calling the Feast API directly from the browser, since this sidesteps needing Feast API-side CORS configuration for browser origins.That proxy route is implemented in Frontend, not DCR. We originally added it as a DCR Express route, but DCR isn't on the reader-facing origin (
www.theguardian.com/m.code.dev-theguardian.com) — it's only ever called internally by Frontend for rendering. A route living solely in DCR is unreachable by a same-origin browserfetch(), so it was removed from DCR and reimplemented in Frontend instead, which does own that origin. See [frontend#TODO] for the Frontend-side implementation of/api/feast-saved-recipes.getFeastSavedFromTheWebRecipescaches in-flight and resolved requests by user id and recipe ids, so that when multipleFeastContextualNudgeislands hydrate on the same page, only one network request is made for the whole batch of recipe ids rather than one per nudge.We updated
ArticleRendererto compute the full list of recipe ids that will get a nudge on the page upfront and pass it to everyFeastContextualNudgeinstance asallNudgeRecipeIds. EachFeastContextualNudgethen uses this, together with the signed-in reader's id and access token, to fetch whether its own recipe is already saved, and passes anisRecipeSavedflag through to the Braze banner.We also added a
SaveFeastRecipeByIdmessage type toBrazeBannersSystem, so a Braze banner can ask DCR to save a Feast recipe to the reader's list on their behalf. This callsaddFeastRecipeToSavedFromWebListwith the reader's access token, logs the outcome, and posts the result back to the banner along with a custom Braze event (braze_banner_save_feast_recipe).Why?
We want Feast contextual nudges (and the Braze banners they render) to reflect whether a reader has already saved a given recipe from the web, and to let readers save a recipe directly from the banner. Batching the "is this saved?" check across all nudges on a page, and caching it, avoids making a separate network request per nudge when several appear on the same article.
Dependencies
guardian/frontendthat implements the/api/feast-saved-recipesproxy route (GET + PUT). Until that's merged and deployed,getFeastSavedFromTheWebRecipes/addFeastRecipeToSavedFromWebListwill 404, andFeastContextualNudgewill simply behave as if no recipe is ever saved (graceful fallback, no crash).How has this change been tested?
Screenshots