Skip to content

WS-2704: Add reverb params context provider#14120

Open
alex-magana wants to merge 64 commits into
latestfrom
TASK-initialize-reverb-globally
Open

WS-2704: Add reverb params context provider#14120
alex-magana wants to merge 64 commits into
latestfrom
TASK-initialize-reverb-globally

Conversation

@alex-magana

@alex-magana alex-magana commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Resolves JIRA: WS-2704

Arises from: #14071

Summary

In #14071, we identified an issue whereby the scroll depth tracker hook
caused page view beacons to be triggered with the incorrect values.

This is due to Reverb being initialised when the scroll depth tracker hook is created, instead
of the page view tracker as has been the case.

This PR introduces a high level ReverbParamsContext which infers the Reverb
values required to track events for given page. The inferred values are then persisted in
window.bbcpage by invoking setBBCPage. These values
are then availed to the page view events as well as component event tracking hooks
window.bbcpage is relied upon by Reverb's viewEvent and userActionEvent functions.

Code changes

Testing

  1. Visit the sample assets below.
http://localhost:7081/portuguese?renderer_env=live
http://localhost:7081/portuguese/articles/cly822lql0lo?renderer_env=live
http://localhost:7081/mundo/media-52123665?renderer_env=live
  1. ATI/Piano beacons should be observed under the Network tab.

Useful Links

@alex-magana alex-magana changed the title WS-2704 - Add reverb params context provider WS-2704: Add reverb params context provider Jun 11, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

presume this will be deleted on clean-up?

const accountContext = use(AccountContext);

useEffect(() => {
setBBCPage({ atiData, requestContext, serviceContext, accountContext });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have tests proving that bbcpage and bbcuser are populated correctly and updated when the page or account data changes? Might be worth adding if not

setBBCPage({ atiData, requestContext, serviceContext, accountContext });
}, [accountContext, atiData, requestContext, serviceContext]);

const value = useMemo(

@pvaliani pvaliani Jun 11, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this only exposes raw atiData. Would amp and canonical users still need to rebuild the Reverb parameters?

@alex-magana alex-magana Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracting Reverb parameters here means AMP and Canonical use-cases
can access the values provided by ReverbParamsContext. As such, we
won't need to rebuild them.

Comment thread ws-nextjs-app/pages/_app.page.tsx Outdated
</QueryProvider>
)}
</EventTrackingContextProvider>
<ReverbParamsContextProvider atiData={atiAnalytics}>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this provider receive the final Reverb params instead of raw page metadata? Article pages add experiment details and adjusted page titles later so those values might get lost

Comment thread ws-nextjs-app/next.config.js Outdated
// Dangerously allow production builds to successfully complete even if
// your project has TypeScript errors.
// !! WARN !!
ignoreBuildErrors: true,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added to facilitate Preview env deployments.

To be removed prior to merging the PR.

@alex-magana alex-magana marked this pull request as ready for review June 23, 2026 10:38

@louisearchibald louisearchibald left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the walkthrough on this today, looks good 🙌

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants