From 0611cface8f98da4e4d73697f1eabc6f24f5ab51 Mon Sep 17 00:00:00 2001 From: alex-magana Date: Mon, 8 Dec 2025 15:49:23 +0300 Subject: [PATCH 001/140] Delete buildATIPageTrackPath function --- .../components/ATIAnalytics/atiUrl/index.ts | 251 ------------------ 1 file changed, 251 deletions(-) diff --git a/src/app/components/ATIAnalytics/atiUrl/index.ts b/src/app/components/ATIAnalytics/atiUrl/index.ts index 5c639231f39..8208a30c649 100644 --- a/src/app/components/ATIAnalytics/atiUrl/index.ts +++ b/src/app/components/ATIAnalytics/atiUrl/index.ts @@ -34,257 +34,6 @@ import { * https://github.com/ampproject/amphtml/blob/master/spec/amp-var-substitutions.md#device-and-browser */ -export const buildATIPageTrackPath = ({ - appName, - contentId, - contentType, - language, - ldpThingIds, - ldpThingLabels, - pageIdentifier, - pageTitle, - producerId, - libraryVersion, - platform, - statsDestination, - timePublished, - timeUpdated, - categoryName, - campaigns, - nationsProducer, - ampExperimentName, - experimentVariant, -}: ATIPageTrackingProps) => { - const href = getHref(platform); - const referrer = getReferrer(platform); - const campaignType = getCampaignType(); - - // on AMP, variable substitutions are used in the value and they cannot be - // encoded: https://github.com/ampproject/amphtml/blob/master/spec/amp-var-substitutions.md - const disableEncodingDueToAmpSubstitution = platform === 'amp'; - - // We use amp variable substitutes to get the href and referrer and these cannot be manipulated - // For canonical, we have a requirement to encode the x5 and x6 value twice. Source issue: https://github.com/bbc/simorgh/pull/6593 - const x5Value = disableEncodingDueToAmpSubstitution - ? href - : href && encodeURIComponent(encodeURIComponent(href)); - const x6Value = disableEncodingDueToAmpSubstitution - ? referrer - : referrer && encodeURIComponent(encodeURIComponent(referrer)); - - const pageViewBeaconValues = [ - { - key: 's', - description: 'destination', - value: getDestination(platform, statsDestination), - wrap: false, - disableEncoding: disableEncodingDueToAmpSubstitution, - }, - { - key: 'idclient', - description: 'at user id', - value: getAtUserId(), - wrap: false, - }, - { - key: 's2', - description: 'producer', - value: producerId, - wrap: false, - }, - { - key: 'p', - description: 'page identifier', - value: pageIdentifier, - wrap: false, - }, - { - key: 'r', - description: 'screen resolution & colour depth', - value: getScreenInfo(platform), - wrap: false, - disableEncoding: disableEncodingDueToAmpSubstitution, - }, - { - key: 're', - description: 'browser/viewport resolution', - value: getBrowserViewPort(platform), - wrap: false, - disableEncoding: disableEncodingDueToAmpSubstitution, - }, - { - key: 'hl', - description: 'time', - value: getCurrentTime(platform), - wrap: false, - disableEncoding: disableEncodingDueToAmpSubstitution, - }, - { - key: 'lng', - description: 'device language', - value: getDeviceLanguage(platform), - wrap: false, - disableEncoding: disableEncodingDueToAmpSubstitution, - }, - { key: 'x1', description: 'content id', value: contentId, wrap: true }, - { - key: 'x2', - description: 'app type', - value: getAppType(platform), - wrap: true, - }, - { - key: 'x3', - description: 'app name', - value: platform === 'app' ? `${appName}-app` : appName, - wrap: true, - }, - { key: 'x4', description: 'language', value: language, wrap: true }, - { - key: 'x5', - description: 'url', - value: x5Value, - wrap: true, - disableEncoding: true, - }, - { - key: 'x6', - description: 'referrer url', - value: x6Value, - wrap: true, - disableEncoding: true, - }, - { key: 'x7', description: 'content type', value: contentType, wrap: true }, - { - key: 'x8', - description: 'library version', - value: libraryVersion, - wrap: true, - }, - { - key: 'x9', - description: 'page title', - value: sanitise(pageTitle), - wrap: true, - }, - { - key: 'x10', - description: "Which home nation's editorial team produced the content", - value: nationsProducer, - wrap: true, - }, - { - key: 'x11', - description: 'publication time', - value: timePublished, - wrap: true, - }, - { - key: 'x12', - description: 'updated time', - value: timeUpdated, - wrap: true, - }, - { - key: 'x13', - description: 'ldp things labels', - value: ldpThingLabels, - wrap: true, - }, - { - key: 'x14', - description: 'ldp things ids', - value: ldpThingIds, - wrap: true, - }, - { - key: 'x16', - description: 'campaigns', - value: (Array.isArray(campaigns) ? campaigns : []) - .map(({ campaignName }) => campaignName) - .join('~'), - wrap: true, - }, - { - key: 'x17', - description: 'category', - value: categoryName, - wrap: true, - }, - { - key: 'x18', - description: 'boolean - if locserve cookie value is defined', - value: isLocServeCookieSet(), - wrap: true, - }, - { - key: 'xto', - description: 'marketing campaign', - value: getATIMarketingString(href, campaignType), - wrap: false, - }, - ...(experimentVariant - ? [ - { - key: 'mv_test', - description: 'Top Bar OJs experiment', - value: 'Top Bar OJs experiment', - wrap: false, - disableEncoding: true, - }, - { - key: 'mv_creation', - description: 'Top Bar OJs variant', - value: `${experimentVariant}`, - wrap: false, - disableEncoding: true, - }, - ] - : []), - ...(ampExperimentName - ? [ - { - key: 'mv_test', - description: 'AMP experiment name', - value: `${ampExperimentName}`, - wrap: false, - disableEncoding: true, - }, - { - key: 'mv_creation', - description: 'AMP experiment variant name', - value: `VARIANT(${ampExperimentName})`, - wrap: false, - disableEncoding: true, - }, - ] - : []), - ...getRSSMarketingString(href, campaignType), - ...(onOnionTld() - ? [ - { - key: 'product_platform', - description: 'onion url', - value: 'tor-bbc', - }, - ] - : []), - ]; - - return getAtiUrl( - pageViewBeaconValues.concat({ - // the ref param should always be the last param because ATI will interpret it as part of the referrer URL - key: 'ref', - description: 'referrer url', - value: getReferrer(platform), - wrap: false, - // disable encoding for this parameter as ati does not appear to support - // decoding of the ref parameter - disableEncoding: true, - }), - ); -}; - export const buildATIEventTrackUrl = ({ pageIdentifier, producerId, From f8961614ea9f00d9ee105bac7476dd233cb703f9 Mon Sep 17 00:00:00 2001 From: alex-magana Date: Mon, 8 Dec 2025 16:10:23 +0300 Subject: [PATCH 002/140] Remove buildATIPageTrackPath page view tracking unit tests --- .../ATIAnalytics/atiUrl/index.client.test.ts | 200 ------------------ 1 file changed, 200 deletions(-) diff --git a/src/app/components/ATIAnalytics/atiUrl/index.client.test.ts b/src/app/components/ATIAnalytics/atiUrl/index.client.test.ts index c25b1477fb9..13055fa0d24 100644 --- a/src/app/components/ATIAnalytics/atiUrl/index.client.test.ts +++ b/src/app/components/ATIAnalytics/atiUrl/index.client.test.ts @@ -1,7 +1,6 @@ import { Platforms } from '#app/models/types/global'; import * as genericLabelHelpers from '../../../lib/analyticsUtils'; import { - buildATIPageTrackPath, buildATIEventTrackUrl, buildReverbAnalyticsModel, buildReverbEventModel, @@ -28,210 +27,11 @@ const analyticsUtilFunctions = [ { name: 'sanitise', source: genericLabelHelpers }, ]; -const marketingCampaignFunc = { - name: 'getCampaignType', - source: genericLabelHelpers, -}; - -const rssMarketingStringFunc = { - name: 'getRSSMarketingString', - source: genericLabelHelpers, -}; - describe('atiUrl', () => { afterEach(() => { jest.clearAllMocks(); }); - describe('getThingAttributes', () => { - beforeEach(() => { - analyticsUtilFunctions.push(marketingCampaignFunc); - analyticsUtilFunctions.push(rssMarketingStringFunc); - analyticsUtilFunctions.forEach(func => { - mockAndSet(func, null); - }); - mockAndSet(rssMarketingStringFunc, []); - }); - - it('should not add empty or null values', () => { - expect(buildATIPageTrackPath({})).toEqual(''); - }); - - it.each` - props | currentUrl | expectedValues - ${{ - appName: 'appName', - contentId: 'contentId', - contentType: 'contentType', - language: 'language', - ldpThingIds: 'ldpThingIds', - ldpThingLabels: 'ldpThingLabels', - pageIdentifier: 'pageIdentifier', - pageTitle: 'pageTitle', - platform: 'platform', - producerId: 'producerId', - timePublished: 'timePublished', - timeUpdated: 'timeUpdated', -}} | ${'https://www.bbc.com/mundo'} | ${['s2=producerId', 'p=pageIdentifier', 'x1=[contentId]', 'x3=[appName]', 'x4=[language]', 'x7=[contentType]', 'x11=[timePublished]', 'x12=[timeUpdated]', 'x13=[ldpThingLabels]', 'x14=[ldpThingIds]', 'xto=SEC------']} - ${{ - appName: 'appName', - contentId: 'contentId', - contentType: 'contentType', - language: 'language', - ldpThingIds: 'ldpThingIds', - ldpThingLabels: 'ldpThingLabels', - pageIdentifier: 'pageIdentifier', - pageTitle: 'pageTitle', - platform: 'platform', - producerId: 'producerId', - timePublished: 'timePublished', - timeUpdated: 'timeUpdated', -}} | ${'https://www.bbcnewsd73hkzno2ini43t4gblxvycyac5aw4gnv7t2rccijh7745uqd.onion/news'} | ${['s2=producerId', 'p=pageIdentifier', 'x1=[contentId]', 'x3=[appName]', 'x4=[language]', 'x7=[contentType]', 'x11=[timePublished]', 'x12=[timeUpdated]', 'x13=[ldpThingLabels]', 'x14=[ldpThingIds]', 'xto=SEC------', 'product_platform=tor-bbc']} - ${{ - appName: 'appName', - contentId: 'contentId', - contentType: 'contentType', - language: 'language', - ldpThingIds: 'ldpThingIds', - ldpThingLabels: 'ldpThingLabels', - pageIdentifier: 'pageIdentifier', - pageTitle: 'pageTitle', - platform: 'platform', - producerId: 'producerId', - timePublished: 'timePublished', - timeUpdated: 'timeUpdated', - ampExperimentName: 'someAmpExperiment', -}} | ${'https://www.bbc.com/news'} | ${['s2=producerId', 'p=pageIdentifier', 'x1=[contentId]', 'x3=[appName]', 'x4=[language]', 'x7=[contentType]', 'x11=[timePublished]', 'x12=[timeUpdated]', 'x13=[ldpThingLabels]', 'x14=[ldpThingIds]', 'xto=SEC------', 'mv_test=someAmpExperiment', 'mv_creation=VARIANT(someAmpExperiment)']} - `( - 'should take in optional props and add them as correct query params', - ({ props, currentUrl, expectedValues }) => { - mockAndSet(marketingCampaignFunc, 'sl'); - - jest - .spyOn(window.location, 'host', 'get') - .mockImplementation(() => new URL(currentUrl).host); - - const queryParams = buildATIPageTrackPath(props); - const queryParamsArray = splitUrl(queryParams); - expect(queryParamsArray).toStrictEqual(expectedValues); - }, - ); - - it('should call RSS marketing string function', () => { - mockAndSet(marketingCampaignFunc, 'RSS'); - mockAndSet(rssMarketingStringFunc, [ - { - key: 'src_medium', - description: 'rss campaign prefix', - value: 'RSS', - wrap: false, - }, - ]); - - const queryParams = buildATIPageTrackPath({}); - - const queryParamsArray = splitUrl(queryParams); - const expectedValues = ['src_medium=RSS']; - - expectedValues.forEach(value => - expect(queryParamsArray).toContain(value), - ); - }); - - it('should call relevant functions', () => { - analyticsUtilFunctions.forEach(func => { - mockAndSet(func, func.name); - }); - - mockAndSet(marketingCampaignFunc, 'email'); - - const queryParams = buildATIPageTrackPath({ - pageTitle: 'pageTitle', - // @ts-expect-error - required for testing purposes - platform: 'platform', - statsDestination: 'statsDestination', - }); - - const queryParamsArray = splitUrl(queryParams); - - expect(queryParamsArray).toEqual([ - 's=getDestination', - 'idclient=getAtUserId', - 'r=getScreenInfo', - 're=getBrowserViewPort', - 'hl=getCurrentTime', - 'lng=getDeviceLanguage', - 'x2=[getAppType]', - 'x5=[getHref]', - 'x6=[getReferrer]', - 'x9=[sanitise]', - 'x18=[isLocServeCookieSet]', - 'xto=-----%40', - 'ref=getReferrer', - ]); - }); - - it('should build query params for .app routes', () => { - analyticsUtilFunctions.forEach(func => { - mockAndSet(func, func.name); - }); - - mockAndSet(marketingCampaignFunc, 'email'); - - const queryParams = buildATIPageTrackPath({ - pageTitle: 'pageTitle', - platform: 'app', - statsDestination: 'statsDestination', - appName: 'news', - }); - - const queryParamsArray = splitUrl(queryParams); - - expect(queryParamsArray).toEqual([ - 's=getDestination', - 'idclient=getAtUserId', - 'r=getScreenInfo', - 're=getBrowserViewPort', - 'hl=getCurrentTime', - 'lng=getDeviceLanguage', - 'x2=[getAppType]', - 'x3=[news-app]', - 'x5=[getHref]', - 'x6=[getReferrer]', - 'x9=[sanitise]', - 'x18=[isLocServeCookieSet]', - 'xto=-----%40', - 'ref=getReferrer', - ]); - }); - - it('if ref param is provided, it should be the very last param so that ATI can interpret it correctly as part of the referrer URL', () => { - analyticsUtilFunctions.forEach(func => { - mockAndSet(func, func.name); - }); - - const lastParam = splitUrl( - buildATIPageTrackPath({ - appName: 'appName', - contentId: 'contentId', - contentType: 'contentType', - language: 'language', - ldpThingIds: 'ldpThingIds', - ldpThingLabels: 'ldpThingLabels', - pageIdentifier: 'pageIdentifier', - pageTitle: 'pageTitle', - // @ts-expect-error - required for testing purposes - platform: 'platform', - producerId: 'producerId', - timePublished: 'timePublished', - timeUpdated: 'timeUpdated', - }), - ).pop(); - - expect(lastParam).toEqual('ref=getReferrer'); - }); - }); - describe('buildATIEventTrackUrl', () => { beforeEach(() => { analyticsUtilFunctions.forEach(func => { From 1e5c7ab630484684a28fe018871928fef62d3c0d Mon Sep 17 00:00:00 2001 From: alex-magana Date: Mon, 8 Dec 2025 16:30:50 +0300 Subject: [PATCH 003/140] Delete buildATIPageTrackPath and buildPageATIUrl --- .../ATIAnalytics/params/buildParams/index.ts | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/app/components/ATIAnalytics/params/buildParams/index.ts b/src/app/components/ATIAnalytics/params/buildParams/index.ts index 3b114dffb6d..e68f62f16f7 100644 --- a/src/app/components/ATIAnalytics/params/buildParams/index.ts +++ b/src/app/components/ATIAnalytics/params/buildParams/index.ts @@ -1,5 +1,5 @@ import { LIBRARY_VERSION } from '../../../../lib/analyticsUtils'; -import { buildATIPageTrackPath, buildReverbAnalyticsModel } from '../../atiUrl'; +import { buildReverbAnalyticsModel } from '../../atiUrl'; import { ATIDataWithContexts } from '../../types'; export const buildPageATIParams = ({ @@ -61,15 +61,6 @@ export const buildPageATIParams = ({ }; }; -export const buildPageATIUrl = ({ - atiData, - requestContext, - serviceContext, -}: ATIDataWithContexts) => - buildATIPageTrackPath( - buildPageATIParams({ atiData, requestContext, serviceContext }), - ); - export const buildPageReverbParams = ({ atiData, requestContext, From 509ac33af4b20377ea54a9efc477b9233d1ab971 Mon Sep 17 00:00:00 2001 From: alex-magana Date: Mon, 8 Dec 2025 17:34:46 +0300 Subject: [PATCH 004/140] Delete buildPageATIUrl unit tests --- .../params/buildParams/index.test.ts | 352 +----------------- 1 file changed, 2 insertions(+), 350 deletions(-) diff --git a/src/app/components/ATIAnalytics/params/buildParams/index.test.ts b/src/app/components/ATIAnalytics/params/buildParams/index.test.ts index c0c3c7d2707..773158e38e1 100644 --- a/src/app/components/ATIAnalytics/params/buildParams/index.test.ts +++ b/src/app/components/ATIAnalytics/params/buildParams/index.test.ts @@ -2,7 +2,7 @@ import { TOPIC_PAGE } from '#app/routes/utils/pageTypes'; import * as analyticsUtils from '#lib/analyticsUtils'; import { RequestContextProps } from '../../../../contexts/RequestContext'; import { ServiceConfig } from '../../../../models/types/serviceConfig'; -import { buildPageATIParams, buildPageATIUrl } from '.'; +import { buildPageATIParams } from '.'; (analyticsUtils.getAtUserId as jest.Mock) = jest.fn(); (analyticsUtils.getCurrentTime as jest.Mock) = jest @@ -33,7 +33,7 @@ const serviceContext: ServiceConfig = { lang: 'pcm', }; -describe('implementation of buildPageATIParams and buildPageATIUrl', () => { +describe('implementation of buildPageATIParams', () => { afterEach(() => { jest.clearAllMocks(); }); @@ -88,40 +88,6 @@ describe('implementation of buildPageATIParams and buildPageATIUrl', () => { }); expect(result).toEqual(validPageURLParams); }); - - it('should return the correct url for a page given the ATI configuration', () => { - const url = buildPageATIUrl({ - atiData: homePageAtiData, - requestContext, - serviceContext, - }); - - const parsedATIURLParams = Object.fromEntries( - new URLSearchParams(url as string), - ); - - const expectedATIURLParams = { - s: '598285', - s2: 'atiAnalyticsProducerId', - p: 'kyrgyz.page', - r: '0x0x24x24', - re: '1024x768', - ref: 'https://www.example.com', - hl: '00-00-00', - lng: 'en-US', - x1: '[urn:bbc:tipo:topic:cm7682qz7v1t]', - x2: '[responsive]', - x3: '[atiAnalyticsAppName]', - x4: '[pcm]', - x5: '[http%3A%2F%2Flocalhost%2F]', - x6: '[https%3A%2F%2Fwww.example.com]', - x7: '[index-home]', - x8: '[simorgh]', - x9: '[pageTitle]', - }; - - expect(parsedATIURLParams).toEqual(expectedATIURLParams); - }); }); describe('Article Page', () => { @@ -191,49 +157,6 @@ describe('implementation of buildPageATIParams and buildPageATIUrl', () => { expect(result).toEqual(validPageURLParams); }); - it('should return the correct url for a page given the ATI configuration', () => { - const url = buildPageATIUrl({ - atiData: articlePageAtiData, - requestContext: { - ...requestContext, - isUK: false, - pageType: 'article', - }, - serviceContext: { ...serviceContext, service: 'burmese', lang: 'my' }, - }); - - const parsedATIURLParams = Object.fromEntries( - new URLSearchParams(url as string), - ); - - const expectedATIURLParams = { - s: '598285', - s2: 'atiAnalyticsProducerId', - p: 'burmese.articles.c9wxnzvwp3mo.page', - r: '0x0x24x24', - re: '1024x768', - ref: 'https://www.example.com', - hl: '00-00-00', - lng: 'en-US', - x1: '[urn:bbc:optimo:asset:c9wxnzvwp3mo]', - x2: '[responsive]', - x3: '[atiAnalyticsAppName]', - x4: '[my]', - x5: '[http%3A%2F%2Flocalhost%2F]', - x6: '[https%3A%2F%2Fwww.example.com]', - x7: '[article]', - x8: '[simorgh]', - x9: '[ဇူလိုင်လ%20၁၃%20ရက်ထိပ်တန်းသတင်းများ-%20ဒုက္ခသည်စခန်းဗုံးကြဲခံရလို့%20ထိုင်းကိုထွက်ပြေးသူတွေဆက်ရှိ]', - x11: '[2023-07-13T05:03:56.214Z]', - x12: '[2023-07-13T08:35:47.388Z]', - x13: '[Refugees%20and%20asylum%20seekers~Myanmar~Military]', - x14: '[0cd55773-e753-44ad-ad07-1366bf1aa6bc~a26174f5-fa3c-4cf8-95a2-29d877175eab~ce5c43ee-8982-4f88-9472-9aa79aeb09cc]', - x17: '[Refugees%20and%20asylum%20seekers~Myanmar~Military]', - }; - - expect(parsedATIURLParams).toEqual(expectedATIURLParams); - }); - it('should return ampExperimentName only if it is present in atiData', () => { const result = buildPageATIParams({ atiData: { @@ -307,49 +230,6 @@ describe('implementation of buildPageATIParams and buildPageATIUrl', () => { }); expect(result).toEqual(validPageURLParams); }); - - it('should return the correct url for a page given the ATI configuration', () => { - const url = buildPageATIUrl({ - atiData: optimoMediaArticlePageAtiData, - requestContext: { - ...requestContext, - isUK: false, - pageType: 'article', - }, - serviceContext: { ...serviceContext, service: 'hausa', lang: 'ha' }, - }); - - const parsedATIURLParams = Object.fromEntries( - new URLSearchParams(url as string), - ); - - const expectedATIURLParams = { - s: '598285', - s2: 'atiAnalyticsProducerId', - p: 'hausa.articles.c4nrpd0d4nro.page', - r: '0x0x24x24', - re: '1024x768', - ref: 'https://www.example.com', - hl: '00-00-00', - lng: 'en-US', - x1: '[urn:bbc:optimo:asset:c4nrpd0d4nro]', - x2: '[responsive]', - x3: '[atiAnalyticsAppName]', - x4: '[ha]', - x5: '[http%3A%2F%2Flocalhost%2F]', - x6: '[https%3A%2F%2Fwww.example.com]', - x7: '[article-sfv]', - x8: '[simorgh]', - x9: '[Kalli%20yadda%20ambaliya%20ta%20tagayyara%20wani%20yanki%20na%20Indiya]', - x11: '[2023-07-11T17:42:48.771Z]', - x12: '[2023-07-11T17:42:48.771Z]', - x13: '[Environment~Narendra+Modi~Nature~India~Severe+weather]', - x14: '[0f37fb35-7f9e-4e49-b189-9d7f1d6fb11f~103fc7e4-3a8d-491c-9a75-3c37c299d48f~12e69b92-a7ba-4463-84e0-be107b9805d0~5a08f030-710f-4168-acee-67294a90fc75~9b16a6c2-7c16-42b7-bff7-6549579622e8]', - x17: '[Environment~Narendra+Modi~Nature~India~Severe+weather]', - }; - - expect(parsedATIURLParams).toEqual(expectedATIURLParams); - }); }); describe('Topic Page', () => { @@ -402,40 +282,6 @@ describe('implementation of buildPageATIParams and buildPageATIUrl', () => { }); expect(result).toEqual(validPageURLParams); }); - - it('should return the correct url for a page given the ATI configuration', () => { - const url = buildPageATIUrl({ - atiData: topicPageAtiData, - requestContext, - serviceContext, - }); - - const parsedATIURLParams = Object.fromEntries( - new URLSearchParams(url as string), - ); - - const expectedATIURLParams = { - s: '598285', - s2: 'atiAnalyticsProducerId', - p: 'pidgin.topics.c95y35941vrt.page', - r: '0x0x24x24', - re: '1024x768', - ref: 'https://www.example.com', - hl: '00-00-00', - lng: 'en-US', - x1: '[urn:bbc:tipo:topic:c95y35941vrt]', - x2: '[responsive]', - x3: '[atiAnalyticsAppName]', - x4: '[pcm]', - x5: '[http%3A%2F%2Flocalhost%2F]', - x6: '[https%3A%2F%2Fwww.example.com]', - x7: '[index-category]', - x8: '[simorgh]', - x9: '[Donald%20Trump]', - }; - - expect(parsedATIURLParams).toEqual(expectedATIURLParams); - }); }); describe('Most Read Page', () => { @@ -489,41 +335,6 @@ describe('implementation of buildPageATIParams and buildPageATIUrl', () => { }); expect(result).toEqual(validPageURLParams); }); - - it('should return the correct url for a page given the ATI configuration', () => { - const url = buildPageATIUrl({ - atiData: mostReadPageAtiData, - requestContext, - serviceContext, - }); - - const parsedATIURLParams = Object.fromEntries( - new URLSearchParams(url as string), - ); - - const expectedATIURLParams = { - s: '598285', - s2: 'atiAnalyticsProducerId', - p: 'pidgin.popular.read.page', - r: '0x0x24x24', - re: '1024x768', - ref: 'https://www.example.com', - hl: '00-00-00', - lng: 'en-US', - x2: '[responsive]', - x3: '[atiAnalyticsAppName]', - x4: '[pcm]', - x5: '[http%3A%2F%2Flocalhost%2F]', - x6: '[https%3A%2F%2Fwww.example.com]', - x7: '[list-datadriven]', - x8: '[simorgh]', - x9: '[MostReadPageTitle]', - x11: '[2023-08-01T12:00:00Z]', - x12: '[2023-08-01T12:15:00Z]', - }; - - expect(parsedATIURLParams).toEqual(expectedATIURLParams); - }); }); describe('CPS Page', () => { @@ -602,46 +413,6 @@ describe('implementation of buildPageATIParams and buildPageATIUrl', () => { }); expect(result).toEqual(validPageURLParams); }); - - it('should return the correct url for a page given the ATI configuration', () => { - const url = buildPageATIUrl({ - atiData: cpsSTYAtiData, - requestContext, - serviceContext, - }); - - const parsedATIURLParams = Object.fromEntries( - new URLSearchParams(url as string), - ); - - const expectedATIURLParams = { - hl: '00-00-00', - lng: 'en-US', - p: 'latin_america::mundo.latin_america.story.64591782.page', - r: '0x0x24x24', - re: '1024x768', - ref: 'https://www.example.com', - s: '598285', - s2: 'atiAnalyticsProducerId', - x1: '[urn:bbc:cps:curie:asset:3137d6de-62c2-4637-a002-29d2ab075990]', - x2: '[responsive]', - x3: '[atiAnalyticsAppName]', - x4: '[es]', - x5: '[http%3A%2F%2Flocalhost%2F]', - x6: '[https%3A%2F%2Fwww.example.com]', - x7: '[article]', - x8: '[simorgh]', - x9: '[4%20claves%20para%20entender%20la%20"sorpresiva"%20liberación%20y%20envío%20a%20EE.UU.%20de%20222%20opositores%20nicaragüenses%20-%20BBC%20News%20Mundo]', - x11: '[2023-02-10T02:00:41.000Z]', - x12: '[2023-02-10T02:00:41.000Z]', - x13: '[Politics~Nicaragua~Latin+America]', - x14: '[75612fa6-147c-4a43-97fa-fcf70d9cced3~7613abe4-1c05-4594-a5ec-3ccf6268b220~e0d04166-b92f-468e-9e68-d5f9330e6ae7]', - x16: '[WS - Update me]', - x17: '[Explainer]', - }; - - expect(parsedATIURLParams).toEqual(expectedATIURLParams); - }); }); describe('MAP', () => { @@ -717,46 +488,6 @@ describe('implementation of buildPageATIParams and buildPageATIUrl', () => { }); expect(result).toEqual(validPageURLParams); }); - - it('should return the correct url for a page given the ATI configuration', () => { - const url = buildPageATIUrl({ - atiData: cpsMAPAtiData, - requestContext, - serviceContext, - }); - - const parsedATIURLParams = Object.fromEntries( - new URLSearchParams(url as string), - ); - - const expectedATIURLParams = { - hl: '00-00-00', - lng: 'en-US', - p: 'media::mundo.media.media_asset.41174775.page', - r: '0x0x24x24', - re: '1024x768', - ref: 'https://www.example.com', - s: '598285', - s2: 'atiAnalyticsProducerId', - x1: '[urn:bbc:cps:curie:asset:6d745333-c79d-e245-a5b2-f4acb7de35e1]', - x2: '[responsive]', - x3: '[atiAnalyticsAppName]', - x4: '[es]', - x5: '[http%3A%2F%2Flocalhost%2F]', - x6: '[https%3A%2F%2Fwww.example.com]', - x7: '[article-media-asset]', - x8: '[simorgh]', - x9: '[¿Qué%20es%20el%20albur%20en%20México%20y%20cómo%20puedes%20saber%20si%20te%20están%20"albureando"?]', - x11: '[2017-09-14T14:09:14.000Z]', - x12: '[2017-09-14T14:09:14.000Z]', - x13: '[Politics~Nicaragua~Latin+America]', - x14: '[75612fa6-147c-4a43-97fa-fcf70d9cced3~7613abe4-1c05-4594-a5ec-3ccf6268b220~e0d04166-b92f-468e-9e68-d5f9330e6ae7]', - x16: '[WS - Update me]', - x17: '[News]', - }; - - expect(parsedATIURLParams).toEqual(expectedATIURLParams); - }); }); describe('PGL', () => { @@ -830,46 +561,6 @@ describe('implementation of buildPageATIParams and buildPageATIUrl', () => { }); expect(result).toEqual(validPageURLParams); }); - - it('should return the correct url for a page given the ATI configuration', () => { - const url = buildPageATIUrl({ - atiData: cpsPGLAtiData, - requestContext, - serviceContext, - }); - - const parsedATIURLParams = Object.fromEntries( - new URLSearchParams(url as string), - ); - - const expectedATIURLParams = { - hl: '00-00-00', - lng: 'en-US', - p: 'sport::mundo.sport.photo_gallery.36935058.page', - r: '0x0x24x24', - re: '1024x768', - ref: 'https://www.example.com', - s: '598285', - s2: 'atiAnalyticsProducerId', - x1: '[urn:bbc:cps:curie:asset:08e22e90-7361-cd47-b586-7cb53fc5a012]', - x2: '[responsive]', - x3: '[atiAnalyticsAppName]', - x4: '[es]', - x5: '[http%3A%2F%2Flocalhost%2F]', - x6: '[https%3A%2F%2Fwww.example.com]', - x7: '[article-photo-gallery]', - x8: '[simorgh]', - x9: '[Río%202016,%20el%20antes%20y%20el%20ahora:%20cómo%20ha%20cambiado%20la%20ropa%20deportiva%20en%20más%20de%20un%20siglo%20de%20juegos%20olímpicos]', - x11: '[2016-08-07T09:21:02.000Z]', - x12: '[2016-08-07T09:21:02.000Z]', - x13: '[Technology]', - x14: '[25844b6e-80b0-4de9-8ea0-7a35e7d4086f]', - x16: '[WS - Divert me]', - x17: '[News]', - }; - - expect(parsedATIURLParams).toEqual(expectedATIURLParams); - }); }); describe('CSP', () => { @@ -970,45 +661,6 @@ describe('implementation of buildPageATIParams and buildPageATIUrl', () => { }; expect(result).toEqual(expectedParamsWithOverride); }); - - it('should return the correct url for a page given the ATI configuration', () => { - const url = buildPageATIUrl({ - atiData: cpsCSPAtiData, - requestContext, - serviceContext, - }); - - const parsedATIURLParams = Object.fromEntries( - new URLSearchParams(url as string), - ); - - const expectedATIURLParams = { - hl: '00-00-00', - lng: 'en-US', - p: 'technology::news.technology.correspondent_story.56294493.page', - r: '0x0x24x24', - re: '1024x768', - ref: 'https://www.example.com', - s: '598285', - s2: '64', - x1: '[urn:bbc:cps:curie:asset:c1c8b1bf-4c9c-44e8-be0d-c81a2aa59e46]', - x2: '[responsive]', - x3: '[atiAnalyticsAppName]', - x4: '[en-gb]', - x5: '[http%3A%2F%2Flocalhost%2F]', - x6: '[https%3A%2F%2Fwww.example.com]', - x7: '[article-correspondent]', - x8: '[simorgh]', - x9: "[Tech%20Tent:%20The%20new%20'space%20race'%20for%20computer%20chips]", - x11: '[2021-03-05T13:37:50.000Z]', - x12: '[2021-03-05T13:37:50.000Z]', - x13: '[Intel~Technology+of+business~Business~Technology~Car+industry~China~Taiwan~Computer+chip~Semiconductors]', - x14: '[0d358111-576d-4d61-a7c7-e2e71931b579~2c493367-e5a2-4c19-be5f-6e9342f5c591~2f2db234-3c2d-40a4-b4ac-eea661faadd0~31684f19-84d6-41f6-b033-7ae08098572a~65ba56b4-3f50-4217-ab8e-b3c1fe890364~6892384e-1966-4c03-9ce3-f694a8f9f69e~7a48b6e0-9074-4303-ae82-011003058e16~b054a2d3-6c1e-44de-b8db-0e2501c035c0~f7bf39da-286c-4e37-8ee0-a01395f09ac2]', - x17: '[News]', - }; - - expect(parsedATIURLParams).toEqual(expectedATIURLParams); - }); }); }); }); From 43b553342396fd26aaba69a8d4d8b9963c999c0a Mon Sep 17 00:00:00 2001 From: alex-magana Date: Mon, 8 Dec 2025 17:37:42 +0300 Subject: [PATCH 005/140] Remove buildATIUrl and buildPageATIUrl functions --- src/app/components/ATIAnalytics/params/index.ts | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/app/components/ATIAnalytics/params/index.ts b/src/app/components/ATIAnalytics/params/index.ts index 3d41f55d00a..fb810e54d3f 100644 --- a/src/app/components/ATIAnalytics/params/index.ts +++ b/src/app/components/ATIAnalytics/params/index.ts @@ -1,21 +1,9 @@ -import { - buildPageATIUrl, - buildPageATIParams, - buildPageReverbParams, -} from './buildParams'; +import { buildPageATIParams, buildPageReverbParams } from './buildParams'; import { ATIConfigurationDetailsProviders, ReverbDetailsProviders, } from '../types'; -export const buildATIUrl = ({ - requestContext, - serviceContext, - atiData, -}: ATIConfigurationDetailsProviders) => { - return buildPageATIUrl({ atiData, requestContext, serviceContext }); -}; - export const buildReverbParams = ({ requestContext, serviceContext, From e7ff184d1c0105c9e389f136b6fc506b155066d5 Mon Sep 17 00:00:00 2001 From: alex-magana Date: Mon, 8 Dec 2025 17:49:27 +0300 Subject: [PATCH 006/140] Delete buildPageATIUrl integration test --- .../ATIAnalytics/params/index.test.ts | 29 ------------------- 1 file changed, 29 deletions(-) diff --git a/src/app/components/ATIAnalytics/params/index.test.ts b/src/app/components/ATIAnalytics/params/index.test.ts index 5daacbfd4e2..0bb9e123d98 100644 --- a/src/app/components/ATIAnalytics/params/index.test.ts +++ b/src/app/components/ATIAnalytics/params/index.test.ts @@ -354,35 +354,6 @@ describe('ATIAnalytics params', () => { expect(params).not.toContain('x6='); expect(params).not.toContain('ref='); }); - - describe('buildPageATIUrl invocation', () => { - let buildPageATIUrlSpy: jest.SpyInstance; - - beforeEach(() => { - buildPageATIUrlSpy = jest.spyOn( - buildPageATIFunctionImports, - 'buildPageATIUrl', - ); - - jest.clearAllMocks(); - }); - - it('should invoke buildPageATIUrl for supported page types', () => { - buildATIUrl({ - requestContext: { ...requestContext, pageType: HOME_PAGE }, - atiData: homePageAnalyticsData, - serviceContext, - }); - - expect(buildPageATIUrlSpy).toHaveBeenCalledWith( - expect.objectContaining({ - requestContext: { ...requestContext, pageType: HOME_PAGE }, - atiData: homePageAnalyticsData, - serviceContext, - }), - ); - }); - }); }); describe('buildATIEventTrackingParams', () => { From e5c089c2176fe77cc017d74eda41e214a1d5a90e Mon Sep 17 00:00:00 2001 From: alex-magana Date: Mon, 8 Dec 2025 18:00:40 +0300 Subject: [PATCH 007/140] Delete buildATIUrl unit tests --- .../ATIAnalytics/params/index.test.ts | 232 +----------------- 1 file changed, 1 insertion(+), 231 deletions(-) diff --git a/src/app/components/ATIAnalytics/params/index.test.ts b/src/app/components/ATIAnalytics/params/index.test.ts index 0bb9e123d98..f64b49d606b 100644 --- a/src/app/components/ATIAnalytics/params/index.test.ts +++ b/src/app/components/ATIAnalytics/params/index.test.ts @@ -7,7 +7,7 @@ import { MEDIA_ARTICLE_PAGE, HOME_PAGE, } from '../../../routes/utils/pageTypes'; -import { buildATIUrl, buildATIEventTrackingParams } from '.'; +import { buildATIEventTrackingParams } from '.'; import * as buildPageATIFunctionImports from './buildParams'; import { RequestContextProps } from '../../../contexts/RequestContext'; import { ServiceConfig } from '../../../models/types/serviceConfig'; @@ -126,236 +126,6 @@ const cpsPGLPageAnalyticsData: ATIData = { }; describe('ATIAnalytics params', () => { - describe('buildATIUrl', () => { - it('should return the correct article url', () => { - const url = buildATIUrl({ - requestContext: { ...requestContext, pageType: ARTICLE_PAGE }, - atiData: articlePageAnalyticsData, - serviceContext, - }); - - const parsedATIURLParams = Object.fromEntries( - new URLSearchParams(url as string), - ); - - const expectedATIURLParams = { - s: '598285', - s2: 'atiAnalyticsProducerId', - p: 'pidgin.articles.crgrx86em6yo.page', - r: '0x0x24x24', - re: '1024x768', - hl: '00-00-00', - lng: 'en-US', - x1: '[urn:bbc:optimo:asset:crgrx86em6yo]', - x2: '[responsive]', - x3: '[atiAnalyticsAppName]', - x4: '[pcm]', - x5: '[http%3A%2F%2Flocalhost%2F]', - x6: '[https%3A%2F%2Fwww.example.com]', - x7: '[article]', - x8: '[simorgh]', - x9: '[Aminat%20Yusuf:%20Tips%20to%20pass%20exam%20-%20Overall%20LASU%20best%20graduate%20drop%20update]', - x10: '[scotland]', - x11: '[2023-07-19T15:57:54.500Z]', - x12: '[2023-07-19T15:57:54.500Z]', - x13: '[Nigeria~Education~Lagos%20state~Women]', - x14: '[3d5d5e30-dd50-4041-96d5-c970b20005b9~6942cb29-9d3f-4c9c-9806-0a0578c286d6~d651d520-a675-4911-8832-1596f257000b~e45cb5f8-3c87-4ebd-ac1c-058e9be22862]', - x17: '[Nigeria~Education~Lagos%20state~Women]', - ref: 'https://www.example.com', - }; - - expect(parsedATIURLParams).toEqual(expectedATIURLParams); - }); - - it('should return the correct media article url', () => { - const url = buildATIUrl({ - requestContext: { ...requestContext, pageType: MEDIA_ARTICLE_PAGE }, - atiData: mediaArticlePageAnalyticsData, - serviceContext, - }); - - const parsedATIParams = Object.fromEntries( - new URLSearchParams(url as string), - ); - - expect(parsedATIParams).toEqual({ - s: '598285', - s2: 'atiAnalyticsProducerId', - p: 'hausa.articles.c4nrpd0d4nro.page', - r: '0x0x24x24', - re: '1024x768', - hl: '00-00-00', - lng: 'en-US', - x1: '[urn:bbc:optimo:asset:c4nrpd0d4nro]', - x2: '[responsive]', - x3: '[atiAnalyticsAppName]', - x4: '[ha]', - x5: '[http%3A%2F%2Flocalhost%2F]', - x6: '[https%3A%2F%2Fwww.example.com]', - x7: '[article-sfv]', - x8: '[simorgh]', - x9: '[Kalli%20yadda%20ambaliya%20ta%20tagayyara%20wani%20yanki%20na%20Indiya]', - x11: '[2023-07-11T17:42:48.771Z]', - x12: '[2023-07-11T17:42:48.771Z]', - x13: '[Environment~Narendra+Modi~Nature~India~Severe+weather]', - x14: '[0f37fb35-7f9e-4e49-b189-9d7f1d6fb11f~103fc7e4-3a8d-491c-9a75-3c37c299d48f~12e69b92-a7ba-4463-84e0-be107b9805d0~5a08f030-710f-4168-acee-67294a90fc75~9b16a6c2-7c16-42b7-bff7-6549579622e8]', - x17: '[Environment~Narendra+Modi~Nature~India~Severe+weather]', - ref: 'https://www.example.com', - }); - }); - - it('should return the correct MAP url', () => { - const url = buildATIUrl({ - requestContext: { ...requestContext, pageType: MEDIA_ASSET_PAGE }, - atiData: cpsMAPPageAnalyticsData, - serviceContext, - }); - - const parsedATIURLParams = Object.fromEntries( - new URLSearchParams(url as string), - ); - - const expectedATIURLParams = { - hl: '00-00-00', - lng: 'en-US', - p: 'media::mundo.media.media_asset.41174775.page', - r: '0x0x24x24', - re: '1024x768', - ref: 'https://www.example.com', - s: '598285', - s2: 'atiAnalyticsProducerId', - x1: '[urn:bbc:cps:4d36f80b-8711-0b4e-8da0-ef76ae8ac470]', - x2: '[responsive]', - x3: '[atiAnalyticsAppName]', - x4: '[es]', - x5: '[http%3A%2F%2Flocalhost%2F]', - x6: '[https%3A%2F%2Fwww.example.com]', - x7: '[article-media-asset]', - x8: '[simorgh]', - x9: '[¿Qué%20es%20el%20albur%20en%20México%20y%20cómo%20puedes%20saber%20si%20te%20están%20"albureando"?%20-%20BBC%20News%20Mundo]', - x11: '[2017-09-14T14:09:14.000Z]', - x12: '[2017-09-14T14:09:14.000Z]', - x13: '[Politics~Nicaragua~Latin+America]', - x14: '[75612fa6-147c-4a43-97fa-fcf70d9cced3~7613abe4-1c05-4594-a5ec-3ccf6268b220~e0d04166-b92f-468e-9e68-d5f9330e6ae7]', - x16: '[WS - Update me]', - x17: '[News]', - }; - - expect(parsedATIURLParams).toEqual(expectedATIURLParams); - }); - - it('should return the correct PGL url', () => { - const url = buildATIUrl({ - requestContext: { ...requestContext, pageType: PHOTO_GALLERY_PAGE }, - atiData: cpsPGLPageAnalyticsData, - serviceContext, - }); - - const parsedATIURLParams = Object.fromEntries( - new URLSearchParams(url as string), - ); - - const expectedATIURLParams = { - hl: '00-00-00', - lng: 'en-US', - p: 'sport::mundo.sport.photo_gallery.36935058.page', - r: '0x0x24x24', - re: '1024x768', - ref: 'https://www.example.com', - s: '598285', - s2: 'atiAnalyticsProducerId', - x1: '[urn:bbc:cps:curie:asset:08e22e90-7361-cd47-b586-7cb53fc5a012]', - x2: '[responsive]', - x3: '[atiAnalyticsAppName]', - x4: '[es]', - x5: '[http%3A%2F%2Flocalhost%2F]', - x6: '[https%3A%2F%2Fwww.example.com]', - x7: '[article-photo-gallery]', - x8: '[simorgh]', - x9: '[Río%202016,%20el%20antes%20y%20el%20ahora:%20cómo%20ha%20cambiado%20la%20ropa%20deportiva%20en%20más%20de%20un%20siglo%20de%20juegos%20olímpicos%20-%20BBC%20News%20Mundo]', - x11: '[2016-08-07T09:21:02.000Z]', - x12: '[2016-08-07T09:21:02.000Z]', - x13: '[Technology]', - x14: '[25844b6e-80b0-4de9-8ea0-7a35e7d4086f]', - x16: '[WS - Divert me]', - x17: '[News]', - }; - - expect(parsedATIURLParams).toEqual(expectedATIURLParams); - }); - - it('should return the correct Homepage url', () => { - const url = buildATIUrl({ - requestContext: { ...requestContext, pageType: HOME_PAGE }, - atiData: homePageAnalyticsData, - serviceContext, - }); - - const parsedATIURLParams = Object.fromEntries( - new URLSearchParams(url as string), - ); - - expect(parsedATIURLParams).toEqual({ - s: '598285', - s2: 'atiAnalyticsProducerId', - p: 'kyrgyz.page', - r: '0x0x24x24', - re: '1024x768', - ref: 'https://www.example.com', - hl: '00-00-00', - lng: 'en-US', - x1: '[urn:bbc:tipo:topic:cm7682qz7v1t]', - x2: '[responsive]', - x3: '[atiAnalyticsAppName]', - x4: '[pcm]', - x5: '[http%3A%2F%2Flocalhost%2F]', - x6: '[https%3A%2F%2Fwww.example.com]', - x7: '[index-home]', - x8: '[simorgh]', - x9: '[pageTitle]', - }); - }); - - it('should have both ref parameter and x6 referrer url parameter, if referrer url exists', () => { - const atiUrl = buildATIUrl({ - requestContext: { ...requestContext, pageType: ARTICLE_PAGE }, - serviceContext, - atiData: articlePageAnalyticsData, - }) as string; - - const params = Object.fromEntries(new URLSearchParams(atiUrl)); - - expect(params.x6).toBe('[https%3A%2F%2Fwww.example.com]'); - expect(params.ref).toBe('https://www.example.com'); - }); - - it('should have ref parameter as the last parameter, if referrer url exists', () => { - const atiUrl = buildATIUrl({ - requestContext: { ...requestContext, pageType: ARTICLE_PAGE }, - serviceContext, - atiData: articlePageAnalyticsData, - }) as string; - const params = atiUrl.split('&'); - - expect(params.pop()).toEqual('ref=https://www.example.com'); - }); - - it('should not have ref and x6 parameters, if referrer url does not exist', () => { - const atiUrl = buildATIUrl({ - requestContext: { - ...requestContext, - pageType: ARTICLE_PAGE, - }, - serviceContext, - atiData: articlePageAnalyticsData, - }) as string; - const params = atiUrl.split('&'); - - expect(params).not.toContain('x6='); - expect(params).not.toContain('ref='); - }); - }); - describe('buildATIEventTrackingParams', () => { it('should return the correct article params', () => { const params = buildATIEventTrackingParams({ From 26e4b8f04577d71a55991516941ce80d8399c5e5 Mon Sep 17 00:00:00 2001 From: alex-magana Date: Mon, 8 Dec 2025 18:03:29 +0300 Subject: [PATCH 008/140] Delete buildATIUrl from the ATIAnalytics component --- src/app/components/ATIAnalytics/index.tsx | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/app/components/ATIAnalytics/index.tsx b/src/app/components/ATIAnalytics/index.tsx index 90fe33cfd96..100e24e5e3b 100644 --- a/src/app/components/ATIAnalytics/index.tsx +++ b/src/app/components/ATIAnalytics/index.tsx @@ -5,7 +5,7 @@ import CanonicalATIAnalytics from './canonical'; import AmpATIAnalytics from './amp'; import AmpGeo from '../../legacy/components/AmpGeo'; import { ATIProps } from './types'; -import { buildATIUrl, buildReverbParams } from './params'; +import { buildReverbParams } from './params'; const ATIAnalytics = ({ atiData = {} }: ATIProps) => { const requestContext = use(RequestContext); @@ -13,12 +13,6 @@ const ATIAnalytics = ({ atiData = {} }: ATIProps) => { const { isAmp } = requestContext; const { useReverb } = serviceContext; - const urlPageViewParams = buildATIUrl({ - requestContext, - serviceContext, - atiData, - }) as string; - const reverbParams = useReverb ? buildReverbParams({ requestContext, @@ -27,20 +21,13 @@ const ATIAnalytics = ({ atiData = {} }: ATIProps) => { }) : null; - if (!urlPageViewParams) { - return null; - } - return isAmp ? ( <> ) : ( - + ); }; From 0f3c9291237402a54d1479a235735f7633af41ec Mon Sep 17 00:00:00 2001 From: alex-magana Date: Tue, 9 Dec 2025 15:49:26 +0300 Subject: [PATCH 009/140] Remove useReverb flag from ATIAnalytics component --- src/app/components/ATIAnalytics/index.tsx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/app/components/ATIAnalytics/index.tsx b/src/app/components/ATIAnalytics/index.tsx index 100e24e5e3b..660f572b63e 100644 --- a/src/app/components/ATIAnalytics/index.tsx +++ b/src/app/components/ATIAnalytics/index.tsx @@ -11,15 +11,12 @@ const ATIAnalytics = ({ atiData = {} }: ATIProps) => { const requestContext = use(RequestContext); const serviceContext = use(ServiceContext); const { isAmp } = requestContext; - const { useReverb } = serviceContext; - const reverbParams = useReverb - ? buildReverbParams({ - requestContext, - serviceContext, - atiData, - }) - : null; + const reverbParams = buildReverbParams({ + requestContext, + serviceContext, + atiData, + }); return isAmp ? ( <> From d3cd486ee55333e47215bf545f6f076825c15c42 Mon Sep 17 00:00:00 2001 From: alex-magana Date: Tue, 9 Dec 2025 16:14:33 +0300 Subject: [PATCH 010/140] Remove url argument and 'fetch' invocation --- .../lib/analyticsUtils/sendBeacon/index.ts | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/app/lib/analyticsUtils/sendBeacon/index.ts b/src/app/lib/analyticsUtils/sendBeacon/index.ts index 40b792339f0..2defe741904 100644 --- a/src/app/lib/analyticsUtils/sendBeacon/index.ts +++ b/src/app/lib/analyticsUtils/sendBeacon/index.ts @@ -132,24 +132,17 @@ const callReverb = async (eventDetails: ReverbEventDetails) => { ); }; -const sendBeacon = async ( - url: string, - reverbBeaconConfig?: ReverbBeaconConfig | null, -) => { +const sendBeacon = async (reverbBeaconConfig: ReverbBeaconConfig) => { if (onClient()) { try { - if (reverbBeaconConfig) { - const { - params: { page, user }, - eventDetails, - } = reverbBeaconConfig; - - await setReverbPageValues({ pageVars: page, userVars: user }); - - await callReverb(eventDetails); - } else { - await fetch(url, { credentials: 'include' }).then(res => res.text()); - } + const { + params: { page, user }, + eventDetails, + } = reverbBeaconConfig; + + await setReverbPageValues({ pageVars: page, userVars: user }); + + await callReverb(eventDetails); } catch (error) { logger.error(ATI_LOGGING_ERROR, { error, From af3dbd743f4510f8101306f2855d99655e674b32 Mon Sep 17 00:00:00 2001 From: alex-magana Date: Tue, 9 Dec 2025 16:23:57 +0300 Subject: [PATCH 011/140] Remove atiPageViewUrlString and atiPageViewUrl variables from CanonicalATIAnalytics --- .../components/ATIAnalytics/canonical/index.tsx | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/app/components/ATIAnalytics/canonical/index.tsx b/src/app/components/ATIAnalytics/canonical/index.tsx index 7173be45855..edfe6c29cbf 100644 --- a/src/app/components/ATIAnalytics/canonical/index.tsx +++ b/src/app/components/ATIAnalytics/canonical/index.tsx @@ -45,10 +45,7 @@ const addScript = ({ script, parameters, nonce }: InlineScriptProps) => { return {addInlineScript({ script, parameters, nonce })}; }; -const CanonicalATIAnalytics = ({ - pageviewParams = '', - reverbParams, -}: ATIAnalyticsProps) => { +const CanonicalATIAnalytics = ({ reverbParams }: ATIAnalyticsProps) => { const { isLite, nonce } = use(RequestContext); usePWAInstallTracker(); @@ -56,16 +53,11 @@ const CanonicalATIAnalytics = ({ useConnectionTypeTracker(); useConnectionBackOnlineTracker(); - const atiPageViewUrlString = - getEnvConfig().SIMORGH_ATI_BASE_URL + pageviewParams; - const [reverbBeaconConfig] = useState(reverbParams); - const [atiPageViewUrl] = useState(atiPageViewUrlString); - useEffect(() => { - if (!isOperaProxy()) sendBeacon(atiPageViewUrl, reverbBeaconConfig); - }, [atiPageViewUrl, reverbBeaconConfig]); + if (!isOperaProxy()) sendBeacon(reverbBeaconConfig); + }, [reverbBeaconConfig]); const liteSiteReverbURL = enforceLegacyDestinationForJapanese( reverbUrlHelper.getLitePageViewUrl(reverbParams), From 4c7abb9b7f250c63306b87fdbfe2f8a5d47953fe Mon Sep 17 00:00:00 2001 From: alex-magana Date: Tue, 9 Dec 2025 16:25:30 +0300 Subject: [PATCH 012/140] Remove baseUrl and pageviewParams from ATIAnalyticsProps --- src/app/components/ATIAnalytics/types.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/app/components/ATIAnalytics/types.ts b/src/app/components/ATIAnalytics/types.ts index 7ecc5f51e76..002d4c09337 100644 --- a/src/app/components/ATIAnalytics/types.ts +++ b/src/app/components/ATIAnalytics/types.ts @@ -142,9 +142,7 @@ export type ReverbBeaconConfig = { }; export interface ATIAnalyticsProps { - baseUrl?: string; - pageviewParams?: string; - reverbParams?: ReverbBeaconConfig | null; + reverbParams: ReverbBeaconConfig; } export interface ATIEventTrackingProps { From 2c682d690988e1932087a1278effcac13680acfd Mon Sep 17 00:00:00 2001 From: alex-magana Date: Tue, 9 Dec 2025 18:33:54 +0300 Subject: [PATCH 013/140] Remove unused getEnvConfig --- src/app/components/ATIAnalytics/canonical/index.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/components/ATIAnalytics/canonical/index.tsx b/src/app/components/ATIAnalytics/canonical/index.tsx index edfe6c29cbf..fdbadcd6b4e 100644 --- a/src/app/components/ATIAnalytics/canonical/index.tsx +++ b/src/app/components/ATIAnalytics/canonical/index.tsx @@ -1,5 +1,4 @@ import { useEffect, useState, use } from 'react'; -import { getEnvConfig } from '#app/lib/utilities/getEnvConfig'; import { RequestContext } from '#app/contexts/RequestContext'; import isOperaProxy from '#app/lib/utilities/isOperaProxy'; import { Helmet } from 'react-helmet'; From 732b2b2734d0aeeac6f6ec5f4593dc8f7e7f5236 Mon Sep 17 00:00:00 2001 From: alex-magana Date: Tue, 9 Dec 2025 18:38:58 +0300 Subject: [PATCH 014/140] Remove redundant ATIAnalyticsPropsExport type --- .../canonical/getNoScriptTrackingPixelUrl/index.ts | 7 ++----- src/app/components/ATIAnalytics/canonical/index.tsx | 6 +----- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/app/components/ATIAnalytics/canonical/getNoScriptTrackingPixelUrl/index.ts b/src/app/components/ATIAnalytics/canonical/getNoScriptTrackingPixelUrl/index.ts index 60f0d255735..ed37debe66d 100644 --- a/src/app/components/ATIAnalytics/canonical/getNoScriptTrackingPixelUrl/index.ts +++ b/src/app/components/ATIAnalytics/canonical/getNoScriptTrackingPixelUrl/index.ts @@ -1,10 +1,7 @@ import { reverbUrlHelper } from '@bbc/reverb-url-helper'; import { ATIAnalyticsProps } from '../../types'; -type ATIAnalyticsPropsExport = Pick; - -const getNoScriptTrackingPixelUrl = ( - reverbParams: ATIAnalyticsPropsExport['reverbParams'], -) => reverbUrlHelper.getTrackingPixelSrc(reverbParams); +const getNoScriptTrackingPixelUrl = (reverbParams: ATIAnalyticsProps) => + reverbUrlHelper.getTrackingPixelSrc(reverbParams); export default getNoScriptTrackingPixelUrl; diff --git a/src/app/components/ATIAnalytics/canonical/index.tsx b/src/app/components/ATIAnalytics/canonical/index.tsx index fdbadcd6b4e..b1ed4ca61fc 100644 --- a/src/app/components/ATIAnalytics/canonical/index.tsx +++ b/src/app/components/ATIAnalytics/canonical/index.tsx @@ -17,11 +17,7 @@ import { ATIAnalyticsProps } from '../types'; import getNoScriptTrackingPixelUrl from './getNoScriptTrackingPixelUrl'; import sendPageViewBeaconOperaMini from './sendPageViewBeaconOperaMini'; -type ATIAnalyticsPropsExport = Pick; - -const renderNoScriptTrackingPixel = ( - reverbParams: ATIAnalyticsPropsExport['reverbParams'], -) => { +const renderNoScriptTrackingPixel = (reverbParams: ATIAnalyticsProps) => { return (