WS-2215 - Analytics tracking on UAS and IDCTA events#14013
Open
jinidev wants to merge 5 commits into
Open
Conversation
Contributor
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;
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', | ||
| }, |
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.
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 use theuseUserTrackingDatahook, makingisSignedInandhashedIdavailable 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.
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