WS-2215 - Analytics tracking on UAS and IDCTA events - #14013
Conversation
There was a problem hiding this comment.
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 assertsparams.useris 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 sendsmy-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
constand 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;
hotinglok
left a comment
There was a problem hiding this comment.
Generally looks good, a few questions about why some parts are memoized. Checking sign-in status doesn't seem to be a particularly expensive operation if it's just checking for the existence of a cookie.
elvinasv
left a comment
There was a problem hiding this comment.
Looks good! Thanks for the changes
|
Closing this PR due to "unverified commit history" issue and raised new PR #14039 |
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
isSignedInandhashedIdto analytics model and event tracking types, ensuring these user properties are passed through all relevant functions and components, includingbuildReverbAnalyticsModel,buildReverbEventModel, and their respective parameter builders.Updated the
EventTrackingContextProviderand the main analytics entry point to useisSignedInandhashedIdavailable in analytics contexts and ensuring they're included in all analytics payloads.Component-Level Event Tracking Enhancements:
useViewTrackeranduseClickTrackerHandlerhooks intoAccountHeader,AccountPromotionalBanner, andSaveArticleButtoncomponents, 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:
isSignedInandhashedIdas 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.
UserID , Users, Visitors- these data in Piano is seen tracked because of this new addition ofisSignedinandhashedIDTesting
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