diff --git a/src/app/components/ATIAnalytics/params/index.test.ts b/src/app/components/ATIAnalytics/params/index.test.ts index 1208534f1b5..0f3f14ee9b1 100644 --- a/src/app/components/ATIAnalytics/params/index.test.ts +++ b/src/app/components/ATIAnalytics/params/index.test.ts @@ -3,7 +3,6 @@ import * as analyticsUtils from '../../../lib/analyticsUtils'; import { ARTICLE_PAGE, FRONT_PAGE, - MEDIA_PAGE, MEDIA_ASSET_PAGE, PHOTO_GALLERY_PAGE, MEDIA_ARTICLE_PAGE, @@ -58,14 +57,6 @@ const frontPage: PageData = { }, }; -const media: PageData = { - id: 'id', - language: 'language', - pageIdentifier: 'pageIdentifier', - pageTitle: 'pageTitle', - contentType: 'player-live', -}; - const homePageAnalyticsData: ATIData = { contentId: 'urn:bbc:tipo:topic:cm7682qz7v1t', contentType: 'index-home', @@ -260,36 +251,6 @@ describe('ATIAnalytics params', () => { }); }); - it('should return the correct media url', () => { - const url = buildATIUrl({ - requestContext: { ...requestContext, pageType: MEDIA_PAGE }, - data: media, - serviceContext, - }); - - const parsedATIParams = Object.fromEntries( - new URLSearchParams(url as string), - ); - - expect(parsedATIParams).toEqual({ - s: '598285', - s2: 'atiAnalyticsProducerId', - p: 'pageIdentifier', - r: '0x0x24x24', - re: '1024x768', - hl: '00-00-00', - lng: 'en-US', - x1: '[id]', - x2: '[responsive]', - x3: '[atiAnalyticsAppName]', - x4: '[language]', - x5: '[http%3A%2F%2Flocalhost%2F]', - x7: '[player-live]', - x8: '[simorgh]', - x9: '[pageTitle]', - }); - }); - it('should return the correct MAP url', () => { const url = buildATIUrl({ requestContext: { ...requestContext, pageType: MEDIA_ASSET_PAGE }, @@ -470,9 +431,9 @@ describe('ATIAnalytics params', () => { ); }); - it('should not invoke buildPageATIUrl for an unsupported page type with no atiData', () => { + it('should not invoke buildPageATIUrl for an unmigrated page type with no atiData', () => { buildATIUrl({ - requestContext: { ...requestContext, pageType: MEDIA_PAGE }, + requestContext: { ...requestContext, pageType: FRONT_PAGE }, atiData: undefined, serviceContext, }); @@ -582,27 +543,6 @@ describe('ATIAnalytics params', () => { }); }); - it('should return the correct media params', () => { - const params = buildATIEventTrackingParams({ - requestContext: { ...requestContext, pageType: MEDIA_PAGE }, - data: media, - serviceContext, - }); - expect(params).toEqual({ - appName: 'atiAnalyticsAppName', - contentId: 'id', - contentType: 'player-live', - language: 'language', - pageIdentifier: 'pageIdentifier', - pageTitle: 'pageTitle', - libraryVersion: 'simorgh', - platform: 'canonical', - producerId: 'atiAnalyticsProducerId', - service: 'pidgin', - statsDestination: 'statsDestination', - }); - }); - it('should return the correct MAP params', () => { const params = buildATIEventTrackingParams({ requestContext: { ...requestContext, pageType: MEDIA_ASSET_PAGE }, @@ -743,60 +683,15 @@ describe('ATIAnalytics params', () => { ); }); - it('should not invoke buildPageATIParams for an unsupported page type with no atiData', () => { + it('should not invoke buildPageATIParams for an unmigrated page type with no atiData', () => { buildATIEventTrackingParams({ - requestContext: { ...requestContext, pageType: MEDIA_PAGE }, + requestContext: { ...requestContext, pageType: FRONT_PAGE }, atiData: undefined, serviceContext, }); - expect(console.error) - .toHaveBeenCalledWith(`ATI Event Tracking Error: Could not parse tracking values from page data: -Cannot read properties of undefined (reading 'id')`); expect(buildPageATIParamsSpy).not.toHaveBeenCalled(); }); }); - - it('should not throw exception and return empty object if no pageData is passed in', () => { - const { error } = console; - console.error = jest.fn(); - - const pageData = null; - const params = buildATIEventTrackingParams({ - requestContext: { ...requestContext, pageType: MEDIA_PAGE }, - // @ts-expect-error - pass in null value to ensure error handling working as expected - data: pageData, - serviceContext, - }); - - expect(params).toEqual({}); - expect(console.error).toHaveBeenCalledWith( - expect.stringContaining( - 'ATI Event Tracking Error: Could not parse tracking values from page data:', - ), - ); - console.error = error; - }); - - it('should not throw exception and return empty object if no atiData is passed in', () => { - const { error } = console; - console.error = jest.fn(); - - const atiData = null; - const params = buildATIEventTrackingParams({ - requestContext: { ...requestContext, pageType: MEDIA_PAGE }, - // @ts-expect-error - pass in null value to ensure error handling working as expected - atiData, - serviceContext, - }); - - expect(params).toEqual({}); - expect(console.error).toHaveBeenCalledWith( - expect.stringContaining( - 'ATI Event Tracking Error: Could not parse tracking values from page data:', - ), - ); - console.error = error; - }); }); }); diff --git a/src/app/components/ATIAnalytics/params/index.ts b/src/app/components/ATIAnalytics/params/index.ts index 17eddfb1775..0702f5fa2cc 100644 --- a/src/app/components/ATIAnalytics/params/index.ts +++ b/src/app/components/ATIAnalytics/params/index.ts @@ -10,7 +10,6 @@ import { FEATURE_INDEX_PAGE, MOST_READ_PAGE, PHOTO_GALLERY_PAGE, - MEDIA_PAGE, ERROR_PAGE, LIVE_PAGE, CPS_ASSET, @@ -22,10 +21,6 @@ import { AUDIO_PAGE, TV_PAGE, } from '../../../routes/utils/pageTypes'; -import { - buildTvRadioATIParams, - buildTvRadioATIUrl, -} from './tvRadioPage/buildParams'; import { buildPageATIUrl, buildPageATIParams } from './buildParams'; import { buildIndexPageATIParams, @@ -68,7 +63,6 @@ const pageTypeUrlBuilders = { [MEDIA_ARTICLE_PAGE]: noOp, [STORY_PAGE]: noOp, [FRONT_PAGE]: buildIndexPageATIUrl, - [MEDIA_PAGE]: buildTvRadioATIUrl, [MOST_READ_PAGE]: noOp, [FEATURE_INDEX_PAGE]: noOp, [TOPIC_PAGE]: noOp, @@ -92,7 +86,6 @@ const pageTypeParamBuilders = { [ARTICLE_PAGE]: noOp, [MEDIA_ARTICLE_PAGE]: noOp, [FRONT_PAGE]: buildIndexPageATIParams, - [MEDIA_PAGE]: buildTvRadioATIParams, [MOST_READ_PAGE]: noOp, [FEATURE_INDEX_PAGE]: noOp, [TOPIC_PAGE]: noOp, @@ -167,32 +160,21 @@ export const buildATIEventTrackingParams = ({ data, atiData, }: ATIConfigurationDetailsProviders) => { - try { - const { pageType } = requestContext; - if (atiData && isMigrated(pageType)) { - return buildPageATIParams({ - atiData, - requestContext, - serviceContext, - }); - } - - const buildParams = createBuilderFactory( + const { pageType } = requestContext; + if (atiData && isMigrated(pageType)) { + return buildPageATIParams({ + atiData, requestContext, - pageTypeParamBuilders, - ); - - return buildParams(data as PageData, requestContext, serviceContext); - } catch (error: unknown) { - const { message } = error as Error; + serviceContext, + }); + } - // eslint-disable-next-line no-console - console.error( - `ATI Event Tracking Error: Could not parse tracking values from page data:\n${message}`, - ); + const buildParams = createBuilderFactory( + requestContext, + pageTypeParamBuilders, + ); - return {}; - } + return buildParams(data as PageData, requestContext, serviceContext); }; export default buildATIUrl; diff --git a/src/app/components/ChartbeatAnalytics/utils/index.test.ts b/src/app/components/ChartbeatAnalytics/utils/index.test.ts index ec5e726ede9..75fb5252f96 100644 --- a/src/app/components/ChartbeatAnalytics/utils/index.test.ts +++ b/src/app/components/ChartbeatAnalytics/utils/index.test.ts @@ -3,7 +3,6 @@ import onClient from '../../../lib/utilities/onClient'; import { ARTICLE_PAGE, FRONT_PAGE, - MEDIA_PAGE, MOST_READ_PAGE, FEATURE_INDEX_PAGE, MEDIA_ASSET_PAGE, @@ -84,11 +83,6 @@ describe('Chartbeat utilities', () => { expectedDefaultType: 'article-media-asset', expectedShortType: 'article-media-asset', }, - { - pageType: MEDIA_PAGE, - expectedDefaultType: 'Radio', - expectedShortType: 'Radio', - }, { pageType: AUDIO_PAGE, expectedDefaultType: 'Radio', @@ -303,7 +297,6 @@ describe('Chartbeat utilities', () => { ${MOST_READ_PAGE} | ${'Most Read Page Title'} | ${'BBC News Pidgin'} | ${'Most Read Page Title - BBC News Pidgin'} ${TOPIC_PAGE} | ${'Topic Page Title'} | ${'BBC News Pidgin'} | ${'Topic Page Title - BBC News Pidgin'} ${LIVE_PAGE} | ${'Live Page Title'} | ${'BBC News Pidgin'} | ${'Live Page Title - BBC News Pidgin'} - ${MEDIA_PAGE} | ${'Media Page Title'} | ${'BBC News Pidgin'} | ${'Media Page Title - BBC News Pidgin'} ${AUDIO_PAGE} | ${'Audio Page Title'} | ${'BBC News Pidgin'} | ${'Audio Page Title - BBC News Pidgin'} ${TV_PAGE} | ${'TV Page Title'} | ${'BBC News Pidgin'} | ${'TV Page Title - BBC News Pidgin'} ${'index'} | ${'index Page Title'} | ${'BBC News Pidgin'} | ${'index Page Title - BBC News Pidgin'} diff --git a/src/app/components/ChartbeatAnalytics/utils/index.ts b/src/app/components/ChartbeatAnalytics/utils/index.ts index a97066209db..6d31d33ae92 100644 --- a/src/app/components/ChartbeatAnalytics/utils/index.ts +++ b/src/app/components/ChartbeatAnalytics/utils/index.ts @@ -7,7 +7,6 @@ import { getReferrer } from '../../../lib/analyticsUtils'; import { ARTICLE_PAGE, FRONT_PAGE, - MEDIA_PAGE, MOST_READ_PAGE, FEATURE_INDEX_PAGE, MEDIA_ASSET_PAGE, @@ -61,7 +60,6 @@ export const getType = (pageType: PageTypes | 'index', shorthand = false) => { return 'article-media-asset'; case LIVE_RADIO_PAGE: case AUDIO_PAGE: - case MEDIA_PAGE: return 'Radio'; case TV_PAGE: return 'TV'; @@ -150,7 +148,6 @@ export const buildSections = ({ : []), ].join(', '); case LIVE_RADIO_PAGE: - case MEDIA_PAGE: case AUDIO_PAGE: case TV_PAGE: return [ @@ -190,7 +187,6 @@ export const getTitle = ({ pageType, title, brandName }: GetTitleProps) => { case TOPIC_PAGE: case LIVE_PAGE: case LIVE_RADIO_PAGE: - case MEDIA_PAGE: case AUDIO_PAGE: case TV_PAGE: case 'index': diff --git a/src/app/components/MediaLoader/Metadata/index.test.tsx b/src/app/components/MediaLoader/Metadata/index.test.tsx index 1b30643fe2c..a5329c4d82a 100644 --- a/src/app/components/MediaLoader/Metadata/index.test.tsx +++ b/src/app/components/MediaLoader/Metadata/index.test.tsx @@ -7,7 +7,7 @@ import { import { ARTICLE_PAGE, AUDIO_PAGE, - MEDIA_PAGE, + LIVE_RADIO_PAGE, TV_PAGE, } from '#app/routes/utils/pageTypes'; import Metadata from '.'; @@ -64,7 +64,7 @@ describe('Media Loader - Metadata', () => { expect(container).toMatchSnapshot(); }); - it.each([MEDIA_PAGE, AUDIO_PAGE, TV_PAGE])( + it.each([AUDIO_PAGE, TV_PAGE, LIVE_RADIO_PAGE])( 'should not render metadata component as the %s page type is not supported', async pageType => { let container; diff --git a/src/app/contexts/EventTrackingContext/index.tsx b/src/app/contexts/EventTrackingContext/index.tsx index 2df643bdb10..4fb15232967 100644 --- a/src/app/contexts/EventTrackingContext/index.tsx +++ b/src/app/contexts/EventTrackingContext/index.tsx @@ -10,7 +10,6 @@ import useToggle from '../../hooks/useToggle'; import { ARTICLE_PAGE, FRONT_PAGE, - MEDIA_PAGE, MOST_READ_PAGE, FEATURE_INDEX_PAGE, MEDIA_ASSET_PAGE, @@ -60,7 +59,6 @@ const getCampaignID = (pageType: CampaignPageTypes) => { [ARTICLE_PAGE]: 'article', [MEDIA_ARTICLE_PAGE]: 'article-sfv', [FRONT_PAGE]: 'index-home', - [MEDIA_PAGE]: 'player-episode', [MOST_READ_PAGE]: 'list-datadriven-read', [FEATURE_INDEX_PAGE]: 'index-section-fix', [MEDIA_ASSET_PAGE]: 'article-media-asset', diff --git a/src/app/legacy/containers/OnDemandImage/index.test.jsx b/src/app/legacy/containers/OnDemandImage/index.test.jsx index df382896048..0f49c82d9e2 100644 --- a/src/app/legacy/containers/OnDemandImage/index.test.jsx +++ b/src/app/legacy/containers/OnDemandImage/index.test.jsx @@ -1,6 +1,6 @@ import React from 'react'; import { RequestContextProvider } from '#contexts/RequestContext'; -import { MEDIA_PAGE } from '#app/routes/utils/pageTypes'; +import { AUDIO_PAGE } from '#app/routes/utils/pageTypes'; import { render } from '../../../components/react-testing-library-with-providers'; import { ServiceContextProvider } from '../../../contexts/ServiceContext'; import OnDemandImage from '.'; @@ -10,7 +10,7 @@ const component = ({ url, isAmp, service, alt }) => ( diff --git a/src/app/routes/utils/pageTypes.ts b/src/app/routes/utils/pageTypes.ts index 0bf58b78254..7fbfa0e2d4d 100644 --- a/src/app/routes/utils/pageTypes.ts +++ b/src/app/routes/utils/pageTypes.ts @@ -1,7 +1,6 @@ export const ARTICLE_PAGE = 'article' as const; export const MEDIA_ARTICLE_PAGE = 'mediaArticle' as const; export const FRONT_PAGE = 'frontPage' as const; -export const MEDIA_PAGE = 'media' as const; export const MOST_READ_PAGE = 'mostRead' as const; export const ERROR_PAGE = 'error' as const; export const FEATURE_INDEX_PAGE = 'FIX' as const; diff --git a/src/server/index.test.jsx b/src/server/index.test.jsx index 45c745bf24e..0fad3bf6760 100644 --- a/src/server/index.test.jsx +++ b/src/server/index.test.jsx @@ -10,7 +10,7 @@ import { SERVER_SIDE_RENDER_REQUEST_RECEIVED, SERVER_SIDE_REQUEST_FAILED, } from '#lib/logger.const'; -import { FRONT_PAGE, MEDIA_PAGE } from '#app/routes/utils/pageTypes'; +import { FRONT_PAGE, LIVE_RADIO_PAGE } from '#app/routes/utils/pageTypes'; import Document from './Document/component'; import routes from '../app/routes'; import * as renderDocument from './Document'; @@ -562,7 +562,7 @@ const testMediaPages = ({ }); describe('404 status code', () => { - const pageType = MEDIA_PAGE; + const pageType = LIVE_RADIO_PAGE; beforeEach(() => { mockRouteProps({ @@ -589,7 +589,7 @@ const testMediaPages = ({ }); describe('Unknown error within the data fetch, react router or its dependencies', () => { - const pageType = 'liveRadio'; + const pageType = LIVE_RADIO_PAGE; beforeEach(() => { mockRouteProps({