Skip to content

WS-2215 - Analytics tracking on UAS and IDCTA events#14013

Open
jinidev wants to merge 5 commits into
latestfrom
ws-2215-analytics-idcta-uas-new
Open

WS-2215 - Analytics tracking on UAS and IDCTA events#14013
jinidev wants to merge 5 commits into
latestfrom
ws-2215-analytics-idcta-uas-new

Conversation

@jinidev
Copy link
Copy Markdown
Contributor

@jinidev jinidev commented May 13, 2026

Resolves JIRA: https://bbc.atlassian.net/browse/WS-2215

Summary

Track UAS SaveForLater and IDCTA account‑related view and click events

Code changes

User Authentication Data Propagation:

  • Added isSignedIn and hashedId to analytics model and event tracking types, ensuring these user properties are passed through all relevant functions and components, including buildReverbAnalyticsModel, buildReverbEventModel, and their respective parameter builders.

  • Updated the EventTrackingContextProvider and the main analytics entry point to use the useUserTrackingData hook, making isSignedIn and hashedId available in analytics contexts and ensuring they're included in all analytics payloads.

Component-Level Event Tracking Enhancements:

  • Integrated useViewTracker and useClickTrackerHandler hooks into AccountHeader, AccountPromotionalBanner, and SaveArticleButton components, enabling detailed view and click analytics for these UI elements. This includes dynamic component naming for click events and passing relevant tracking data (such as resource IDs).

Analytics Hook Improvements:

  • Updated the click tracker handler to accept and forward isSignedIn and hashedId as part of event tracking data, ensuring user authentication state is included with each event.
    These changes collectively improve the granularity and accuracy of analytics, especially regarding user authentication state, and ensure that key user interactions are tracked in detail.

Testing

Event names :

SaveArticleButton :
save-article-button-click-save and save-article-button-click-remove for button clicks
save-article-button-view - for view
Piano dashboard - https://analytics.piano.io/dataquery/#/designer?reportid=69fc727210a9df2f7a011419

AccountPromotionalBanner:
account-promotional-banner - for view
account-promotional-banner-close - for closing
account-promotional-banner-sign-in - for signin click
account-promotional-banner-register - for register click

Account header:
account-header - for view
account-header-settings - for settings click
account-header-sign-in - for signin click
Piano Dashboard - https://analytics.piano.io/dataquery/#/designer?reportid=6a033bbb5e9acc6f81847ccb

MyNews page:
my_news.page - for the view of page
Piano dashboard -https://analytics.piano.io/dataquery/#/designer?reportid=69fde2d421b0d1e734c23d33

@jinidev jinidev marked this pull request as ready for review May 13, 2026 17:12
Copilot AI review requested due to automatic review settings May 13, 2026 17:12
@jinidev jinidev changed the title Ws 2215 analytics idcta uas new WS-2215 - Analytics tracking on UAS and IDCTA events May 13, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds UAS/IDCTA-related analytics data and component event tracking across account, save-for-later, and My News surfaces.

Changes:

  • Propagates signed-in state and hashed ID into Reverb page/event analytics models.
  • Adds view/click tracking to account header, account promotional banner, and save article button.
  • Adds ATI page analytics metadata for the Next.js My News page.

Reviewed changes

Copilot reviewed 19 out of 20 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
ws-nextjs-app/pages/[service]/my-news/MyNewsPage.tsx Renders ATIAnalytics for My News.
ws-nextjs-app/pages/[service]/my-news/index.page.tsx Adds My News ATI page identifier.
src/global.d.ts Updates bbcuser.getHashedId typing.
src/app/models/types/eventTracking.ts Adds user fields to event context type.
src/app/lib/analyticsUtils/sendBeacon/index.ts Supplies hashed ID to window.bbcuser.
src/app/lib/analyticsUtils/extractATITrackingProps/index.ts Extracts user fields from event context.
src/app/hooks/useUserTrackingData/index.ts Adds hook for signed-in/hash tracking data.
src/app/hooks/useCustomEventTracker/index.tsx Forwards user fields on custom events.
src/app/hooks/useClickTrackerHandler/index.jsx Forwards user fields on click events.
src/app/contexts/EventTrackingContext/index.tsx Adds user fields to event tracking context.
src/app/components/SaveArticleButton/index.tsx Adds save button view/click tracking.
src/app/components/ATIAnalytics/types.ts Extends analytics types with hashed ID.
src/app/components/ATIAnalytics/params/index.ts Passes user fields into page param building.
src/app/components/ATIAnalytics/params/buildParams/index.ts Includes user fields in page ATI params.
src/app/components/ATIAnalytics/index.tsx Reads user tracking data for page analytics.
src/app/components/ATIAnalytics/beacon/index.ts Passes user fields into event model building.
src/app/components/ATIAnalytics/atiUrl/index.ts Adds user fields to Reverb page/event payloads.
src/app/components/Account/AccountPromotionalBanner/index.tsx Adds banner view/click tracking.
src/app/components/Account/AccountHeader/index.tsx Adds account header view/click tracking.
scripts/bundleSize/bundleSizeConfig.js Updates bundle size lower bound.
Comments suppressed due to low confidence (3)

src/app/components/ATIAnalytics/atiUrl/index.ts:169

  • This also changes the default component-event user payload to include hashedId: null, while the existing event-model test asserts params.user is exactly { isSignedIn: false } (src/app/components/ATIAnalytics/atiUrl/index.client.test.ts:231-233). The tests need to be updated to cover the new field, or the field should be omitted when no hashed ID is available, otherwise CI will fail for the unchanged default event case.
      user: {
        isSignedIn,
        hashedId,

ws-nextjs-app/pages/[service]/my-news/index.page.tsx:52

  • The PR description/testing notes list the My News page-view event as my_news.page, but the implementation sends my-news.page. If the dashboard/query is configured for the underscore identifier, this page view will not be counted under the expected event name.
          atiAnalytics: {
            pageIdentifier: 'my-news.page',
          },

src/app/hooks/useUserTrackingData/index.ts:24

  • These values are reassigned inside the memo even though they can be derived immutably from the context and cookie values. This deviates from the repository guideline to prefer const and avoid reassignment where possible, and makes the signed-in/hash precedence a little harder to reason about.
    let isSignedIn = !!isSignedInFromContext;
    let hashedId: string | null = null;

Comment on lines +40 to +42
const viewTracker = useViewTracker({
componentName: 'save-article-button-view',
});
Comment on lines +22 to +24
const viewTracker = useViewTracker({
componentName: 'account-header',
});
Comment on lines +29 to +31
const viewTracker = useViewTracker({
componentName: 'account-promotional-banner',
});
Comment on lines 108 to +110
user: {
isSignedIn: false,
isSignedIn,
hashedId,
Comment on lines +19 to +23
const useUserTrackingData = (): UserTrackingData => {
const { isSignedIn: isSignedInFromContext } = use(AccountContext);

const trackingData = useMemo(() => {
let isSignedIn = !!isSignedInFromContext;
Comment on lines 43 to +52
pageType: MY_NEWS_PAGE,
status: OK,
timeOnServer: Date.now(),
pathname: `/${service}/my-news`,
pageData: {
metadata: {
type: MY_NEWS_PAGE,
atiAnalytics: {
pageIdentifier: 'my-news.page',
},
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.

2 participants