Skip to content

Fix Braze banner reentry and dismissal, integrate Braze banners into Feast contextual nudges#16415

Open
juabara wants to merge 2 commits into
mainfrom
feat/jm-braze-dismissals
Open

Fix Braze banner reentry and dismissal, integrate Braze banners into Feast contextual nudges#16415
juabara wants to merge 2 commits into
mainfrom
feat/jm-braze-dismissals

Conversation

@juabara

@juabara juabara commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR fixes two issues with the Braze Banners System and integrates it into Feast contextual nudges.

Banner dismissal fix

  • Adds hasDismissedRef guard to prevent double-dismissal via rapid clicks or duplicate postMessage events
  • Calls braze.dismissBanner(banner) on close so the SDK natively suppresses the banner for the user
  • Inverts the postMessage origin check to early-return on invalid origins (clearer and safer)
  • Adds BRAZE_BANNERS_SYSTEM:GET_CONTEXT message type so banner creatives can read page context

Banner reentry / stale placement fix

  • Tracks stale placements in a Set — failed or timed-out refreshes mark placements stale, preventing cached banners from rendering
  • Late-arriving refresh successes mark placements fresh again
  • canShowBrazeBannersSystem now checks isPlacementStale before showing a cached banner
  • refreshBanners now accepts specific placements instead of requesting all placements blindly
  • buildBrazeMessaging only calls refreshBanners when getPagePlacements() finds banner islands on the page, avoiding wasted refresh tokens

Feast contextual nudge integration

  • FeastContextualNudge now checks for a Braze banner at the nudge's placement and renders it via BrazeBannersSystemDisplay if available, falling back to the existing Feast nudge
  • ArticleRenderer assigns up to 5 evenly distributed nudge indices across recipe sections via getFeastNudgeIndex
  • Passes recipe context (recipe data, article title, page ID, dark mode, Adjust token) to the banner

Other

  • Bumps @braze/web-sdk from 6.5.0 to 6.9.0
  • Updates README with dismissal, stale placement, and GET_CONTEXT documentation
  • Adds unit tests for dismissal, stale placement, refresh ordering, and Feast nudge index assignment

…Feast nudges

- Guard against double-dismissal with hasDismissedRef; call braze.dismissBanner()
  on close so the SDK suppresses the banner natively
- Track stale placements to prevent rendering cached banners after a failed or
  timed-out refresh; late successes mark placements fresh again
- Only request placements that exist on the page via getPagePlacements()
- Invert postMessage origin check for early return on invalid origins
- Add GET_CONTEXT message type for banner creatives to read page context
- Integrate BrazeBannersSystemDisplay into FeastContextualNudge with fallback
- Assign up to 5 evenly distributed nudge indices in ArticleRenderer
- Bump @braze/web-sdk from 6.5.0 to 6.9.0
- Add unit tests for all changes
@juabara
juabara requested review from a team as code owners July 20, 2026 13:04
@juabara juabara added feature Departmental tracking: work on a new feature fix Departmental tracking: fix labels Jul 20, 2026
@github-actions

Copy link
Copy Markdown

Hello 👋! When you're ready to run Chromatic, please apply the run_chromatic label to this PR.

You will need to reapply the label each time you want to run Chromatic.

Click here to see the Chromatic project.

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Departmental tracking: work on a new feature fix Departmental tracking: fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant