diff --git a/cypress/e2e/pages/liveRadio/index.cy.js b/cypress/e2e/pages/liveRadio/index.cy.js
index 209f0972959..0590e4e465f 100644
--- a/cypress/e2e/pages/liveRadio/index.cy.js
+++ b/cypress/e2e/pages/liveRadio/index.cy.js
@@ -115,7 +115,6 @@ const atiAnalyticsTestSuites = [
siteId: 51,
applicationType: 'responsive',
contentType: 'player-live',
- useReverb: true,
tests: [
assertPageView,
assertRadioScheduleComponentView,
diff --git a/cypress/e2e/pages/mostReadPage/index.cy.js b/cypress/e2e/pages/mostReadPage/index.cy.js
index 8e763b4a9ec..a5302234648 100644
--- a/cypress/e2e/pages/mostReadPage/index.cy.js
+++ b/cypress/e2e/pages/mostReadPage/index.cy.js
@@ -86,7 +86,6 @@ const atiAnalyticsTestSuites = [
siteId: 40,
applicationType: 'responsive',
contentType: 'list-datadriven',
- useReverb: true,
tests: [
assertPageView,
assertDropdownNavigationComponentClick,
@@ -103,7 +102,6 @@ const atiAnalyticsAmpTestSuites = atiAnalyticsTestSuites.map(testSuite => {
return {
...testSuite,
path: getPathWithSuffix({ path: testSuite.path, suffix: '.amp' }),
- useReverb: true,
applicationType: 'amp',
tests: [assertPageView],
};
@@ -126,7 +124,6 @@ const atiAnalyticsLiteTestSuites = atiAnalyticsTestSuites.map(testSuite => {
...testSuite,
path: getPathWithSuffix({ path: testSuite.path, suffix: '.lite' }),
applicationType: 'lite',
- useReverb: true,
tests: [...liteSiteTests],
};
});
diff --git a/cypress/e2e/pages/onDemandAudio/index.cy.js b/cypress/e2e/pages/onDemandAudio/index.cy.js
index b7860b9127e..cce92d3d2a5 100644
--- a/cypress/e2e/pages/onDemandAudio/index.cy.js
+++ b/cypress/e2e/pages/onDemandAudio/index.cy.js
@@ -466,7 +466,6 @@ const atiAnalyticsTestSuites = [
siteId: 3,
applicationType: 'responsive',
contentType: 'player-episode',
- useReverb: true,
tests: [
assertPageView,
assertRecentAudioEpisodesComponentView,
@@ -483,7 +482,6 @@ const atiAnalyticsTestSuites = [
siteId: 5,
applicationType: 'responsive',
contentType: 'player-episode',
- useReverb: true,
tests: [assertPageView],
},
{
@@ -494,7 +492,6 @@ const atiAnalyticsTestSuites = [
siteId: 40,
applicationType: 'responsive',
contentType: 'player-episode',
- useReverb: true,
tests: [...atiAnalyticsPodcastComponentTests],
},
{
@@ -505,7 +502,6 @@ const atiAnalyticsTestSuites = [
siteId: 40,
applicationType: 'responsive',
contentType: 'player-episode',
- useReverb: true,
tests: [...atiAnalyticsPodcastComponentTests],
},
{
@@ -516,7 +512,6 @@ const atiAnalyticsTestSuites = [
siteId: 33,
applicationType: 'responsive',
contentType: 'player-episode',
- useReverb: true,
tests: [...atiAnalyticsPodcastComponentTests],
},
{
@@ -527,7 +522,6 @@ const atiAnalyticsTestSuites = [
siteId: 33,
applicationType: 'responsive',
contentType: 'player-episode',
- useReverb: true,
tests: [...atiAnalyticsPodcastComponentTests],
},
{
@@ -539,7 +533,6 @@ const atiAnalyticsTestSuites = [
siteId: 94,
applicationType: 'responsive',
contentType: 'player-episode',
- useReverb: true,
tests: [...atiAnalyticsPodcastComponentTests],
},
];
@@ -561,7 +554,6 @@ const atiAnalyticsLiteTestSuites = atiAnalyticsTestSuites.map(testSuite => {
...testSuite,
path: getPathWithSuffix({ path: testSuite.path, suffix: '.lite' }),
applicationType: 'lite',
- useReverb: false,
siteId: testSuite.siteId,
tests: [...liteSiteTests],
};
diff --git a/cypress/e2e/pages/onDemandTV/index.cy.js b/cypress/e2e/pages/onDemandTV/index.cy.js
index fec326e0acb..d312e2be565 100644
--- a/cypress/e2e/pages/onDemandTV/index.cy.js
+++ b/cypress/e2e/pages/onDemandTV/index.cy.js
@@ -211,7 +211,6 @@ const atiAnalyticsTestSuites = [
siteId: 3,
applicationType: 'responsive',
contentType: 'player-episode',
- useReverb: true,
tests: [assertPageView],
},
{
@@ -222,7 +221,6 @@ const atiAnalyticsTestSuites = [
siteId: 3,
applicationType: 'responsive',
contentType: 'player-episode',
- useReverb: true,
tests: [assertPageView],
},
];
@@ -252,7 +250,6 @@ const atiAnalyticsLiteTestSuites = atiAnalyticsTestSuites.map(testSuite => {
...testSuite,
path: getPathWithSuffix({ path: testSuite.path, suffix: '.lite' }),
applicationType: 'lite',
- useReverb: false,
siteId: testSuite.siteId,
tests: [...liteSiteTests],
};
diff --git a/cypress/e2e/pages/topicPage/index.cy.js b/cypress/e2e/pages/topicPage/index.cy.js
index 67659c7be42..192a9d77281 100644
--- a/cypress/e2e/pages/topicPage/index.cy.js
+++ b/cypress/e2e/pages/topicPage/index.cy.js
@@ -87,7 +87,6 @@ const atiAnalyticsTestSuites = [
siteId: 59,
applicationType: 'responsive',
contentType: 'index-category',
- useReverb: true,
componentTrackingContentType: 'topic-page',
tests: [assertPageView],
},
@@ -100,7 +99,6 @@ const atiAnalyticsTestSuites = [
applicationType: 'responsive',
contentType: 'index-category',
componentTrackingContentType: 'topic-page',
- useReverb: true,
tests: [
assertPageView,
assertScrollableNavigationComponentView,
@@ -130,7 +128,6 @@ const atiAnalyticsLiteTestSuites = atiAnalyticsTestSuites.map(testSuite => {
...testSuite,
path: getPathWithSuffix({ path: testSuite.path, suffix: '.lite' }),
applicationType: 'lite',
- useReverb: false,
siteId: testSuite.siteId,
tests: [...liteSiteTests],
};
diff --git a/cypress/e2e/specialFeatures/atiAnalytics/assertions/articleLiteSiteLink.js b/cypress/e2e/specialFeatures/atiAnalytics/assertions/articleLiteSiteLink.js
index 51d71f669ae..cc9db8ded5c 100644
--- a/cypress/e2e/specialFeatures/atiAnalytics/assertions/articleLiteSiteLink.js
+++ b/cypress/e2e/specialFeatures/atiAnalytics/assertions/articleLiteSiteLink.js
@@ -6,7 +6,6 @@ const { ARTICLE_LITE_SITE_LINK } = COMPONENTS;
export const assertArticleLiteSiteLinkComponentView = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -23,7 +22,6 @@ export const assertArticleLiteSiteLinkComponentView = ({
component: ARTICLE_LITE_SITE_LINK,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
@@ -33,7 +31,6 @@ export const assertArticleLiteSiteLinkComponentView = ({
export const assertArticleLiteSiteLinkComponentClick = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -53,7 +50,6 @@ export const assertArticleLiteSiteLinkComponentClick = ({
component: ARTICLE_LITE_SITE_LINK,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
diff --git a/cypress/e2e/specialFeatures/atiAnalytics/assertions/featuresAnalysis.js b/cypress/e2e/specialFeatures/atiAnalytics/assertions/featuresAnalysis.js
index 401d1b008a3..f1f3c7614fa 100644
--- a/cypress/e2e/specialFeatures/atiAnalytics/assertions/featuresAnalysis.js
+++ b/cypress/e2e/specialFeatures/atiAnalytics/assertions/featuresAnalysis.js
@@ -6,7 +6,6 @@ const { FEATURES } = COMPONENTS;
export const assertFeaturesAnalysisComponentView = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -21,7 +20,6 @@ export const assertFeaturesAnalysisComponentView = ({
component: FEATURES,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
@@ -31,7 +29,6 @@ export const assertFeaturesAnalysisComponentView = ({
export const assertFeaturesAnalysisComponentClick = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -49,7 +46,6 @@ export const assertFeaturesAnalysisComponentClick = ({
component: FEATURES,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
diff --git a/cypress/e2e/specialFeatures/atiAnalytics/assertions/index.js b/cypress/e2e/specialFeatures/atiAnalytics/assertions/index.js
index 1f66d441597..1527fa9debf 100644
--- a/cypress/e2e/specialFeatures/atiAnalytics/assertions/index.js
+++ b/cypress/e2e/specialFeatures/atiAnalytics/assertions/index.js
@@ -6,7 +6,7 @@ import {
import {
ATI_PAGE_VIEW,
ATI_PAGE_VIEW_REVERB,
- // ATI_USER_ID_COOKIE,
+ ATI_USER_ID_COOKIE,
getATIParamsFromURL,
interceptATIAnalyticsBeacons,
getExpectedAtiDestination,
@@ -14,7 +14,7 @@ import {
import environment from '../../../../support/helpers/getAppEnv';
const usesReverbViewabilityModel = applicationType =>
- applicationType !== 'lite';
+ !['lite', 'amp'].includes(applicationType);
const getAppName = service => {
if (service === 'ws') {
@@ -93,7 +93,14 @@ const assertLocationSpecificPianoDestinationExists = ({ service }) => {
});
};
-const assertReverbViewabilityComponentEventParamsExist = ({ params }) => {
+const assertReverbViewabilityComponentEventParamsExist = ({
+ params,
+ applicationType,
+}) => {
+ if (['responsive', 'lite'].includes(applicationType)) {
+ expect(params).to.have.property('idclient');
+ }
+
expect(params).to.have.property('s'); // destination
expect(params).to.have.property('events'); // event details
expect(params).to.have.property('context');
@@ -183,7 +190,6 @@ const validateViewabilityEventDetails = ({ payload, actionType }) => {
};
export const assertPageView = ({
- useReverb,
pageIdentifier,
applicationType,
contentType,
@@ -196,10 +202,9 @@ export const assertPageView = ({
cy.visit(path, { retryOnStatusCodeFailure: true });
const useViewabilty = usesReverbViewabilityModel(applicationType);
- const atiPageViewAlias =
- useReverb && useViewabilty && applicationType !== 'amp'
- ? ATI_PAGE_VIEW_REVERB
- : ATI_PAGE_VIEW;
+ const atiPageViewAlias = useViewabilty
+ ? ATI_PAGE_VIEW_REVERB
+ : ATI_PAGE_VIEW;
cy.wait(`@${atiPageViewAlias}`).then(({ request }) => {
const params = getATIParamsFromURL(request.url);
@@ -210,13 +215,12 @@ export const assertPageView = ({
applicationType,
});
- // TODO: Commenting out temporarily until old ATI code is removed - https://bbc.atlassian.net/browse/WS-222
- // if (['responsive', 'lite'].includes(applicationType)) {
- // expect(params.idclient).to.equal(
- // ATI_USER_ID_COOKIE,
- // 'params.idclient (atuserid cookie value)',
- // );
- // }
+ if (['responsive', 'lite'].includes(applicationType)) {
+ expect(params.idclient).to.equal(
+ ATI_USER_ID_COOKIE,
+ 'params.idclient (atuserid cookie value)',
+ );
+ }
expect(params.p).to.equal(pageIdentifier, 'params.p (page identifier)');
expect(parseInt(params.s2, 10)).to.equal(
@@ -246,20 +250,12 @@ export const assertPageView = ({
const assertViewabilityModelViewEvent = ({
pageIdentifier,
params,
- // applicationType,
+ applicationType,
siteId,
}) => {
const eventContext = JSON.parse(params.context);
- assertReverbViewabilityComponentEventParamsExist({ params });
-
- // TODO: Commenting out temporarily until old ATI code is removed - https://bbc.atlassian.net/browse/WS-222
- // if (['responsive', 'lite'].includes(applicationType)) {
- // expect(params.idclient).to.equal(
- // ATI_USER_ID_COOKIE,
- // 'params.idclient (atuserid cookie value)',
- // );
- // }
+ assertReverbViewabilityComponentEventParamsExist({ params, applicationType });
expect(params.events).to.satisfy(
payload =>
@@ -275,6 +271,7 @@ export const assertATIComponentViewEvent = ({
component,
pageIdentifier,
contentType,
+ applicationType,
siteId,
}) => {
const requestAlias = `@${component}-viewability-view`;
@@ -289,6 +286,7 @@ export const assertATIComponentViewEvent = ({
pageIdentifier,
contentType,
params,
+ applicationType,
siteId,
});
});
@@ -297,23 +295,16 @@ export const assertATIComponentViewEvent = ({
const assertViewabilityModelClickEvent = ({
pageIdentifier,
params,
- // applicationType,
+ applicationType,
siteId,
}) => {
const eventContext = JSON.parse(params.context);
assertReverbViewabilityComponentEventParamsExist({
params,
+ applicationType,
});
- // TODO: Commenting out temporarily until old ATI code is removed - https://bbc.atlassian.net/browse/WS-222
- // if (['responsive', 'lite'].includes(applicationType)) {
- // expect(params.idclient).to.equal(
- // ATI_USER_ID_COOKIE,
- // 'params.idclient (atuserid cookie value)',
- // );
- // }
-
expect(params.events).to.satisfy(
payload =>
validateViewabilityEventDetails({
@@ -331,6 +322,7 @@ export const assertATIComponentClickEvent = ({
component,
contentType,
pageIdentifier,
+ applicationType,
siteId,
}) => {
const requestAlias = `@${component}-viewability-click`;
@@ -344,6 +336,7 @@ export const assertATIComponentClickEvent = ({
contentType,
pageIdentifier,
params,
+ applicationType,
siteId,
});
});
diff --git a/cypress/e2e/specialFeatures/atiAnalytics/assertions/latestMedia.js b/cypress/e2e/specialFeatures/atiAnalytics/assertions/latestMedia.js
index f38dda4a3a7..d5f7fbc468f 100644
--- a/cypress/e2e/specialFeatures/atiAnalytics/assertions/latestMedia.js
+++ b/cypress/e2e/specialFeatures/atiAnalytics/assertions/latestMedia.js
@@ -6,7 +6,6 @@ const { LATEST_MEDIA } = COMPONENTS;
export const assertLatestMediaComponentView = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -21,7 +20,6 @@ export const assertLatestMediaComponentView = ({
component: LATEST_MEDIA,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
@@ -31,7 +29,6 @@ export const assertLatestMediaComponentView = ({
export const assertLatestMediaComponentClick = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -51,7 +48,6 @@ export const assertLatestMediaComponentClick = ({
component: LATEST_MEDIA,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
diff --git a/cypress/e2e/specialFeatures/atiAnalytics/assertions/liveMedia.js b/cypress/e2e/specialFeatures/atiAnalytics/assertions/liveMedia.js
index f4e8a1b8a8f..da77f33f089 100644
--- a/cypress/e2e/specialFeatures/atiAnalytics/assertions/liveMedia.js
+++ b/cypress/e2e/specialFeatures/atiAnalytics/assertions/liveMedia.js
@@ -6,7 +6,6 @@ const { LIVE_MEDIA } = COMPONENTS;
export const assertLiveMediaComponentView = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -23,7 +22,6 @@ export const assertLiveMediaComponentView = ({
component: LIVE_MEDIA,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
@@ -33,7 +31,6 @@ export const assertLiveMediaComponentView = ({
export const assertLiveMediaComponentClick = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -52,7 +49,6 @@ export const assertLiveMediaComponentClick = ({
component: LIVE_MEDIA,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
diff --git a/cypress/e2e/specialFeatures/atiAnalytics/assertions/messageBanner.js b/cypress/e2e/specialFeatures/atiAnalytics/assertions/messageBanner.js
index 1d36cf5c2e3..1cd7563b6a5 100644
--- a/cypress/e2e/specialFeatures/atiAnalytics/assertions/messageBanner.js
+++ b/cypress/e2e/specialFeatures/atiAnalytics/assertions/messageBanner.js
@@ -7,7 +7,6 @@ export const assertMessageBannerComponentView = ({
pageIdentifier,
contentType,
componentTrackingContentType,
- useReverb,
path,
applicationType,
siteId,
@@ -24,7 +23,6 @@ export const assertMessageBannerComponentView = ({
component: MESSAGE_BANNER,
pageIdentifier,
contentType: componentTrackingContentType || contentType,
- useReverb,
applicationType,
siteId,
});
@@ -35,7 +33,6 @@ export const assertMessageBannerComponentClick = ({
pageIdentifier,
contentType,
componentTrackingContentType,
- useReverb,
path,
applicationType,
siteId,
@@ -55,7 +52,6 @@ export const assertMessageBannerComponentClick = ({
component: MESSAGE_BANNER,
pageIdentifier,
contentType: componentTrackingContentType || contentType,
- useReverb,
applicationType,
siteId,
});
diff --git a/cypress/e2e/specialFeatures/atiAnalytics/assertions/mostRead.js b/cypress/e2e/specialFeatures/atiAnalytics/assertions/mostRead.js
index 49e020e35f3..a2cd077d098 100644
--- a/cypress/e2e/specialFeatures/atiAnalytics/assertions/mostRead.js
+++ b/cypress/e2e/specialFeatures/atiAnalytics/assertions/mostRead.js
@@ -7,7 +7,6 @@ const { MOST_READ } = COMPONENTS;
export const assertMostReadComponentView = ({
pageIdentifier,
contentType,
- useReverb,
path,
service,
applicationType,
@@ -29,7 +28,6 @@ export const assertMostReadComponentView = ({
component: MOST_READ,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
@@ -39,7 +37,6 @@ export const assertMostReadComponentView = ({
export const assertMostReadComponentClick = ({
pageIdentifier,
contentType,
- useReverb,
path,
service,
applicationType,
@@ -64,7 +61,6 @@ export const assertMostReadComponentClick = ({
component: MOST_READ,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
diff --git a/cypress/e2e/specialFeatures/atiAnalytics/assertions/navigation.js b/cypress/e2e/specialFeatures/atiAnalytics/assertions/navigation.js
index dca76335172..adb391f3961 100644
--- a/cypress/e2e/specialFeatures/atiAnalytics/assertions/navigation.js
+++ b/cypress/e2e/specialFeatures/atiAnalytics/assertions/navigation.js
@@ -7,7 +7,6 @@ export const assertScrollableNavigationComponentView = ({
pageIdentifier,
contentType,
componentTrackingContentType,
- useReverb,
path,
applicationType,
siteId,
@@ -24,7 +23,6 @@ export const assertScrollableNavigationComponentView = ({
component: SCROLLABLE_NAVIGATION,
pageIdentifier,
contentType: componentTrackingContentType || contentType,
- useReverb,
applicationType,
siteId,
});
@@ -35,7 +33,6 @@ export const assertScrollableNavigationComponentClick = ({
pageIdentifier,
contentType,
componentTrackingContentType,
- useReverb,
path,
applicationType,
siteId,
@@ -55,7 +52,6 @@ export const assertScrollableNavigationComponentClick = ({
component: SCROLLABLE_NAVIGATION,
pageIdentifier,
contentType: componentTrackingContentType || contentType,
- useReverb,
applicationType,
siteId,
});
@@ -67,7 +63,6 @@ export const assertDropdownNavigationComponentView = ({
pageIdentifier,
contentType,
componentTrackingContentType,
- useReverb,
path,
applicationType,
siteId,
@@ -83,7 +78,6 @@ export const assertDropdownNavigationComponentView = ({
component: DROPDOWN_NAVIGATION,
pageIdentifier,
contentType: componentTrackingContentType || contentType,
- useReverb,
applicationType,
siteId,
});
@@ -94,7 +88,6 @@ export const assertDropdownNavigationComponentClick = ({
pageIdentifier,
contentType,
componentTrackingContentType,
- useReverb,
path,
applicationType,
siteId,
@@ -113,7 +106,6 @@ export const assertDropdownNavigationComponentClick = ({
component: DROPDOWN_NAVIGATION,
pageIdentifier,
contentType: componentTrackingContentType || contentType,
- useReverb,
applicationType,
siteId,
});
diff --git a/cypress/e2e/specialFeatures/atiAnalytics/assertions/podcastLinks.js b/cypress/e2e/specialFeatures/atiAnalytics/assertions/podcastLinks.js
index 81fd72b07ae..7882c314ba3 100644
--- a/cypress/e2e/specialFeatures/atiAnalytics/assertions/podcastLinks.js
+++ b/cypress/e2e/specialFeatures/atiAnalytics/assertions/podcastLinks.js
@@ -6,7 +6,6 @@ const { PODCAST_LINKS } = COMPONENTS;
export const assertPodcastLinksComponentView = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -23,7 +22,6 @@ export const assertPodcastLinksComponentView = ({
component: PODCAST_LINKS,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
@@ -33,7 +31,6 @@ export const assertPodcastLinksComponentView = ({
export const assertPodcastLinksComponentClick = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -53,7 +50,6 @@ export const assertPodcastLinksComponentClick = ({
component: PODCAST_LINKS,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
diff --git a/cypress/e2e/specialFeatures/atiAnalytics/assertions/podcastPromo.js b/cypress/e2e/specialFeatures/atiAnalytics/assertions/podcastPromo.js
index f5643bfd8dd..7949169bf46 100644
--- a/cypress/e2e/specialFeatures/atiAnalytics/assertions/podcastPromo.js
+++ b/cypress/e2e/specialFeatures/atiAnalytics/assertions/podcastPromo.js
@@ -6,7 +6,6 @@ const { PODCAST_PROMO } = COMPONENTS;
export const assertPodcastPromoComponentView = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -23,7 +22,6 @@ export const assertPodcastPromoComponentView = ({
component: PODCAST_PROMO,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
@@ -33,7 +31,6 @@ export const assertPodcastPromoComponentView = ({
export const assertPodcastPromoComponentClick = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -53,7 +50,6 @@ export const assertPodcastPromoComponentClick = ({
component: PODCAST_PROMO,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
diff --git a/cypress/e2e/specialFeatures/atiAnalytics/assertions/radioSchedule.js b/cypress/e2e/specialFeatures/atiAnalytics/assertions/radioSchedule.js
index 2c37202b8b7..bb51cab3374 100644
--- a/cypress/e2e/specialFeatures/atiAnalytics/assertions/radioSchedule.js
+++ b/cypress/e2e/specialFeatures/atiAnalytics/assertions/radioSchedule.js
@@ -6,7 +6,6 @@ const { RADIO_SCHEDULE } = COMPONENTS;
export const assertRadioScheduleComponentView = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -23,7 +22,6 @@ export const assertRadioScheduleComponentView = ({
component: RADIO_SCHEDULE,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
@@ -33,7 +31,6 @@ export const assertRadioScheduleComponentView = ({
export const assertRadioScheduleComponentClick = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -53,7 +50,6 @@ export const assertRadioScheduleComponentClick = ({
component: RADIO_SCHEDULE,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
diff --git a/cypress/e2e/specialFeatures/atiAnalytics/assertions/recentAudioEpisodes.js b/cypress/e2e/specialFeatures/atiAnalytics/assertions/recentAudioEpisodes.js
index 2b7be4beb47..898b01651a8 100644
--- a/cypress/e2e/specialFeatures/atiAnalytics/assertions/recentAudioEpisodes.js
+++ b/cypress/e2e/specialFeatures/atiAnalytics/assertions/recentAudioEpisodes.js
@@ -6,7 +6,6 @@ const { RECENT_AUDIO_EPISODES } = COMPONENTS;
export const assertRecentAudioEpisodesComponentView = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -23,7 +22,6 @@ export const assertRecentAudioEpisodesComponentView = ({
component: RECENT_AUDIO_EPISODES,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
@@ -33,7 +31,6 @@ export const assertRecentAudioEpisodesComponentView = ({
export const assertRecentAudioEpisodesComponentClick = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -53,7 +50,6 @@ export const assertRecentAudioEpisodesComponentClick = ({
component: RECENT_AUDIO_EPISODES,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
diff --git a/cypress/e2e/specialFeatures/atiAnalytics/assertions/relatedTopics.js b/cypress/e2e/specialFeatures/atiAnalytics/assertions/relatedTopics.js
index f8dc91e5b53..559bcf97f9e 100644
--- a/cypress/e2e/specialFeatures/atiAnalytics/assertions/relatedTopics.js
+++ b/cypress/e2e/specialFeatures/atiAnalytics/assertions/relatedTopics.js
@@ -6,7 +6,6 @@ const { RELATED_TOPICS } = COMPONENTS;
export const assertRelatedTopicsComponentView = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -23,7 +22,6 @@ export const assertRelatedTopicsComponentView = ({
component: RELATED_TOPICS,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
@@ -33,7 +31,6 @@ export const assertRelatedTopicsComponentView = ({
export const assertRelatedTopicsComponentClick = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -53,7 +50,6 @@ export const assertRelatedTopicsComponentClick = ({
component: RELATED_TOPICS,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
diff --git a/cypress/e2e/specialFeatures/atiAnalytics/assertions/share.js b/cypress/e2e/specialFeatures/atiAnalytics/assertions/share.js
index 7c43c4c4825..225d68614cf 100644
--- a/cypress/e2e/specialFeatures/atiAnalytics/assertions/share.js
+++ b/cypress/e2e/specialFeatures/atiAnalytics/assertions/share.js
@@ -6,7 +6,6 @@ const { SHARE } = COMPONENTS;
export const assertShareComponentView = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -23,7 +22,6 @@ export const assertShareComponentView = ({
component: SHARE,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
@@ -33,7 +31,6 @@ export const assertShareComponentView = ({
export const assertShareComponentClick = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -53,7 +50,6 @@ export const assertShareComponentClick = ({
component: SHARE,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
diff --git a/cypress/e2e/specialFeatures/atiAnalytics/assertions/socialEmbed.js b/cypress/e2e/specialFeatures/atiAnalytics/assertions/socialEmbed.js
index 7d13593f0d4..6b803ac81e7 100644
--- a/cypress/e2e/specialFeatures/atiAnalytics/assertions/socialEmbed.js
+++ b/cypress/e2e/specialFeatures/atiAnalytics/assertions/socialEmbed.js
@@ -6,7 +6,6 @@ const { SOCIAL_EMBED } = COMPONENTS;
export const assertSocialEmbedComponentView = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -23,7 +22,6 @@ export const assertSocialEmbedComponentView = ({
component: SOCIAL_EMBED,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
@@ -33,7 +31,6 @@ export const assertSocialEmbedComponentView = ({
export const assertSocialEmbedComponentClick = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -53,7 +50,6 @@ export const assertSocialEmbedComponentClick = ({
component: SOCIAL_EMBED,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
diff --git a/cypress/e2e/specialFeatures/atiAnalytics/assertions/topStories.js b/cypress/e2e/specialFeatures/atiAnalytics/assertions/topStories.js
index 9450a96c0c9..bb8ce6394ae 100644
--- a/cypress/e2e/specialFeatures/atiAnalytics/assertions/topStories.js
+++ b/cypress/e2e/specialFeatures/atiAnalytics/assertions/topStories.js
@@ -6,7 +6,6 @@ const { TOP_STORIES } = COMPONENTS;
export const assertTopStoriesComponentView = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -21,7 +20,6 @@ export const assertTopStoriesComponentView = ({
component: TOP_STORIES,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
@@ -31,7 +29,6 @@ export const assertTopStoriesComponentView = ({
export const assertTopStoriesComponentClick = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -51,7 +48,6 @@ export const assertTopStoriesComponentClick = ({
component: TOP_STORIES,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
diff --git a/cypress/e2e/specialFeatures/atiAnalytics/index.cy.js b/cypress/e2e/specialFeatures/atiAnalytics/index.cy.js
index 1fc445f15fd..86e8241b00e 100644
--- a/cypress/e2e/specialFeatures/atiAnalytics/index.cy.js
+++ b/cypress/e2e/specialFeatures/atiAnalytics/index.cy.js
@@ -29,7 +29,6 @@ const ampTestSuites = canonicalTestSuites.filter(supportsAmp).map(testSuite => {
return {
...testSuite,
path: getPathWithSuffix({ path: testSuite.path, suffix: '.amp' }),
- useReverb: true,
applicationType: 'amp',
tests: [assertPageView],
};
@@ -57,7 +56,6 @@ const liteTestSuites = canonicalTestSuites.map(testSuite => {
...testSuite,
path: getPathWithSuffix({ path: testSuite.path, suffix: '.lite' }),
applicationType: 'lite',
- useReverb: false,
siteId: testSuite.service === 'magyarul' ? 134 : testSuite.siteId,
tests: [...liteSiteTests],
};
diff --git a/scripts/bundleSize/bundleSizeConfig.js b/scripts/bundleSize/bundleSizeConfig.js
index 475f5b2be47..f739f087d5d 100644
--- a/scripts/bundleSize/bundleSizeConfig.js
+++ b/scripts/bundleSize/bundleSizeConfig.js
@@ -9,5 +9,5 @@
export const VARIANCE = 5;
-export const MIN_SIZE = 935;
-export const MAX_SIZE = 1304;
+export const MIN_SIZE = 922;
+export const MAX_SIZE = 1292;
diff --git a/src/app/components/ATIAnalytics/amp/ampAnalyticsJson.test.ts b/src/app/components/ATIAnalytics/amp/ampAnalyticsJson.test.ts
index 95b7a991404..35a27e3abdf 100644
--- a/src/app/components/ATIAnalytics/amp/ampAnalyticsJson.test.ts
+++ b/src/app/components/ATIAnalytics/amp/ampAnalyticsJson.test.ts
@@ -109,8 +109,6 @@ describe('AMP ATI Analytics', () => {
];
const ampAnalyticsJsonConfiguration = ampAnalyticsJson({
- baseUrl: 'https://exampleBaseAtiUrl.com?',
- pageviewParams: 'param1=value1¶m2=value2',
reverbParams,
});
const {
diff --git a/src/app/components/ATIAnalytics/amp/index.test.tsx b/src/app/components/ATIAnalytics/amp/index.test.tsx
index 43bc8cf4a0f..50d4c4fc914 100644
--- a/src/app/components/ATIAnalytics/amp/index.test.tsx
+++ b/src/app/components/ATIAnalytics/amp/index.test.tsx
@@ -2,7 +2,9 @@
import { render } from '../../react-testing-library-with-providers';
import AmpATIAnalytics from '.';
import { ReverbBeaconConfig } from '../types';
-import splitUrl from '../atiUrl/splitUrl';
+
+const splitUrl = (url: string): string[] =>
+ url.replace(/&/g, ',').replace(/\?/g, ',').split(',');
describe('Amp ATI Analytics', () => {
beforeEach(() => {
@@ -49,10 +51,7 @@ describe('Amp ATI Analytics', () => {
};
const { container } = render(
- ,
+ ,
);
const ampAnalyticsComponents = container.querySelectorAll(
diff --git a/src/app/components/ATIAnalytics/atiUrl/index.client.test.ts b/src/app/components/ATIAnalytics/atiUrl/index.client.test.ts
index c25b1477fb9..bfba0cf5fce 100644
--- a/src/app/components/ATIAnalytics/atiUrl/index.client.test.ts
+++ b/src/app/components/ATIAnalytics/atiUrl/index.client.test.ts
@@ -1,12 +1,6 @@
import { Platforms } from '#app/models/types/global';
import * as genericLabelHelpers from '../../../lib/analyticsUtils';
-import {
- buildATIPageTrackPath,
- buildATIEventTrackUrl,
- buildReverbAnalyticsModel,
- buildReverbEventModel,
-} from '.';
-import splitUrl from './splitUrl';
+import { buildReverbAnalyticsModel, buildReverbEventModel } from '.';
const mockAndSet = ({ name, source }, response) => {
source[name] = jest.fn(); // eslint-disable-line no-param-reassign
@@ -14,266 +8,18 @@ const mockAndSet = ({ name, source }, response) => {
};
const analyticsUtilFunctions = [
- { name: 'getDestination', source: genericLabelHelpers },
{ name: 'getAppType', source: genericLabelHelpers },
- { name: 'getScreenInfo', source: genericLabelHelpers },
- { name: 'getBrowserViewPort', source: genericLabelHelpers },
- { name: 'getCurrentTime', source: genericLabelHelpers },
- { name: 'getDeviceLanguage', source: genericLabelHelpers },
{ name: 'getHref', source: genericLabelHelpers },
{ name: 'getReferrer', source: genericLabelHelpers },
- { name: 'getAtUserId', source: genericLabelHelpers },
- { name: 'getATIMarketingString,', source: genericLabelHelpers },
{ name: 'isLocServeCookieSet', source: genericLabelHelpers },
{ 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 => {
- mockAndSet(func, func.name);
- });
- });
-
- it('should return the correct url', () => {
- process.env.SIMORGH_ATI_BASE_URL = 'http://foobar.com?';
-
- const atiEventTrackUrl = buildATIEventTrackUrl({
- pageIdentifier: 'pageIdentifier',
- service: 'news',
- platform: 'canonical',
- statsDestination: 'statsDestination',
- componentName: 'component',
- type: 'type',
- campaignID: 'campaignID',
- format: 'format',
- url: 'url',
- detailedPlacement: 'detailedPlacement',
- experimentName: 'dummy_experiment',
- experimentVariant: 'variant_1',
- });
-
- expect(splitUrl(atiEventTrackUrl)).toEqual([
- 'http://foobar.com',
- 's=getDestination',
- 'p=pageIdentifier',
- 'atc=PUB-[campaignID]-[component]-[variant_1]-[format]-[pageIdentifier]-[detailedPlacement]-[]-[url]',
- 'idclient=getAtUserId',
- 'hl=getCurrentTime',
- 're=getBrowserViewPort',
- 'r=getScreenInfo',
- 'lng=getDeviceLanguage',
- 'mv_test=dummy_experiment',
- 'mv_creation=variant_1',
- 'type=AT',
- ]);
- });
- });
-
describe('Reverb', () => {
describe('buildReverbAnalyticsModel', () => {
beforeEach(() => {
diff --git a/src/app/components/ATIAnalytics/atiUrl/index.ts b/src/app/components/ATIAnalytics/atiUrl/index.ts
index 5c639231f39..f95fd1a6ffe 100644
--- a/src/app/components/ATIAnalytics/atiUrl/index.ts
+++ b/src/app/components/ATIAnalytics/atiUrl/index.ts
@@ -5,23 +5,12 @@ import {
} from '#app/lib/analyticsUtils/analytics.const';
import { getEnvConfig } from '#app/lib/utilities/getEnvConfig';
import {
- getDestination,
getAppType,
- getScreenInfo,
- getBrowserViewPort,
- getCurrentTime,
- getDeviceLanguage,
getHref,
getReferrer,
- getAtUserId,
isLocServeCookieSet,
onOnionTld,
sanitise,
- getAtiUrl,
- getEventInfo,
- getCampaignType,
- getATIMarketingString,
- getRSSMarketingString,
} from '../../../lib/analyticsUtils';
import {
ATIEventTrackingProps,
@@ -34,405 +23,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,
- platform,
- statsDestination,
- componentName,
- campaignID,
- format,
- type,
- advertiserID,
- url,
- detailedPlacement,
- experimentName,
- experimentVariant,
- ampExperimentName,
- isStatic = false,
-}: ATIEventTrackingProps & {
- isStatic?: boolean;
-}) => {
- // 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';
-
- const eventPublisher = type === 'view' ? 'ati' : 'atc';
- const eventTrackingBeaconValues = [
- {
- key: 's',
- description: 'destination',
- value: getDestination(platform, statsDestination),
- wrap: false,
- disableEncoding: disableEncodingDueToAmpSubstitution,
- },
- {
- key: 's2',
- description: 'producer',
- value: producerId,
- wrap: false,
- },
- {
- key: 'p',
- description: 'page identifier',
- value: pageIdentifier,
- wrap: false,
- },
- {
- key: eventPublisher,
- description: 'event publisher',
- value: getEventInfo({
- campaignID,
- componentName,
- format,
- pageIdentifier,
- advertiserID,
- url,
- detailedPlacement,
- experimentVariant: experimentVariant ?? '',
- }),
- wrap: false,
- disableEncoding: true,
- },
- ...(isStatic
- ? []
- : [
- {
- key: 'idclient',
- description: 'at user id',
- value: getAtUserId(),
- wrap: false,
- },
- {
- key: 'hl',
- description: 'time',
- value: getCurrentTime(platform),
- wrap: false,
- disableEncoding: disableEncodingDueToAmpSubstitution,
- },
- {
- key: 're',
- description: 'browser/viewport resolution',
- value: getBrowserViewPort(platform),
- wrap: false,
- disableEncoding: disableEncodingDueToAmpSubstitution,
- },
- {
- key: 'r',
- description: 'screen resolution & colour depth',
- value: getScreenInfo(platform),
- wrap: false,
- disableEncoding: disableEncodingDueToAmpSubstitution,
- },
- {
- key: 'lng',
- description: 'device language',
- value: getDeviceLanguage(platform),
- wrap: false,
- disableEncoding: disableEncodingDueToAmpSubstitution,
- },
- ]),
- ...(experimentVariant && experimentName
- ? [
- {
- key: 'mv_test',
- description: 'Experiment name',
- value: `${experimentName}`,
- wrap: false,
- disableEncoding: true,
- },
- {
- key: 'mv_creation',
- description: 'Experiment variant',
- value: `${experimentVariant}`,
- wrap: false,
- disableEncoding: true,
- },
- ]
- : []),
- ...(ampExperimentName
- ? [
- {
- key: 'mv_test',
- description: 'AMP experiment project name',
- value: `Google Discover`,
- wrap: false,
- disableEncoding: true,
- },
- {
- key: 'mv_experiment_id',
- 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,
- },
- ]
- : []),
- ];
-
- return `${getEnvConfig().SIMORGH_ATI_BASE_URL}${getAtiUrl(
- eventTrackingBeaconValues,
- )}&type=AT`;
-};
-
export const buildReverbAnalyticsModel = ({
appName,
campaigns,
diff --git a/src/app/components/ATIAnalytics/atiUrl/splitUrl.test.ts b/src/app/components/ATIAnalytics/atiUrl/splitUrl.test.ts
deleted file mode 100644
index b6d54ab2098..00000000000
--- a/src/app/components/ATIAnalytics/atiUrl/splitUrl.test.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import splitUrl from './splitUrl';
-
-describe('splitUrl', () => {
- it('returns an array of the host and query string parameters for a given URL', () => {
- const url = 'https://foobar.com?key1=value1&key2=value2';
-
- expect(splitUrl(url)).toEqual([
- 'https://foobar.com',
- 'key1=value1',
- 'key2=value2',
- ]);
- });
-});
diff --git a/src/app/components/ATIAnalytics/atiUrl/splitUrl.ts b/src/app/components/ATIAnalytics/atiUrl/splitUrl.ts
deleted file mode 100644
index bc5982f9e4a..00000000000
--- a/src/app/components/ATIAnalytics/atiUrl/splitUrl.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export default (url: string): string[] =>
- url.replace(/&/g, ',').replace(/\?/g, ',').split(',');
diff --git a/src/app/components/ATIAnalytics/beacon/index.test.ts b/src/app/components/ATIAnalytics/beacon/index.test.ts
index a0ec9a706fb..f581ad119f9 100644
--- a/src/app/components/ATIAnalytics/beacon/index.test.ts
+++ b/src/app/components/ATIAnalytics/beacon/index.test.ts
@@ -1,16 +1,8 @@
import * as sendBeacon from '../../../lib/analyticsUtils/sendBeacon';
-import * as analyticsUtils from '../../../lib/analyticsUtils';
import { sendEventBeacon } from '.';
const sendBeaconSpy = jest.spyOn(sendBeacon, 'default');
-(analyticsUtils.getAtUserId as jest.Mock) = jest
- .fn()
- .mockReturnValue('123-456-789');
-(analyticsUtils.getCurrentTime as jest.Mock) = jest
- .fn()
- .mockReturnValue('00-00-00');
-
const reverbMock = {
isReady: jest.fn(),
initialise: jest.fn(() => Promise.resolve()),
@@ -24,43 +16,11 @@ window.__reverb = {
};
describe('beacon', () => {
- const originalATIBaseUrl = process.env.SIMORGH_ATI_BASE_URL;
- const atiBaseUrl = 'https://foobar.com?';
- process.env.SIMORGH_ATI_BASE_URL = atiBaseUrl;
-
afterEach(() => {
jest.clearAllMocks();
- process.env.SIMORGH_ATI_BASE_URL = originalATIBaseUrl;
});
describe('event', () => {
- it('should call sendBeacon exactly once', () => {
- sendEventBeacon({
- type: 'click',
- service: 'news',
- componentName: 'component',
- pageIdentifier: 'pageIdentifier',
- detailedPlacement: 'detailedPlacement',
- });
- expect(sendBeaconSpy).toHaveBeenCalledTimes(1);
-
- const parsedATIParams = Object.fromEntries(
- new URLSearchParams(new URL(sendBeaconSpy.mock.calls[0][0]).search),
- );
-
- expect(parsedATIParams).toEqual({
- idclient: '123-456-789',
- s: '598285',
- p: 'pageIdentifier',
- r: '0x0x24x24',
- re: '1024x768',
- hl: '00-00-00',
- lng: 'en-US',
- atc: 'PUB-[]-[component]-[]-[]-[pageIdentifier]-[detailedPlacement]-[]-[]',
- type: 'AT',
- });
- });
-
describe('Reverb', () => {
describe('Viewability Model', () => {
it('should call reverb userActionEvent exactly once for a view event', async () => {
@@ -76,7 +36,6 @@ describe('beacon', () => {
advertiserID: 'advertiserID',
url: 'http://localhost',
detailedPlacement: 'detailedPlacement',
- useReverb: true,
});
expect(sendBeaconSpy).toHaveBeenCalledTimes(1);
@@ -119,7 +78,6 @@ describe('beacon', () => {
advertiserID: 'advertiserID',
url: 'http://localhost',
detailedPlacement: 'detailedPlacement',
- useReverb: true,
});
expect(sendBeaconSpy).toHaveBeenCalledTimes(1);
@@ -149,22 +107,6 @@ describe('beacon', () => {
);
});
});
-
- it('should resolve reverbParams to null when Reverb is disabled for a service', () => {
- sendEventBeacon({
- type: 'click',
- service: 'news',
- componentName: 'component',
- pageIdentifier: 'pageIdentifier',
- detailedPlacement: 'detailedPlacement',
- useReverb: false,
- });
-
- const reverbParams = sendBeaconSpy.mock.calls[0][1];
-
- expect(sendBeaconSpy).toHaveBeenCalledTimes(1);
- expect(reverbParams).toBeNull();
- });
});
});
});
diff --git a/src/app/components/ATIAnalytics/beacon/index.ts b/src/app/components/ATIAnalytics/beacon/index.ts
index 4cb509b0be6..b388e41b1f0 100644
--- a/src/app/components/ATIAnalytics/beacon/index.ts
+++ b/src/app/components/ATIAnalytics/beacon/index.ts
@@ -1,5 +1,5 @@
import sendBeacon from '../../../lib/analyticsUtils/sendBeacon';
-import { buildATIEventTrackUrl, buildReverbEventModel } from '../atiUrl';
+import { buildReverbEventModel } from '../atiUrl';
import { ATIEventTrackingProps } from '../types';
export const sendEventBeacon = async ({
@@ -7,59 +7,35 @@ export const sendEventBeacon = async ({
componentName,
format,
pageIdentifier,
- platform,
- producerId,
producerName,
- service,
statsDestination,
type,
advertiserID,
url,
- detailedPlacement,
experimentName,
experimentVariant,
- useReverb,
itemTracker,
groupTracker,
eventGroupingName,
}: ATIEventTrackingProps) => {
- const atiClickTrackingUrl = buildATIEventTrackUrl({
- campaignID,
- componentName,
- format,
+ const reverbParams = buildReverbEventModel({
pageIdentifier,
- platform,
- producerId,
- service,
+ producerName,
statsDestination,
+ componentName,
+ campaignID,
+ format,
type,
advertiserID,
url,
- detailedPlacement,
experimentName,
experimentVariant,
+ itemTracker,
+ groupTracker,
+ eventGroupingName,
});
- const reverbParams = useReverb
- ? buildReverbEventModel({
- pageIdentifier,
- producerName,
- statsDestination,
- componentName,
- campaignID,
- format,
- type,
- advertiserID,
- url,
- experimentName,
- experimentVariant,
- itemTracker,
- groupTracker,
- eventGroupingName,
- })
- : null;
-
- await sendBeacon(atiClickTrackingUrl, reverbParams);
+ await sendBeacon(reverbParams);
};
export default sendEventBeacon;
diff --git a/src/app/components/ATIAnalytics/canonical/getNoScriptTrackingPixelUrl/index.test.ts b/src/app/components/ATIAnalytics/canonical/getNoScriptTrackingPixelUrl/index.test.ts
index dc4b8579a2e..ec2e83f24f9 100644
--- a/src/app/components/ATIAnalytics/canonical/getNoScriptTrackingPixelUrl/index.test.ts
+++ b/src/app/components/ATIAnalytics/canonical/getNoScriptTrackingPixelUrl/index.test.ts
@@ -37,7 +37,7 @@ const mockReverbParams = {
describe('trackingPixelUrl', () => {
it('should return the correct tracking pixel URL', () => {
const { origin, pathname, searchParams } = new URL(
- getNoScriptTrackingPixelUrl(mockReverbParams),
+ getNoScriptTrackingPixelUrl({ reverbParams: mockReverbParams }),
);
expect(origin).toEqual('https://a1.api.bbc.co.uk');
diff --git a/src/app/components/ATIAnalytics/canonical/getNoScriptTrackingPixelUrl/index.ts b/src/app/components/ATIAnalytics/canonical/getNoScriptTrackingPixelUrl/index.ts
index 60f0d255735..4f5200ad220 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.test.tsx b/src/app/components/ATIAnalytics/canonical/index.test.tsx
index 0a40796e1bd..ed23c754270 100644
--- a/src/app/components/ATIAnalytics/canonical/index.test.tsx
+++ b/src/app/components/ATIAnalytics/canonical/index.test.tsx
@@ -15,32 +15,53 @@ describe('Canonical ATI Analytics', () => {
jest.clearAllMocks();
});
- const atiBaseUrl = 'https://foobar.com?';
- const reverbBaseUrl = 'https://logws1363.ati-host.net/hit.xiti?';
- const mockPageviewParams = 'key=value&key2=value2&x8=[simorgh]';
+ const reverbBaseUrl = 'https://a1.api.bbc.co.uk/hit.xiti';
+ const mockReverbParams = {
+ params: {
+ env: 'live',
+ page: {
+ contentId: 'urn:bbc:optimo:asset:cvgr9dk5dlno',
+ contentType: 'article',
+ destination: 'NEWS_LANGUAGES_GNL_TEST',
+ name: 'japanese.articles.cvgr9dk5dlno.page',
+ producer: 'JAPANESE',
+ additionalProperties: {
+ app_name: 'news-japanese',
+ app_type: 'responsive',
+ content_language: 'ja',
+ product_platform: null,
+ referrer_url: null,
+ x5: 'http%3A%2F%2Flocalhost%3A7081%2Fjapanese%2Farticles%2Fcvgr9dk5dlno%3Frenderer_env%3Dlive',
+ x8: 'simorgh',
+ x9: 'ゼレンスキー氏、領土問題が和平交渉で「最も困難」%20%20米特使はプーチン氏と会談へ',
+ x10: null,
+ x11: '2025-12-02T01:53:57.743Z',
+ x12: '2025-12-02T01:53:57.743Z',
+ x13: 'Europe~Volodymyr+Zelensky~Russia–Ukraine+war~Emmanuel+Macron~Russia~Eastern+Europe~France~Diplomacy~Donald+Trump~Vladimir+Putin~United+States~Military~Ukraine',
+ x14: '0b0bfd5a-81b8-43fa-91fc-57f1fcd24487~1808a59a-896b-4112-89c1-b713b991a1d1~23d96e97-b777-413a-a8c5-85a2eda98613~279feee6-7189-4e96-ad17-627f71685373~39267b85-1784-4f4b-80ed-f8cb4a35f337~57ade6dd-a03a-4e8e-ade3-53899690623b~61ef4416-de68-49ff-9c97-e0779dafd9d2~6fcca1fa-293b-4449-ac67-120f545c6a0d~78080d81-2849-497e-bc3a-bf364626456b~7fd6ee44-38a3-4fe3-a40f-7b4f8f72c67f~82857f8e-8134-462a-bb32-b7b14f4eab75~ce5c43ee-8982-4f88-9472-9aa79aeb09cc~ee8750ed-a7fb-453f-bfca-2aa8b3fb064c',
+ x16: '',
+ x17: 'Europe~Volodymyr+Zelensky~Russia–Ukraine+war~Emmanuel+Macron~Russia~Eastern+Europe~France~Diplomacy~Donald+Trump~Vladimir+Putin~United+States~Military~Ukraine',
+ x18: false,
+ },
+ },
+ user: {
+ isSignedIn: false,
+ },
+ },
+ eventDetails: {
+ eventName: 'pageView',
+ },
+ } as ReverbBeaconConfig;
const mockSendBeacon = jest.fn().mockReturnValue('beacon-return-value');
- process.env.SIMORGH_ATI_BASE_URL = atiBaseUrl;
// @ts-expect-error - we need to mock these functions to ensure tests are deterministic
beacon.default = mockSendBeacon;
- it('calls atiBaseURL and sendBeacon with required params', () => {
- const expectedUrl = `${atiBaseUrl}${mockPageviewParams}`;
- const reverbConfig = undefined;
-
- act(() => {
- render();
- });
-
- expect(mockSendBeacon).toHaveBeenCalledTimes(1);
- expect(mockSendBeacon).toHaveBeenCalledWith(expectedUrl, reverbConfig);
- });
-
it('should add scripts to helmet', () => {
jest.spyOn(isOperaProxy, 'default').mockImplementation(() => false);
act(() => {
- render();
+ render();
});
const helmet = Helmet.peek();
@@ -52,7 +73,7 @@ describe('Canonical ATI Analytics', () => {
jest.spyOn(isOperaProxy, 'default').mockImplementation(() => false);
act(() => {
- render();
+ render();
});
const helmet = Helmet.peek();
@@ -65,32 +86,10 @@ describe('Canonical ATI Analytics', () => {
it('should contain a beacon onLoad script via processClientDeviceAndSendStaticBeacon on lite', () => {
jest.spyOn(isOperaProxy, 'default').mockImplementation(() => false);
- const sampleReverbConfig = {
- params: {
- env: undefined,
- page: {
- contentId: 'urn:bbc:tipo:topic:cm7682qz7v1t',
- contentType: 'index-home',
- destination: 'WS_NEWS_LANGUAGES_TEST',
- name: 'kyrgyz.page',
- producer: 'KYRGYZ',
- additionalProperties: [Object],
- },
- user: { isSignedIn: false },
- },
- eventDetails: { eventName: 'pageView' },
- };
-
act(() => {
- render(
- ,
- {
- isLite: true,
- },
- );
+ render(, {
+ isLite: true,
+ });
});
const helmet = Helmet.peek();
@@ -106,7 +105,7 @@ describe('Canonical ATI Analytics', () => {
jest.spyOn(isOperaProxy, 'default').mockImplementation(() => true);
act(() => {
- render();
+ render();
});
expect(mockSendBeacon).not.toHaveBeenCalled();
@@ -114,7 +113,7 @@ describe('Canonical ATI Analytics', () => {
it('should render a noscript image for non-JS users', () => {
const { container } = render(
- ,
+ ,
);
expect(container.querySelector('noscript')).toBeInTheDocument();
});
diff --git a/src/app/components/ATIAnalytics/canonical/index.tsx b/src/app/components/ATIAnalytics/canonical/index.tsx
index 7173be45855..c3185f3311f 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';
@@ -18,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 (
@@ -45,10 +40,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 +48,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),
@@ -88,7 +75,7 @@ const CanonicalATIAnalytics = ({
script: sendPageViewBeaconOperaMini(operaMiniPageViewReverbURL),
nonce,
})}
- {renderNoScriptTrackingPixel(reverbParams)}
+ {renderNoScriptTrackingPixel({ reverbParams })}
>
);
};
diff --git a/src/app/components/ATIAnalytics/index.client.test.tsx b/src/app/components/ATIAnalytics/index.client.test.tsx
index 8de19bc985e..3b92d6dad07 100644
--- a/src/app/components/ATIAnalytics/index.client.test.tsx
+++ b/src/app/components/ATIAnalytics/index.client.test.tsx
@@ -2,7 +2,6 @@
import { articleDataNews } from '#pages/ArticlePage/fixtureData';
import styUkrainianAssetData from '#data/ukrainian/cpsAssets/news-53561143.json';
import styUkrainianInRussianAssetData from '#data/ukrainian/cpsAssets/features-russian-53477115.json';
-import * as analyticsUtils from '#lib/analyticsUtils';
import { ServiceContext } from '#contexts/ServiceContext';
import { ServiceConfig } from '#models/types/serviceConfig';
import styAssetData from './fixtures/storyPage.json';
@@ -21,14 +20,6 @@ import ATIAnalytics from '.';
import * as amp from './amp';
import * as canonical from './canonical';
-(analyticsUtils.getAtUserId as jest.Mock) = jest.fn();
-(analyticsUtils.getCurrentTime as jest.Mock) = jest
- .fn()
- .mockReturnValue('00-00-00');
-(analyticsUtils.getPublishedDatetime as jest.Mock) = jest
- .fn()
- .mockReturnValue('1970-01-01T00:00:00.000Z');
-
const defaultRenderProps = {
bbcOrigin: 'https://www.test.bbc.co.uk',
id: 'c0000000000o',
@@ -39,12 +30,16 @@ const defaultRenderProps = {
describe('ATI Analytics Container', () => {
beforeEach(() => {
+ process.env.SIMORGH_APP_ENV = 'test';
+
jest
.spyOn(window.location, 'href', 'get')
.mockImplementation(() => 'http://localhost/');
});
afterEach(() => {
+ delete process.env.SIMORGH_APP_ENV;
+
jest.clearAllMocks();
});
@@ -68,33 +63,43 @@ describe('ATI Analytics Container', () => {
isUK: true,
});
- const { pageviewParams } = mockCanonical.mock.calls[0][0];
-
- const parsedATIParams = Object.fromEntries(
- new URLSearchParams(pageviewParams),
- );
+ const { reverbParams } = mockCanonical.mock.calls[0][0];
- expect(parsedATIParams).toEqual({
- s: '598286',
- s2: '64',
- p: 'news.articles.c0000000001o.page',
- r: '1024x768x24x24',
- re: '1024x768',
- hl: '00-00-00',
- lng: 'en-US',
- x1: '[urn:bbc:optimo:c0000000001o]',
- x2: '[responsive]',
- x3: '[news]',
- x4: '[en-gb]',
- x5: '[http%3A%2F%2Flocalhost%2F]',
- x7: '[article]',
- x8: '[simorgh]',
- x9: '[Article%20Headline%20for%20SEO]',
- x11: '[2018-01-01T12:01:00.000Z]',
- x12: '[2018-01-01T14:00:00.000Z]',
- x13: '[Royal+Wedding+2018~Duchess+of+Sussex]',
- x14: '[2351f2b2-ce36-4f44-996d-c3c4f7f90eaa~803eaeb9-c0c3-4f1b-9a66-90efac3df2dc]',
- x17: '[Royal+Wedding+2018~Duchess+of+Sussex]',
+ expect(reverbParams).toEqual({
+ params: {
+ env: 'test',
+ page: {
+ contentId: 'urn:bbc:optimo:c0000000001o',
+ contentType: 'article',
+ destination: 'NEWS_PS_TEST',
+ name: 'news.articles.c0000000001o.page',
+ producer: 'NEWS',
+ additionalProperties: {
+ app_name: 'news',
+ app_type: 'responsive',
+ content_language: 'en-gb',
+ product_platform: null,
+ referrer_url: null,
+ x5: 'http%3A%2F%2Flocalhost%2F',
+ x8: 'simorgh',
+ x9: 'Article%20Headline%20for%20SEO',
+ x10: null,
+ x11: '2018-01-01T12:01:00.000Z',
+ x12: '2018-01-01T14:00:00.000Z',
+ x13: 'Royal+Wedding+2018~Duchess+of+Sussex',
+ x14: '2351f2b2-ce36-4f44-996d-c3c4f7f90eaa~803eaeb9-c0c3-4f1b-9a66-90efac3df2dc',
+ x16: '',
+ x17: 'Royal+Wedding+2018~Duchess+of+Sussex',
+ x18: false,
+ },
+ },
+ user: {
+ isSignedIn: false,
+ },
+ },
+ eventDetails: {
+ eventName: 'pageView',
+ },
});
});
@@ -177,33 +182,39 @@ describe('ATI Analytics Container', () => {
},
);
- const { pageviewParams } = mockCanonical.mock.calls[0][0];
-
- const parsedATIParams = Object.fromEntries(
- new URLSearchParams(pageviewParams),
- );
+ const { reverbParams } = mockCanonical.mock.calls[0][0];
- expect(parsedATIParams).toEqual({
- s: '598286',
- s2: '64',
- p: 'news.articles.c0000000001o.page',
- r: '1024x768x24x24',
- re: '1024x768',
- hl: '00-00-00',
- lng: 'en-US',
- x1: '[urn:bbc:optimo:c0000000001o]',
- x2: '[responsive]',
- x3: '[news]',
- x4: '[en-gb]',
- x5: '[http%3A%2F%2Flocalhost%2F]',
- x7: '[article-sfv]',
- x8: '[simorgh]',
- x9: '[Article%20Headline%20for%20SEO]',
- x11: '[2018-01-01T12:01:00.000Z]',
- x12: '[2018-01-01T14:00:00.000Z]',
- x13: '[Royal+Wedding+2018~Duchess+of+Sussex]',
- x14: '[2351f2b2-ce36-4f44-996d-c3c4f7f90eaa~803eaeb9-c0c3-4f1b-9a66-90efac3df2dc]',
- x17: '[Royal+Wedding+2018~Duchess+of+Sussex]',
+ expect(reverbParams).toEqual({
+ params: {
+ env: 'test',
+ page: {
+ contentId: 'urn:bbc:optimo:c0000000001o',
+ contentType: 'article-sfv',
+ destination: 'NEWS_PS_TEST',
+ name: 'news.articles.c0000000001o.page',
+ producer: 'NEWS',
+ additionalProperties: {
+ app_name: 'news',
+ app_type: 'responsive',
+ content_language: 'en-gb',
+ product_platform: null,
+ referrer_url: null,
+ x5: 'http%3A%2F%2Flocalhost%2F',
+ x8: 'simorgh',
+ x9: 'Article%20Headline%20for%20SEO',
+ x10: null,
+ x11: '2018-01-01T12:01:00.000Z',
+ x12: '2018-01-01T14:00:00.000Z',
+ x13: 'Royal+Wedding+2018~Duchess+of+Sussex',
+ x14: '2351f2b2-ce36-4f44-996d-c3c4f7f90eaa~803eaeb9-c0c3-4f1b-9a66-90efac3df2dc',
+ x16: '',
+ x17: 'Royal+Wedding+2018~Duchess+of+Sussex',
+ x18: false,
+ },
+ },
+ user: { isSignedIn: false },
+ },
+ eventDetails: { eventName: 'pageView' },
});
});
@@ -346,33 +357,39 @@ describe('ATI Analytics Container', () => {
service: 'azeri',
});
- const { pageviewParams } = mockCanonical.mock.calls[0][0];
-
- const parsedATIParams = Object.fromEntries(
- new URLSearchParams(pageviewParams),
- );
+ const { reverbParams } = mockCanonical.mock.calls[0][0];
- expect(parsedATIParams).toEqual({
- s: '598343',
- s2: '6',
- p: 'azerbaijan::azeri.azerbaijan.photo_gallery.44208474.page',
- r: '1024x768x24x24',
- re: '1024x768',
- hl: '00-00-00',
- lng: 'en-US',
- x1: '[urn:bbc:cps:curie:asset:38229308-a0fb-654a-a274-19bec0414560]',
- x2: '[responsive]',
- x3: '[news-azeri]',
- x4: '[az]',
- x5: '[http%3A%2F%2Flocalhost%2F]',
- x7: '[article-photo-gallery]',
- x8: '[simorgh]',
- x9: '[Azərbaycan%20Xalq%20Cümhuriyyəti%20-%20Fotolarda%20-%20BBC%20News%20Azərbaycanca]',
- x11: '[2018-05-27T08:34:15.000Z]',
- x12: '[2018-05-27T08:34:15.000Z]',
- x13: '[History~Azerbaijan~Society~Culture~Politics~Human+rights~Azerbaijan+Democratic+Republic+100th+anniversary~Caucasus~Law+and+order]',
- x14: '[03eb3674-6190-4cd7-8104-1a00991d67a3~0f8e45e2-6499-44b1-be1f-1a3dd81e8af7~5307a8d9-f620-40f5-92d4-f99c919a6ffa~6a73afa3-ea6b-45c1-80bb-49060b99f864~75612fa6-147c-4a43-97fa-fcf70d9cced3~8b04c2e8-5409-4e7d-9877-3ccaf04727af~9e6f8e15-894a-45cb-9db9-d8881e8e6ae2~a86bc15e-ccd0-4ea9-9903-df3d4575a176~d94f45db-bb47-4e7b-b1a2-5bc3e6afd0aa]',
- x17: '[News]',
+ expect(reverbParams).toEqual({
+ params: {
+ env: 'test',
+ page: {
+ contentId:
+ 'urn:bbc:cps:curie:asset:38229308-a0fb-654a-a274-19bec0414560',
+ contentType: 'article-photo-gallery',
+ destination: 'WS_NEWS_LANGUAGES_TEST',
+ name: 'azerbaijan::azeri.azerbaijan.photo_gallery.44208474.page',
+ producer: 'AZERI',
+ additionalProperties: {
+ app_name: 'news-azeri',
+ app_type: 'responsive',
+ content_language: 'az',
+ product_platform: null,
+ referrer_url: null,
+ x5: 'http%3A%2F%2Flocalhost%2F',
+ x8: 'simorgh',
+ x9: 'Azərbaycan%20Xalq%20Cümhuriyyəti%20-%20Fotolarda%20-%20BBC%20News%20Azərbaycanca',
+ x11: '2018-05-27T08:34:15.000Z',
+ x12: '2018-05-27T08:34:15.000Z',
+ x13: 'History~Azerbaijan~Society~Culture~Politics~Human+rights~Azerbaijan+Democratic+Republic+100th+anniversary~Caucasus~Law+and+order',
+ x14: '03eb3674-6190-4cd7-8104-1a00991d67a3~0f8e45e2-6499-44b1-be1f-1a3dd81e8af7~5307a8d9-f620-40f5-92d4-f99c919a6ffa~6a73afa3-ea6b-45c1-80bb-49060b99f864~75612fa6-147c-4a43-97fa-fcf70d9cced3~8b04c2e8-5409-4e7d-9877-3ccaf04727af~9e6f8e15-894a-45cb-9db9-d8881e8e6ae2~a86bc15e-ccd0-4ea9-9903-df3d4575a176~d94f45db-bb47-4e7b-b1a2-5bc3e6afd0aa',
+ x16: '',
+ x17: 'News',
+ x18: false,
+ },
+ },
+ user: { isSignedIn: false },
+ },
+ eventDetails: { eventName: 'pageView' },
});
});
@@ -454,34 +471,39 @@ describe('ATI Analytics Container', () => {
service: 'mundo',
});
- const { pageviewParams } = mockCanonical.mock.calls[0][0];
-
- const parsedATIParams = Object.fromEntries(
- new URLSearchParams(pageviewParams),
- );
+ const { reverbParams } = mockCanonical.mock.calls[0][0];
- expect(parsedATIParams).toEqual({
- s: '598343',
- s2: '62',
- p: 'mundo.story.23263889.page',
- r: '1024x768x24x24',
- re: '1024x768',
- hl: '00-00-00',
- lng: 'en-US',
- x1: '[urn:bbc:cps:curie:asset:f776ad93-e486-b14a-b5ea-55955dd0644f]',
- x2: '[responsive]',
- x3: '[news-mundo]',
- x4: '[es]',
- x5: '[http%3A%2F%2Flocalhost%2F]',
- x7: '[article]',
- x8: '[simorgh]',
- x9: '[WS%20STY%20TEST%20-%20Full%20Headline%20-%20BBC%20News%20Mundo]',
- x11: '[2020-02-03T15:58:27.000Z]',
- x12: '[2020-05-06T11:02:07.000Z]',
- x13: '[Life~Fake+news]',
- x14: '[0239ab33-1cfc-4f5d-babb-a8159711af3e~e7539dc8-5cfb-413a-b4fe-0ad77bc665aa]',
- x16: '[Amuse me]',
- x17: '[News]',
+ expect(reverbParams).toEqual({
+ params: {
+ env: 'test',
+ page: {
+ contentId:
+ 'urn:bbc:cps:curie:asset:f776ad93-e486-b14a-b5ea-55955dd0644f',
+ contentType: 'article',
+ destination: 'WS_NEWS_LANGUAGES_TEST',
+ name: 'mundo.story.23263889.page',
+ producer: 'MUNDO',
+ additionalProperties: {
+ app_name: 'news-mundo',
+ app_type: 'responsive',
+ content_language: 'es',
+ product_platform: null,
+ referrer_url: null,
+ x5: 'http%3A%2F%2Flocalhost%2F',
+ x8: 'simorgh',
+ x9: 'WS%20STY%20TEST%20-%20Full%20Headline%20-%20BBC%20News%20Mundo',
+ x11: '2020-02-03T15:58:27.000Z',
+ x12: '2020-05-06T11:02:07.000Z',
+ x13: 'Life~Fake+news',
+ x14: '0239ab33-1cfc-4f5d-babb-a8159711af3e~e7539dc8-5cfb-413a-b4fe-0ad77bc665aa',
+ x16: 'Amuse me',
+ x17: 'News',
+ x18: false,
+ },
+ },
+ user: { isSignedIn: false },
+ },
+ eventDetails: { eventName: 'pageView' },
});
});
@@ -613,34 +635,43 @@ describe('ATI Analytics Container', () => {
service: 'ukrainian',
});
- const { pageviewParams } = mockCanonical.mock.calls[0][0];
-
- const parsedATIParams = Object.fromEntries(
- new URLSearchParams(pageviewParams),
- );
+ const { reverbParams } = mockCanonical.mock.calls[0][0];
- expect(parsedATIParams).toEqual({
- s: '598343',
- s2: '94',
- p: 'news::ukrainian.news.story.53561143.page',
- r: '1024x768x24x24',
- re: '1024x768',
- hl: '00-00-00',
- lng: 'en-US',
- x1: '[urn:bbc:cps:curie:asset:9e539daf-1d79-4630-900c-7db33c4bf1ac]',
- x2: '[responsive]',
- x3: '[news-ukrainian]',
- x4: '[uk]',
- x5: '[http%3A%2F%2Flocalhost%2F]',
- x7: '[article]',
- x8: '[simorgh]',
- x9: '[Виробництво%20героїну%20зросло%20завдяки%20сонячним%20батареям.%20Погляд%20з%20Британії%20-%20BBC%20News%20Україна]',
- x11: '[2020-07-28T13:25:13.000Z]',
- x12: '[2020-07-28T13:25:13.000Z]',
- x13: '[Afghanistan~Drug+use~Drugs+trade~Ukraine]',
- x14: '[1a5696c5-07d0-4a08-8b54-41ad5cd534b6~37cd3473-7b24-44b0-84c1-bf3c4801df5e~4b4cca1c-d458-4310-819e-dd48572b12c4~ee8750ed-a7fb-453f-bfca-2aa8b3fb064c]',
- x16: '[WS - Educate me]',
- x17: '[News]',
+ expect(reverbParams).toEqual({
+ params: {
+ env: 'test',
+ page: {
+ contentId:
+ 'urn:bbc:cps:curie:asset:9e539daf-1d79-4630-900c-7db33c4bf1ac',
+ contentType: 'article',
+ destination: 'WS_NEWS_LANGUAGES_TEST',
+ name: 'news::ukrainian.news.story.53561143.page',
+ producer: 'UKRAINIAN',
+ additionalProperties: {
+ app_name: 'news-ukrainian',
+ app_type: 'responsive',
+ content_language: 'uk',
+ product_platform: null,
+ referrer_url: null,
+ x5: 'http%3A%2F%2Flocalhost%2F',
+ x8: 'simorgh',
+ x9: 'Виробництво%20героїну%20зросло%20завдяки%20сонячним%20батареям.%20Погляд%20з%20Британії%20-%20BBC%20News%20Україна',
+ x11: '2020-07-28T13:25:13.000Z',
+ x12: '2020-07-28T13:25:13.000Z',
+ x13: 'Afghanistan~Drug+use~Drugs+trade~Ukraine',
+ x14: '1a5696c5-07d0-4a08-8b54-41ad5cd534b6~37cd3473-7b24-44b0-84c1-bf3c4801df5e~4b4cca1c-d458-4310-819e-dd48572b12c4~ee8750ed-a7fb-453f-bfca-2aa8b3fb064c',
+ x16: 'WS - Educate me',
+ x17: 'News',
+ x18: false,
+ },
+ },
+ user: {
+ isSignedIn: false,
+ },
+ },
+ eventDetails: {
+ eventName: 'pageView',
+ },
});
});
@@ -719,34 +750,43 @@ describe('ATI Analytics Container', () => {
service: 'ukrainian',
});
- const { pageviewParams } = mockCanonical.mock.calls[0][0];
-
- const parsedATIParams = Object.fromEntries(
- new URLSearchParams(pageviewParams),
- );
+ const { reverbParams } = mockCanonical.mock.calls[0][0];
- expect(parsedATIParams).toEqual({
- s: '598343',
- s2: '94',
- p: 'russian_features::ukrainian.russian_features.story.53477115.page',
- r: '1024x768x24x24',
- re: '1024x768',
- hl: '00-00-00',
- lng: 'en-US',
- x1: '[urn:bbc:cps:curie:asset:307108d3-9bcc-4829-990c-4b42c1290258]',
- x2: '[responsive]',
- x3: '[news-ukrainian]',
- x4: '[ru]',
- x5: '[http%3A%2F%2Flocalhost%2F]',
- x7: '[article]',
- x8: '[simorgh]',
- x9: '[Карта%20новых%20районов%20Украины:%20кто%20и%20кого%20поглотил%20-%20BBC%20News%20Україна]',
- x11: '[2020-07-21T13:00:09.000Z]',
- x12: '[2020-07-21T13:00:09.000Z]',
- x13: '[Society~Politics~Ukraine]',
- x14: '[5307a8d9-f620-40f5-92d4-f99c919a6ffa~75612fa6-147c-4a43-97fa-fcf70d9cced3~ee8750ed-a7fb-453f-bfca-2aa8b3fb064c]',
- x16: '[WS - Update me]',
- x17: '[News]',
+ expect(reverbParams).toEqual({
+ params: {
+ env: 'test',
+ page: {
+ contentId:
+ 'urn:bbc:cps:curie:asset:307108d3-9bcc-4829-990c-4b42c1290258',
+ contentType: 'article',
+ destination: 'WS_NEWS_LANGUAGES_TEST',
+ name: 'russian_features::ukrainian.russian_features.story.53477115.page',
+ producer: 'UKRAINIAN',
+ additionalProperties: {
+ app_name: 'news-ukrainian',
+ app_type: 'responsive',
+ content_language: 'ru',
+ product_platform: null,
+ referrer_url: null,
+ x5: 'http%3A%2F%2Flocalhost%2F',
+ x8: 'simorgh',
+ x9: 'Карта%20новых%20районов%20Украины:%20кто%20и%20кого%20поглотил%20-%20BBC%20News%20Україна',
+ x11: '2020-07-21T13:00:09.000Z',
+ x12: '2020-07-21T13:00:09.000Z',
+ x13: 'Society~Politics~Ukraine',
+ x14: '5307a8d9-f620-40f5-92d4-f99c919a6ffa~75612fa6-147c-4a43-97fa-fcf70d9cced3~ee8750ed-a7fb-453f-bfca-2aa8b3fb064c',
+ x16: 'WS - Update me',
+ x17: 'News',
+ x18: false,
+ },
+ },
+ user: {
+ isSignedIn: false,
+ },
+ },
+ eventDetails: {
+ eventName: 'pageView',
+ },
});
});
@@ -803,127 +843,6 @@ describe('ATI Analytics Container', () => {
});
});
- describe('XTO Marketing string', () => {
- it('should include the xto marketing string for a valid campaign type', () => {
- jest
- .spyOn(window.location, 'href', 'get')
- .mockImplementation(
- () =>
- 'https://localhost?at_medium=email&at_emailtype=acquisition&at_creation=my_creation',
- );
-
- const mockCanonical = jest.fn().mockReturnValue('canonical-return-value');
- // @ts-expect-error - we need to mock these functions to ensure tests are deterministic
- canonical.default = mockCanonical;
-
- const {
- metadata: { atiAnalytics },
- } = styAssetData;
-
- const atiData = {
- ...atiAnalytics,
- pageTitle: `${atiAnalytics.pageTitle} - BBC News Mundo`,
- };
-
- render(, {
- ...defaultRenderProps,
- atiData,
- isAmp: false,
- pageData: styAssetData,
- pageType: STORY_PAGE,
- service: 'mundo',
- });
-
- const { pageviewParams } = mockCanonical.mock.calls[0][0];
-
- const parsedATIParams = Object.fromEntries(
- new URLSearchParams(pageviewParams),
- );
-
- expect(parsedATIParams).toEqual({
- s: '598343',
- s2: '62',
- p: 'mundo.story.23263889.page',
- r: '1024x768x24x24',
- re: '1024x768',
- hl: '00-00-00',
- lng: 'en-US',
- x1: '[urn:bbc:cps:curie:asset:f776ad93-e486-b14a-b5ea-55955dd0644f]',
- x2: '[responsive]',
- x3: '[news-mundo]',
- x4: '[es]',
- x5: '[https%3A%2F%2Flocalhost%3Fat_medium%3Demail%26at_emailtype%3Dacquisition%26at_creation%3Dmy_creation]',
- x7: '[article]',
- x8: '[simorgh]',
- x9: '[WS%20STY%20TEST%20-%20Full%20Headline%20-%20BBC%20News%20Mundo]',
- x11: '[2020-02-03T15:58:27.000Z]',
- x12: '[2020-05-06T11:02:07.000Z]',
- x13: '[Life~Fake+news]',
- x14: '[0239ab33-1cfc-4f5d-babb-a8159711af3e~e7539dc8-5cfb-413a-b4fe-0ad77bc665aa]',
- x16: '[Amuse me]',
- x17: '[News]',
- xto: 'EREC--[my_creation]---@',
- });
- });
- it('should not include the xto marketing string when a campaign type is not specified', () => {
- jest
- .spyOn(window.location, 'href', 'get')
- .mockImplementation(() => 'http://localhost?foo=bar');
-
- const mockCanonical = jest.fn().mockReturnValue('canonical-return-value');
- // @ts-expect-error - we need to mock these functions to ensure tests are deterministic
- canonical.default = mockCanonical;
-
- const {
- metadata: { atiAnalytics },
- } = styAssetData;
-
- const atiData = {
- ...atiAnalytics,
- pageTitle: `${atiAnalytics.pageTitle} - BBC News Mundo`,
- };
-
- render(, {
- ...defaultRenderProps,
- atiData,
- isAmp: false,
- pageData: styAssetData,
- pageType: STORY_PAGE,
- service: 'mundo',
- });
-
- const { pageviewParams } = mockCanonical.mock.calls[0][0];
-
- const parsedATIParams = Object.fromEntries(
- new URLSearchParams(pageviewParams),
- );
-
- expect(parsedATIParams).toEqual({
- s: '598343',
- s2: '62',
- p: 'mundo.story.23263889.page',
- r: '1024x768x24x24',
- re: '1024x768',
- hl: '00-00-00',
- lng: 'en-US',
- x1: '[urn:bbc:cps:curie:asset:f776ad93-e486-b14a-b5ea-55955dd0644f]',
- x2: '[responsive]',
- x3: '[news-mundo]',
- x4: '[es]',
- x5: '[http%3A%2F%2Flocalhost%3Ffoo%3Dbar]',
- x7: '[article]',
- x8: '[simorgh]',
- x9: '[WS%20STY%20TEST%20-%20Full%20Headline%20-%20BBC%20News%20Mundo]',
- x11: '[2020-02-03T15:58:27.000Z]',
- x12: '[2020-05-06T11:02:07.000Z]',
- x13: '[Life~Fake+news]',
- x14: '[0239ab33-1cfc-4f5d-babb-a8159711af3e~e7539dc8-5cfb-413a-b4fe-0ad77bc665aa]',
- x16: '[Amuse me]',
- x17: '[News]',
- });
- });
- });
-
describe('Reverb', () => {
it('should supply reverbParams when Reverb is enabled', () => {
const mockCanonical = jest.fn().mockReturnValue('canonical-return-value');
@@ -934,7 +853,7 @@ describe('ATI Analytics Container', () => {
metadata: { atiAnalytics },
} = articleDataNews;
- // @ts-expect-error - only partial data required to manually set 'useReverb' to true
+ // @ts-expect-error - only partial data required to manually to test reverbParams
const serviceContextProps: ServiceConfig = {
atiAnalyticsAppName: 'atiAnalyticsAppName',
atiAnalyticsProducerId: 'atiAnalyticsProducerId',
@@ -942,7 +861,6 @@ describe('ATI Analytics Container', () => {
service: 'pidgin',
brandName: 'brandName',
lang: 'pcm',
- useReverb: true,
};
render(
@@ -989,45 +907,6 @@ describe('ATI Analytics Container', () => {
});
});
- it('should set reverbParams to null when Reverb is disabled', () => {
- const mockCanonical = jest.fn().mockReturnValue('canonical-return-value');
- // @ts-expect-error - we need to mock these functions to ensure tests are deterministic
- canonical.default = mockCanonical;
-
- const {
- metadata: { atiAnalytics },
- } = articleDataNews;
-
- // @ts-expect-error - only partial data required to manually set 'useReverb' to false
- const serviceContextProps: ServiceConfig = {
- atiAnalyticsAppName: 'atiAnalyticsAppName',
- atiAnalyticsProducerId: 'atiAnalyticsProducerId',
- atiAnalyticsProducerName: 'atiAnalyticsProducerName',
- service: 'news',
- brandName: 'brandName',
- lang: 'en-GB',
- useReverb: false,
- };
-
- render(
-
-
- ,
- {
- ...defaultRenderProps,
- atiData: atiAnalytics,
- isAmp: false,
- pageData: articleDataNews,
- pageType: ARTICLE_PAGE,
- isUK: true,
- },
- );
-
- const { reverbParams } = mockCanonical.mock.calls[0][0];
-
- expect(reverbParams).toBeNull();
- });
-
it('should call AmpATIAnalytics when platform is Amp', () => {
const mockAmp = jest.fn().mockReturnValue('amp-return-value');
@@ -1037,7 +916,7 @@ describe('ATI Analytics Container', () => {
metadata: { atiAnalytics },
} = articleDataNews;
- // @ts-expect-error - only partial data required to manually set 'useReverb' to true
+ // @ts-expect-error - only partial data required to test AmpATIAnalytics is called
const serviceContextProps: ServiceConfig = {
atiAnalyticsAppName: 'atiAnalyticsAppName',
atiAnalyticsProducerId: 'atiAnalyticsProducerId',
@@ -1045,7 +924,6 @@ describe('ATI Analytics Container', () => {
service: 'pidgin',
brandName: 'brandName',
lang: 'pcm',
- useReverb: true,
};
render(
@@ -1097,7 +975,7 @@ describe('ATI Analytics Container', () => {
metadata: { atiAnalytics },
} = articleDataNews;
- // @ts-expect-error - only partial data required to manually set 'useReverb' to true
+ // @ts-expect-error - only partial data required to test AmpGeo component rendering
const serviceContextProps: ServiceConfig = {
atiAnalyticsAppName: 'atiAnalyticsAppName',
atiAnalyticsProducerId: 'atiAnalyticsProducerId',
@@ -1105,7 +983,6 @@ describe('ATI Analytics Container', () => {
service: 'pidgin',
brandName: 'brandName',
lang: 'pcm',
- useReverb: true,
};
const { container } = render(
diff --git a/src/app/components/ATIAnalytics/index.tsx b/src/app/components/ATIAnalytics/index.tsx
index 90fe33cfd96..a5729d9d092 100644
--- a/src/app/components/ATIAnalytics/index.tsx
+++ b/src/app/components/ATIAnalytics/index.tsx
@@ -5,31 +5,18 @@ 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);
const serviceContext = use(ServiceContext);
const { isAmp } = requestContext;
- const { useReverb } = serviceContext;
- const urlPageViewParams = buildATIUrl({
+ const reverbParams = buildReverbParams({
requestContext,
serviceContext,
atiData,
- }) as string;
-
- const reverbParams = useReverb
- ? buildReverbParams({
- requestContext,
- serviceContext,
- atiData,
- })
- : null;
-
- if (!urlPageViewParams) {
- return null;
- }
+ });
return isAmp ? (
<>
@@ -37,10 +24,7 @@ const ATIAnalytics = ({ atiData = {} }: ATIProps) => {
>
) : (
-
+
);
};
diff --git a/src/app/components/ATIAnalytics/params/buildParams/index.test.ts b/src/app/components/ATIAnalytics/params/buildParams/index.test.ts
index c0c3c7d2707..0aaff70ffca 100644
--- a/src/app/components/ATIAnalytics/params/buildParams/index.test.ts
+++ b/src/app/components/ATIAnalytics/params/buildParams/index.test.ts
@@ -1,16 +1,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 '.';
-
-(analyticsUtils.getAtUserId as jest.Mock) = jest.fn();
-(analyticsUtils.getCurrentTime as jest.Mock) = jest
- .fn()
- .mockReturnValue('00-00-00');
-(analyticsUtils.getPublishedDatetime as jest.Mock) = jest
- .fn()
- .mockReturnValue('1970-01-01T00:00:00.000Z');
+import { buildPageATIParams } from '.';
jest
.spyOn(document, 'referrer', 'get')
@@ -33,7 +24,7 @@ const serviceContext: ServiceConfig = {
lang: 'pcm',
};
-describe('implementation of buildPageATIParams and buildPageATIUrl', () => {
+describe('implementation of buildPageATIParams', () => {
afterEach(() => {
jest.clearAllMocks();
});
@@ -88,40 +79,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 +148,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 +221,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 +273,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 +326,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 +404,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 +479,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 +552,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 +652,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);
- });
});
});
});
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,
diff --git a/src/app/components/ATIAnalytics/params/index.test.ts b/src/app/components/ATIAnalytics/params/index.test.ts
index 5daacbfd4e2..f352d647191 100644
--- a/src/app/components/ATIAnalytics/params/index.test.ts
+++ b/src/app/components/ATIAnalytics/params/index.test.ts
@@ -1,5 +1,4 @@
/* eslint-disable no-console */
-import * as analyticsUtils from '../../../lib/analyticsUtils';
import {
ARTICLE_PAGE,
MEDIA_ASSET_PAGE,
@@ -7,20 +6,11 @@ import {
MEDIA_ARTICLE_PAGE,
HOME_PAGE,
} from '../../../routes/utils/pageTypes';
-import { buildATIUrl, buildATIEventTrackingParams } from '.';
-import * as buildPageATIFunctionImports from './buildParams';
+import buildReverbParams from '.';
import { RequestContextProps } from '../../../contexts/RequestContext';
import { ServiceConfig } from '../../../models/types/serviceConfig';
import { ATIData } from '../types';
-(analyticsUtils.getAtUserId as jest.Mock) = jest.fn();
-(analyticsUtils.getCurrentTime as jest.Mock) = jest
- .fn()
- .mockReturnValue('00-00-00');
-(analyticsUtils.getPublishedDatetime as jest.Mock) = jest
- .fn()
- .mockReturnValue('1970-01-01T00:00:00.000Z');
-
jest
.spyOn(document, 'referrer', 'get')
.mockReturnValue('https://www.example.com');
@@ -126,458 +116,212 @@ const cpsPGLPageAnalyticsData: ATIData = {
};
describe('ATIAnalytics params', () => {
- describe('buildATIUrl', () => {
- it('should return the correct article url', () => {
- const url = buildATIUrl({
+ describe('buildReverbParams', () => {
+ it('should return the correct page view tracking params for an article page', () => {
+ const params = buildReverbParams({
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,
+ expect(params).toEqual({
+ params: {
+ page: {
+ contentId: 'urn:bbc:optimo:asset:crgrx86em6yo',
+ contentType: 'article',
+ destination: 'statsDestination',
+ name: 'pidgin.articles.crgrx86em6yo.page',
+ additionalProperties: {
+ app_name: 'atiAnalyticsAppName',
+ app_type: 'responsive',
+ content_language: 'pcm',
+ product_platform: null,
+ referrer_url: 'https://www.example.com',
+ x5: 'http%3A%2F%2Flocalhost%2F',
+ 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',
+ x16: '',
+ x17: 'Nigeria~Education~Lagos%20state~Women',
+ x18: false,
+ },
+ },
+ user: {
+ isSignedIn: false,
+ },
+ },
+ eventDetails: {
+ eventName: 'pageView',
+ },
});
-
- 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({
+ it('should return the correct page view tracking params for a home page', () => {
+ const params = buildReverbParams({
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('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', () => {
- it('should return the correct article params', () => {
- const params = buildATIEventTrackingParams({
- requestContext: { ...requestContext, pageType: ARTICLE_PAGE },
- atiData: articlePageAnalyticsData,
- serviceContext,
- });
expect(params).toEqual({
- appName: 'atiAnalyticsAppName',
- contentId: 'urn:bbc:optimo:asset:crgrx86em6yo',
- contentType: 'article',
- categoryName: 'Nigeria~Education~Lagos%20state~Women',
- isUK: false,
- language: 'pcm',
- ldpThingIds:
- '3d5d5e30-dd50-4041-96d5-c970b20005b9~6942cb29-9d3f-4c9c-9806-0a0578c286d6~d651d520-a675-4911-8832-1596f257000b~e45cb5f8-3c87-4ebd-ac1c-058e9be22862',
- ldpThingLabels: 'Nigeria~Education~Lagos%20state~Women',
- pageIdentifier: 'pidgin.articles.crgrx86em6yo.page',
- pageTitle:
- 'Aminat Yusuf: Tips to pass exam - Overall LASU best graduate drop update',
- libraryVersion: 'simorgh',
- platform: 'canonical',
- producerId: 'atiAnalyticsProducerId',
- service: 'pidgin',
- statsDestination: 'statsDestination',
- timePublished: '2023-07-19T15:57:54.500Z',
- timeUpdated: '2023-07-19T15:57:54.500Z',
- nationsProducer: 'scotland',
+ params: {
+ page: {
+ contentId: 'urn:bbc:tipo:topic:cm7682qz7v1t',
+ contentType: 'index-home',
+ destination: 'statsDestination',
+ name: 'kyrgyz.page',
+ additionalProperties: {
+ app_name: 'atiAnalyticsAppName',
+ app_type: 'responsive',
+ content_language: 'pcm',
+ product_platform: null,
+ referrer_url: 'https://www.example.com',
+ x5: 'http%3A%2F%2Flocalhost%2F',
+ x8: 'simorgh',
+ x9: 'pageTitle',
+ x16: '',
+ x18: false,
+ },
+ },
+ user: {
+ isSignedIn: false,
+ },
+ },
+ eventDetails: {
+ eventName: 'pageView',
+ },
});
});
- it('should return the correct media article params', () => {
- const params = buildATIEventTrackingParams({
+ it('should return the correct page view tracking params for a media article page', () => {
+ const params = buildReverbParams({
requestContext: { ...requestContext, pageType: MEDIA_ARTICLE_PAGE },
atiData: mediaArticlePageAnalyticsData,
serviceContext,
});
+
expect(params).toEqual({
- appName: 'atiAnalyticsAppName',
- campaigns: undefined,
- categoryName: 'Environment~Narendra+Modi~Nature~India~Severe+weather',
- contentId: 'urn:bbc:optimo:asset:c4nrpd0d4nro',
- contentType: 'article-sfv',
- isUK: false,
- language: 'ha',
- ldpThingIds:
- '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',
- ldpThingLabels: 'Environment~Narendra+Modi~Nature~India~Severe+weather',
- pageIdentifier: 'hausa.articles.c4nrpd0d4nro.page',
- pageTitle: 'Kalli yadda ambaliya ta tagayyara wani yanki na Indiya',
- libraryVersion: 'simorgh',
- nationsProducer: null,
- platform: 'canonical',
- producerId: 'atiAnalyticsProducerId',
- service: 'pidgin',
- statsDestination: 'statsDestination',
- timePublished: '2023-07-11T17:42:48.771Z',
- timeUpdated: '2023-07-11T17:42:48.771Z',
+ params: {
+ page: {
+ contentId: 'urn:bbc:optimo:asset:c4nrpd0d4nro',
+ contentType: 'article-sfv',
+ destination: 'statsDestination',
+ name: 'hausa.articles.c4nrpd0d4nro.page',
+ additionalProperties: {
+ app_name: 'atiAnalyticsAppName',
+ app_type: 'responsive',
+ content_language: 'ha',
+ product_platform: null,
+ referrer_url: 'https://www.example.com',
+ x5: 'http%3A%2F%2Flocalhost%2F',
+ x8: 'simorgh',
+ x9: 'Kalli%20yadda%20ambaliya%20ta%20tagayyara%20wani%20yanki%20na%20Indiya',
+ x10: null,
+ 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',
+ x16: '',
+ x17: 'Environment~Narendra+Modi~Nature~India~Severe+weather',
+ x18: false,
+ },
+ },
+ user: {
+ isSignedIn: false,
+ },
+ },
+ eventDetails: {
+ eventName: 'pageView',
+ },
});
});
- it('should return the correct MAP params', () => {
- const params = buildATIEventTrackingParams({
+ it('should return the correct page view tracking params for a MAP page', () => {
+ const params = buildReverbParams({
requestContext: { ...requestContext, pageType: MEDIA_ASSET_PAGE },
atiData: cpsMAPPageAnalyticsData,
serviceContext,
});
+
expect(params).toEqual({
- appName: 'atiAnalyticsAppName',
- categoryName: 'News',
- campaigns: [
- {
- campaignId: '5a988e4739461b000e9dabfc',
- campaignName: 'WS - Update me',
+ params: {
+ page: {
+ contentId: 'urn:bbc:cps:4d36f80b-8711-0b4e-8da0-ef76ae8ac470',
+ contentType: 'article-media-asset',
+ destination: 'statsDestination',
+ name: 'media::mundo.media.media_asset.41174775.page',
+ additionalProperties: {
+ app_name: 'atiAnalyticsAppName',
+ app_type: 'responsive',
+ content_language: 'es',
+ product_platform: null,
+ referrer_url: 'https://www.example.com',
+ x5: 'http%3A%2F%2Flocalhost%2F',
+ 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',
+ x18: false,
+ },
},
- ],
- contentId: 'urn:bbc:cps:4d36f80b-8711-0b4e-8da0-ef76ae8ac470',
- contentType: 'article-media-asset',
- isUK: false,
- language: 'es',
- ldpThingIds:
- '75612fa6-147c-4a43-97fa-fcf70d9cced3~7613abe4-1c05-4594-a5ec-3ccf6268b220~e0d04166-b92f-468e-9e68-d5f9330e6ae7',
- ldpThingLabels: 'Politics~Nicaragua~Latin+America',
- libraryVersion: 'simorgh',
- nationsProducer: undefined,
- pageIdentifier: 'media::mundo.media.media_asset.41174775.page',
- pageTitle:
- '¿Qué es el albur en México y cómo puedes saber si te están "albureando"? - BBC News Mundo',
- platform: 'canonical',
- producerId: 'atiAnalyticsProducerId',
- service: 'pidgin',
- statsDestination: 'statsDestination',
- timePublished: '2017-09-14T14:09:14.000Z',
- timeUpdated: '2017-09-14T14:09:14.000Z',
+ user: {
+ isSignedIn: false,
+ },
+ },
+ eventDetails: {
+ eventName: 'pageView',
+ },
});
});
- it('should return the correct PGL params', () => {
- const params = buildATIEventTrackingParams({
+ it('should return the correct page view tracking params for a PGL page', () => {
+ const params = buildReverbParams({
requestContext: { ...requestContext, pageType: PHOTO_GALLERY_PAGE },
atiData: cpsPGLPageAnalyticsData,
serviceContext,
});
- expect(params).toEqual({
- appName: 'atiAnalyticsAppName',
- campaigns: [
- {
- campaignId: '5a988e3139461b000e9dabf9',
- campaignName: 'WS - Divert me',
- },
- ],
- categoryName: 'News',
- contentId:
- 'urn:bbc:cps:curie:asset:08e22e90-7361-cd47-b586-7cb53fc5a012',
- contentType: 'article-photo-gallery',
- isUK: false,
- language: 'es',
- ldpThingIds: '25844b6e-80b0-4de9-8ea0-7a35e7d4086f',
- ldpThingLabels: 'Technology',
- libraryVersion: 'simorgh',
- nationsProducer: undefined,
- pageIdentifier: 'sport::mundo.sport.photo_gallery.36935058.page',
- pageTitle:
- 'Río 2016, el antes y el ahora: cómo ha cambiado la ropa deportiva en más de un siglo de juegos olímpicos - BBC News Mundo',
- platform: 'canonical',
- producerId: 'atiAnalyticsProducerId',
- service: 'pidgin',
- statsDestination: 'statsDestination',
- timePublished: '2016-08-07T09:21:02.000Z',
- timeUpdated: '2016-08-07T09:21:02.000Z',
- });
- });
- it('should return the correct Homepage params', () => {
- const params = buildATIEventTrackingParams({
- requestContext: { ...requestContext, pageType: HOME_PAGE },
- atiData: homePageAnalyticsData,
- serviceContext,
- });
expect(params).toEqual({
- appName: 'atiAnalyticsAppName',
- campaigns: undefined,
- categoryName: undefined,
- contentId: 'urn:bbc:tipo:topic:cm7682qz7v1t',
- contentType: 'index-home',
- isUK: false,
- language: 'pcm',
- ldpThingIds: undefined,
- ldpThingLabels: undefined,
- libraryVersion: 'simorgh',
- nationsProducer: undefined,
- pageIdentifier: 'kyrgyz.page',
- pageTitle: 'pageTitle',
- platform: 'canonical',
- producerId: 'atiAnalyticsProducerId',
- service: 'pidgin',
- statsDestination: 'statsDestination',
- timePublished: undefined,
- timeUpdated: undefined,
- });
- });
-
- describe('buildPageATIParams invocation', () => {
- let buildPageATIParamsSpy: jest.SpyInstance;
- const { error } = console;
-
- beforeEach(() => {
- buildPageATIParamsSpy = jest.spyOn(
- buildPageATIFunctionImports,
- 'buildPageATIParams',
- );
- console.error = jest.fn();
- });
-
- afterEach(() => {
- jest.clearAllMocks();
- console.error = error;
- });
-
- it('should invoke buildPageATIParams for supported page types', () => {
- buildATIEventTrackingParams({
- requestContext: { ...requestContext, pageType: HOME_PAGE },
- atiData: homePageAnalyticsData,
- serviceContext,
- });
-
- expect(buildPageATIParamsSpy).toHaveBeenCalledWith(
- expect.objectContaining({
- requestContext: { ...requestContext, pageType: HOME_PAGE },
- atiData: homePageAnalyticsData,
- serviceContext,
- }),
- );
+ params: {
+ page: {
+ contentId:
+ 'urn:bbc:cps:curie:asset:08e22e90-7361-cd47-b586-7cb53fc5a012',
+ contentType: 'article-photo-gallery',
+ destination: 'statsDestination',
+ name: 'sport::mundo.sport.photo_gallery.36935058.page',
+ additionalProperties: {
+ app_name: 'atiAnalyticsAppName',
+ app_type: 'responsive',
+ content_language: 'es',
+ product_platform: null,
+ referrer_url: 'https://www.example.com',
+ x5: 'http%3A%2F%2Flocalhost%2F',
+ 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',
+ x18: false,
+ },
+ },
+ user: {
+ isSignedIn: false,
+ },
+ },
+ eventDetails: {
+ eventName: 'pageView',
+ },
});
});
});
diff --git a/src/app/components/ATIAnalytics/params/index.ts b/src/app/components/ATIAnalytics/params/index.ts
index 3d41f55d00a..2207a4b12e7 100644
--- a/src/app/components/ATIAnalytics/params/index.ts
+++ b/src/app/components/ATIAnalytics/params/index.ts
@@ -1,37 +1,10 @@
-import {
- buildPageATIUrl,
- buildPageATIParams,
- buildPageReverbParams,
-} from './buildParams';
-import {
- ATIConfigurationDetailsProviders,
- ReverbDetailsProviders,
-} from '../types';
+import { buildPageReverbParams } from './buildParams';
+import { ReverbDetailsProviders } from '../types';
-export const buildATIUrl = ({
- requestContext,
- serviceContext,
- atiData,
-}: ATIConfigurationDetailsProviders) => {
- return buildPageATIUrl({ atiData, requestContext, serviceContext });
-};
-
-export const buildReverbParams = ({
+export default ({
requestContext,
serviceContext,
atiData,
}: ReverbDetailsProviders) => {
return buildPageReverbParams({ atiData, requestContext, serviceContext });
};
-
-export const buildATIEventTrackingParams = ({
- requestContext,
- serviceContext,
- atiData,
-}: ATIConfigurationDetailsProviders) => {
- return buildPageATIParams({
- atiData,
- requestContext,
- serviceContext,
- });
-};
diff --git a/src/app/components/ATIAnalytics/types.ts b/src/app/components/ATIAnalytics/types.ts
index 7ecc5f51e76..ac6fd73dbd8 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 {
@@ -161,7 +159,6 @@ export interface ATIEventTrackingProps {
advertiserID?: string;
url?: string;
detailedPlacement?: string;
- useReverb?: boolean;
experimentName?: string;
experimentVariant?: string | null;
ampExperimentName?: string;
diff --git a/src/app/components/OptimizelyPageMetrics/PageCompleteTracking/index.test.tsx b/src/app/components/OptimizelyPageMetrics/PageCompleteTracking/index.test.tsx
index 4c265075aa1..f5292a1987d 100644
--- a/src/app/components/OptimizelyPageMetrics/PageCompleteTracking/index.test.tsx
+++ b/src/app/components/OptimizelyPageMetrics/PageCompleteTracking/index.test.tsx
@@ -38,7 +38,7 @@ const IntersectionObserver = jest.fn(cb => {
const getObserverInstance = (element: HTMLElement) => {
try {
- // @ts-expect-error for testing purposes
+ // @ts-expect-error retrieve mock IntersectionObserver instances for testing purposes
const [instance] = Array.from(observers).find(([, item]) =>
item.elements.has(element),
);
diff --git a/src/app/contexts/EventTrackingContext/index.tsx b/src/app/contexts/EventTrackingContext/index.tsx
index 4c7e36c6b79..3f61fb2bc2e 100644
--- a/src/app/contexts/EventTrackingContext/index.tsx
+++ b/src/app/contexts/EventTrackingContext/index.tsx
@@ -26,7 +26,6 @@ import {
} from '../../routes/utils/pageTypes';
import { PageTypes } from '../../models/types/global';
import { EventTrackingContextProps } from '../../models/types/eventTracking';
-import { buildATIEventTrackingParams } from '../../components/ATIAnalytics/params';
import { ServiceContext } from '../ServiceContext';
import { ATIData } from '../../components/ATIAnalytics/types';
@@ -81,7 +80,7 @@ export const EventTrackingContextProvider = ({
atiData,
}: PropsWithChildren) => {
const requestContext = use(RequestContext);
- const { pageType } = requestContext;
+ const { pageType, platform, statsDestination } = requestContext;
const serviceContext = use(ServiceContext);
const { atiAnalyticsProducerId, atiAnalyticsProducerName } = serviceContext;
@@ -91,13 +90,7 @@ export const EventTrackingContextProvider = ({
const trackingProps = useMemo(() => {
if (eventTrackingIsEnabled && atiData) {
const campaignID = getCampaignID(pageType as CampaignPageTypes);
-
- const { pageIdentifier, platform, statsDestination } =
- buildATIEventTrackingParams({
- requestContext,
- serviceContext,
- atiData,
- });
+ const { pageIdentifier } = atiData;
return {
campaignID,
@@ -115,8 +108,8 @@ export const EventTrackingContextProvider = ({
atiData,
eventTrackingIsEnabled,
pageType,
- requestContext,
- serviceContext,
+ platform,
+ statsDestination,
]);
if (!eventTrackingIsEnabled || !atiData) {
diff --git a/src/app/hooks/useClickTrackerHandler/index.client.test.jsx b/src/app/hooks/useClickTrackerHandler/index.client.test.jsx
index 970b3418fb3..c844a6fb282 100644
--- a/src/app/hooks/useClickTrackerHandler/index.client.test.jsx
+++ b/src/app/hooks/useClickTrackerHandler/index.client.test.jsx
@@ -4,10 +4,9 @@
import { createContext } from 'react';
import { OptimizelyProvider } from '@optimizely/react-sdk';
import userEvent from '@testing-library/user-event';
-import { waitFor } from '@testing-library/dom';
import { STORY_PAGE } from '#app/routes/utils/pageTypes';
+import constructReverbUrl from '#app/lib/analyticsUtils/staticATITracking/constructReverbUrl';
import * as trackingToggle from '#hooks/useTrackingToggle';
-import constructATIUrl from '#app/lib/analyticsUtils/staticATITracking/constructATIUrl';
import * as useOptimizelyVariation from '../useOptimizelyVariation';
import {
@@ -16,6 +15,7 @@ import {
renderHook,
act,
fireEvent,
+ waitFor,
} from '../../components/react-testing-library-with-providers';
import * as serviceContextModule from '../../contexts/ServiceContext';
import pidginData from './fixtureData/tori-51745682.json';
@@ -37,8 +37,6 @@ const urlToObject = url => {
};
};
-process.env.SIMORGH_ATI_BASE_URL = 'https://logws1363.ati-host.net?';
-
const eventTrackingData = {
componentName: 'brand',
format: 'CHD=promo::2',
@@ -63,11 +61,6 @@ const defaultOptimizely = {
user: { attributes: { foo: 'bar' }, id: 'test' },
};
-// eslint-disable-next-line no-underscore-dangle
-window.__reverb = {
- __reverbLoadedPromise: Promise.resolve(reverbMock),
-};
-
const wrapper = ({ children }) => (
{
atiAnalyticsProducerId: '70',
atiAnalyticsProducerName: 'PIDGIN',
service: 'pidgin',
- useReverb: false,
}),
);
});
@@ -136,7 +128,102 @@ describe('useClickTrackerHandler', () => {
jest.clearAllMocks();
});
- describe('Click tracking', () => {
+ describe('Click tracking - Reverb', () => {
+ beforeEach(() => {
+ jest.replaceProperty(
+ serviceContextModule,
+ 'ServiceContext',
+ createContext({
+ atiAnalyticsProducerId: '70',
+ atiAnalyticsProducerName: 'PIDGIN',
+ service: 'pidgin',
+ }),
+ );
+
+ // eslint-disable-next-line no-underscore-dangle
+ window.__reverb = {
+ __reverbLoadedPromise: Promise.resolve(reverbMock),
+ };
+ });
+
+ it.each([
+ {
+ title: 'should trigger a beacon for a click event',
+ trackingData: { ...eventTrackingData },
+ expectedItemEvent: {
+ link: 'https://www.bbc.com/pidgin/articles/c93gd1yxng1o',
+ name: 'brand',
+ },
+ },
+ {
+ title: 'should trigger a beacon for an item level click event',
+ trackingData: {
+ ...eventTrackingData,
+ componentName: 'portrait-video',
+ itemTracker: {
+ type: 'portrait-video-promo',
+ text: 'Rollercoaster facts... while riding a rollercoaster',
+ position: 1,
+ duration: 73000,
+ resourceId: 'test-resource-id',
+ },
+ },
+ expectedItemEvent: {
+ duration: 73000,
+ link: 'https://www.bbc.com/pidgin/articles/c93gd1yxng1o',
+ name: 'portrait-video',
+ position: 1,
+ resource_id: 'test-resource-id',
+ text: 'Rollercoaster facts... while riding a rollercoaster',
+ type: 'portrait-video-promo',
+ },
+ },
+ ])('$title', async ({ trackingData, expectedItemEvent }) => {
+ const {
+ metadata: { atiAnalytics },
+ } = pidginData;
+
+ const TestLink = () => {
+ const { onClick: handleClick } = useClickTrackerHandler(trackingData);
+
+ return (
+
+ );
+ };
+
+ const { getByText } = render(, {
+ atiData: atiAnalytics,
+ pageData: pidginData,
+ pageType: STORY_PAGE,
+ pathname: '/pidgin',
+ service: 'pidgin',
+ toggles: defaultToggles,
+ });
+
+ await act(() => userEvent.click(getByText('Link')));
+
+ expect(reverbMock.userActionEvent).toHaveBeenCalledTimes(1);
+ expect(reverbMock.userActionEvent).toHaveBeenCalledWith(
+ 'viewability',
+ '',
+ {
+ event: { action: 'select', category: 'viewability' },
+ group: { name: 'article-sty', type: trackingData.componentName },
+ item: expectedItemEvent,
+ },
+ undefined,
+ undefined,
+ true,
+ );
+ });
+
it('should return a function', () => {
const { result } = renderHook(
() => useClickTrackerHandler(eventTrackingData),
@@ -155,7 +242,6 @@ describe('useClickTrackerHandler', () => {
metadata: { atiAnalytics },
} = pidginData;
- const spyFetch = jest.spyOn(global, 'fetch');
const { getByTestId } = render(
,
{
@@ -168,34 +254,36 @@ describe('useClickTrackerHandler', () => {
},
);
- expect(spyFetch).not.toHaveBeenCalled();
+ expect(reverbMock.userActionEvent).not.toHaveBeenCalled();
await act(() => userEvent.click(getByTestId('test-component')));
- expect(spyFetch).toHaveBeenCalledTimes(1);
+ expect(reverbMock.userActionEvent).toHaveBeenCalledTimes(1);
await act(() => userEvent.click(getByTestId('test-component')));
- expect(spyFetch).toHaveBeenCalledTimes(1);
-
- const [[viewEventUrl]] = spyFetch.mock.calls;
-
- expect(urlToObject(viewEventUrl)).toEqual({
- origin: 'https://logws1363.ati-host.net',
- pathname: '/',
- searchParams: {
- atc: 'PUB-[article-sty]-[brand]-[]-[CHD=promo::2]-[news::pidgin.news.story.51745682.page]-[]-[]-[]',
- hl: expect.stringMatching(/^.+?x.+?x.+?$/),
- idclient: expect.stringMatching(/^.+?-.+?-.+?-.+?$/),
- lng: 'en-US',
- p: 'news::pidgin.news.story.51745682.page',
- r: '1024x768x24x24',
- re: '1024x768',
- s: '598343',
- s2: '70',
- type: 'AT',
+ expect(reverbMock.userActionEvent).toHaveBeenCalledTimes(1);
+
+ expect(reverbMock.userActionEvent).toHaveBeenCalledWith(
+ 'viewability',
+ '',
+ {
+ event: {
+ category: 'viewability',
+ action: 'select',
+ },
+ group: {
+ name: 'article-sty',
+ type: 'brand',
+ },
+ item: {
+ name: 'brand',
+ },
},
- });
+ undefined,
+ undefined,
+ true,
+ );
});
it('should not send a tracking request if the toggle is disabled', async () => {
@@ -221,7 +309,7 @@ describe('useClickTrackerHandler', () => {
await act(() => userEvent.click(getByTestId('test-component')));
- expect(global.fetch).toHaveBeenCalledTimes(0);
+ expect(reverbMock.userActionEvent).toHaveBeenCalledTimes(0);
});
it('should send tracking request on click of child element (button)', async () => {
@@ -243,24 +331,28 @@ describe('useClickTrackerHandler', () => {
await act(() => userEvent.click(getByText('Button')));
- const [[viewEventUrl]] = global.fetch.mock.calls;
-
- expect(urlToObject(viewEventUrl)).toEqual({
- origin: 'https://logws1363.ati-host.net',
- pathname: '/',
- searchParams: {
- atc: 'PUB-[article-sty]-[brand]-[]-[CHD=promo::2]-[news::pidgin.news.story.51745682.page]-[]-[]-[]',
- hl: expect.stringMatching(/^.+?x.+?x.+?$/),
- idclient: expect.stringMatching(/^.+?-.+?-.+?-.+?$/),
- lng: 'en-US',
- p: 'news::pidgin.news.story.51745682.page',
- r: '1024x768x24x24',
- re: '1024x768',
- s: '598343',
- s2: '70',
- type: 'AT',
+ expect(reverbMock.userActionEvent).toHaveBeenCalledTimes(1);
+
+ expect(reverbMock.userActionEvent).toHaveBeenCalledWith(
+ 'viewability',
+ '',
+ {
+ event: {
+ category: 'viewability',
+ action: 'select',
+ },
+ group: {
+ name: 'article-sty',
+ type: 'brand',
+ },
+ item: {
+ name: 'brand',
+ },
},
- });
+ undefined,
+ undefined,
+ true,
+ );
});
it('should send tracking request with the URL of the next page on click of a link', async () => {
@@ -296,24 +388,27 @@ describe('useClickTrackerHandler', () => {
await act(() => userEvent.click(getByText('Link')));
- const [[viewEventUrl]] = global.fetch.mock.calls;
-
- expect(urlToObject(viewEventUrl)).toEqual({
- origin: 'https://logws1363.ati-host.net',
- pathname: '/',
- searchParams: {
- atc: 'PUB-[article-sty]-[brand]-[]-[CHD=promo::2]-[news::pidgin.news.story.51745682.page]-[]-[]-[https://www.bbc.com/pidgin/articles/c93gd1yxng1o]',
- hl: expect.stringMatching(/^.+?x.+?x.+?$/),
- idclient: expect.stringMatching(/^.+?-.+?-.+?-.+?$/),
- lng: 'en-US',
- p: 'news::pidgin.news.story.51745682.page',
- r: '1024x768x24x24',
- re: '1024x768',
- s: '598343',
- s2: '70',
- type: 'AT',
+ expect(reverbMock.userActionEvent).toHaveBeenCalledWith(
+ 'viewability',
+ '',
+ {
+ event: {
+ category: 'viewability',
+ action: 'select',
+ },
+ group: {
+ name: 'article-sty',
+ type: 'brand',
+ },
+ item: {
+ link: 'https://www.bbc.com/pidgin/articles/c93gd1yxng1o',
+ name: 'brand',
+ },
},
- });
+ undefined,
+ undefined,
+ true,
+ );
});
it('should only track clicks on the child component if clicks are tracked on both a parent and child', async () => {
@@ -346,39 +441,49 @@ describe('useClickTrackerHandler', () => {
await act(() => userEvent.click(getByText('Button')));
- expect(global.fetch).toHaveBeenCalledTimes(1);
-
- const [[viewEventUrl]] = global.fetch.mock.calls;
-
- expect(urlToObject(viewEventUrl)).toEqual({
- origin: 'https://logws1363.ati-host.net',
- pathname: '/',
- searchParams: {
- atc: 'PUB-[article-sty]-[brand]-[]-[CHD=promo::2]-[news::pidgin.news.story.51745682.page]-[]-[]-[]',
- hl: expect.stringMatching(/^.+?x.+?x.+?$/),
- idclient: expect.stringMatching(/^.+?-.+?-.+?-.+?$/),
- lng: 'en-US',
- p: 'news::pidgin.news.story.51745682.page',
- r: '1024x768x24x24',
- re: '1024x768',
- s: '598343',
- s2: '70',
- type: 'AT',
+ expect(reverbMock.userActionEvent).toHaveBeenCalledTimes(1);
+
+ expect(reverbMock.userActionEvent).toHaveBeenCalledWith(
+ 'viewability',
+ '',
+ {
+ event: {
+ category: 'viewability',
+ action: 'select',
+ },
+ group: {
+ name: 'article-sty',
+ type: 'brand',
+ },
+ item: {
+ name: 'brand',
+ },
},
- });
+ undefined,
+ undefined,
+ true,
+ );
});
it('should allow the user to navigate after clicking on a tracked link even if the tracking request fails', async () => {
+ const err = new Error('An error');
+
+ const errorReverbMock = {
+ ...reverbMock,
+ userActionEvent: jest.fn(() => Promise.reject(err)),
+ };
+
+ // eslint-disable-next-line no-underscore-dangle
+ window.__reverb = {
+ __reverbLoadedPromise: Promise.resolve(errorReverbMock),
+ };
+
const url = 'https://bbc.com/pidgin';
const {
metadata: { atiAnalytics },
} = pidginData;
- global.fetch = jest.fn(() => {
- throw new Error('Failed to fetch');
- });
-
const { getByText } = render(
{
await act(() => userEvent.click(getByText('Link')));
- expect(global.fetch).toHaveBeenCalledTimes(1);
- expect(global.fetch).toThrow('Failed to fetch');
+ expect(errorReverbMock.userActionEvent).toHaveBeenCalledTimes(1);
+ expect(errorReverbMock.userActionEvent).rejects.toThrow(err);
expect(windowLocationAssignSpy).toHaveBeenCalledTimes(1);
expect(windowLocationAssignSpy).toHaveBeenCalledWith(url);
@@ -423,7 +528,7 @@ describe('useClickTrackerHandler', () => {
fireEvent.contextMenu(getByText('Button'));
});
- expect(global.fetch).not.toHaveBeenCalled();
+ expect(reverbMock.userActionEvent).not.toHaveBeenCalledTimes(1);
});
it('should not navigate to the next page if preventNavigation is true', async () => {
@@ -458,7 +563,6 @@ describe('useClickTrackerHandler', () => {
});
it('should be able to override the campaignID that is sent to ATI', async () => {
- const spyFetch = jest.spyOn(global, 'fetch');
const campaignID = 'custom-campaign';
const {
metadata: { atiAnalytics },
@@ -478,10 +582,20 @@ describe('useClickTrackerHandler', () => {
await act(() => userEvent.click(getByTestId('test-component')));
- const [[viewEventUrl]] = spyFetch.mock.calls;
-
- expect(urlToObject(viewEventUrl).searchParams.atc).toEqual(
- 'PUB-[custom-campaign]-[brand]-[]-[CHD=promo::2]-[news::pidgin.news.story.51745682.page]-[]-[]-[]',
+ expect(reverbMock.userActionEvent).toHaveBeenCalledWith(
+ 'viewability',
+ '',
+ {
+ event: { action: 'select', category: 'viewability' },
+ group: {
+ name: 'custom-campaign',
+ type: 'brand',
+ },
+ item: { name: 'brand' },
+ },
+ undefined,
+ undefined,
+ true,
);
});
@@ -585,99 +699,6 @@ describe('useClickTrackerHandler', () => {
});
});
- describe('Click tracking - Reverb', () => {
- beforeEach(() => {
- jest.replaceProperty(
- serviceContextModule,
- 'ServiceContext',
- createContext({
- atiAnalyticsProducerId: '70',
- atiAnalyticsProducerName: 'PIDGIN',
- service: 'pidgin',
- useReverb: true,
- }),
- );
- });
-
- it.each([
- {
- title: 'should trigger a beacon for a click event',
- trackingData: { ...eventTrackingData },
- expectedItemEvent: {
- link: 'https://www.bbc.com/pidgin/articles/c93gd1yxng1o',
- name: 'brand',
- },
- },
- {
- title: 'should trigger a beacon for an item level click event',
- trackingData: {
- ...eventTrackingData,
- componentName: 'portrait-video',
- itemTracker: {
- type: 'portrait-video-promo',
- text: 'Rollercoaster facts... while riding a rollercoaster',
- position: 1,
- duration: 73000,
- resourceId: 'test-resource-id',
- },
- },
- expectedItemEvent: {
- duration: 73000,
- link: 'https://www.bbc.com/pidgin/articles/c93gd1yxng1o',
- name: 'portrait-video',
- position: 1,
- resource_id: 'test-resource-id',
- text: 'Rollercoaster facts... while riding a rollercoaster',
- type: 'portrait-video-promo',
- },
- },
- ])('$title', async ({ trackingData, expectedItemEvent }) => {
- const {
- metadata: { atiAnalytics },
- } = pidginData;
-
- const TestLink = () => {
- const { onClick: handleClick } = useClickTrackerHandler(trackingData);
-
- return (
-
- );
- };
-
- const { getByText } = render(, {
- atiData: atiAnalytics,
- pageData: pidginData,
- pageType: STORY_PAGE,
- pathname: '/pidgin',
- service: 'pidgin',
- toggles: defaultToggles,
- });
-
- await act(() => userEvent.click(getByText('Link')));
-
- expect(reverbMock.userActionEvent).toHaveBeenCalledTimes(1);
- expect(reverbMock.userActionEvent).toHaveBeenCalledWith(
- 'viewability',
- '',
- {
- event: { action: 'select', category: 'viewability' },
- group: { name: 'article-sty', type: trackingData.componentName },
- item: expectedItemEvent,
- },
- undefined,
- undefined,
- true,
- );
- });
- });
-
describe('Error handling', () => {
it('should not throw error and not send event to ATI when no tracking data passed into hook', async () => {
const {
@@ -699,7 +720,7 @@ describe('useClickTrackerHandler', () => {
await act(() => userEvent.click(getByText('Button')));
expect(container.error).toBeUndefined();
- expect(global.fetch).not.toHaveBeenCalled();
+ expect(reverbMock.userActionEvent).not.toHaveBeenCalled();
});
it('should not throw error and not send event to ATI when no pageData is provided from context providers', async () => {
@@ -718,7 +739,7 @@ describe('useClickTrackerHandler', () => {
await act(() => userEvent.click(getByText('Button')));
expect(container.error).toBeUndefined();
- expect(global.fetch).not.toHaveBeenCalled();
+ expect(reverbMock.userActionEvent).not.toHaveBeenCalled();
});
it('should not throw error and not send event to ATI when unexpected data passed into hook', async () => {
@@ -745,7 +766,7 @@ describe('useClickTrackerHandler', () => {
await act(() => userEvent.click(getByText('Button')));
expect(container.error).toBeUndefined();
- expect(global.fetch).not.toHaveBeenCalled();
+ expect(reverbMock.userActionEvent).not.toHaveBeenCalled();
});
it('should not throw error and not send event to ATI when unexpected data type passed into hook', async () => {
@@ -770,7 +791,7 @@ describe('useClickTrackerHandler', () => {
await act(() => userEvent.click(getByText('Button')));
expect(container.error).toBeUndefined();
- expect(global.fetch).not.toHaveBeenCalled();
+ expect(reverbMock.userActionEvent).not.toHaveBeenCalled();
});
});
@@ -778,22 +799,38 @@ describe('useClickTrackerHandler', () => {
it('Returns a valid ati tracking url given the input props', () => {
const { result } = renderHook(
() =>
- constructATIUrl({
+ constructReverbUrl({
eventTrackingData: {
...eventTrackingData,
campaignID: 'custom-campaign',
},
eventType: 'click',
- isStatic: true,
}),
{
wrapper,
},
);
- expect(result.current).toContain(
- 'atc=PUB-[custom-campaign]-[brand]-[]-[CHD=promo::2]-[]-[]-[]-[]&type=AT',
- );
+ const { searchParams } = urlToObject(result.current);
+
+ expect(searchParams).toEqual({
+ idclient: '{idclient}',
+ s: '596068',
+ r: '{screenResolutionColourDepth}',
+ re: '{browserViewportResolution}',
+ hl: '{timestamp}',
+ ts: '{epochTimestamp}',
+ lng: '{language}',
+ x6: '[{referrer}]',
+ app_type: 'lite',
+ ref: '{referrer}',
+ app_name: 'undefined',
+ language: 'undefined',
+ content_type: 'STY',
+ events:
+ '[{"name":"viewability.select","data":{"item":{"name":"brand","link":"{forwardingLink}"},"event":{"category":"viewability","action":"select"},"group":{"name":"custom-campaign","type":"brand"},"user":{"id":null},"app":{"type":"lite"}}}]',
+ context: '[{"data":{"page":{},"site":{"level2_id":""}}}]',
+ });
});
});
});
diff --git a/src/app/hooks/useClickTrackerHandler/index.jsx b/src/app/hooks/useClickTrackerHandler/index.jsx
index b75803238c2..eb87c449b8a 100644
--- a/src/app/hooks/useClickTrackerHandler/index.jsx
+++ b/src/app/hooks/useClickTrackerHandler/index.jsx
@@ -38,7 +38,7 @@ const useClickTrackerHandler = (eventTrackingData = {}) => {
const { trackingIsEnabled } = useTrackingToggle(componentName);
const [clickedIdentifier, setClickedIdentifier] = useState(null);
- const { service, useReverb } = use(ServiceContext);
+ const { service } = use(ServiceContext);
const { optimizely } = use(OptimizelyContext);
return useCallback(
@@ -100,7 +100,6 @@ const useClickTrackerHandler = (eventTrackingData = {}) => {
statsDestination,
url: url || nextPageUrl,
detailedPlacement,
- useReverb,
...(groupTracker && { groupTracker }),
...(itemTracker && { itemTracker }),
...(experimentVariant &&
@@ -138,7 +137,6 @@ const useClickTrackerHandler = (eventTrackingData = {}) => {
advertiserID,
url,
detailedPlacement,
- useReverb,
groupTracker,
itemTracker,
experimentName,
diff --git a/src/app/hooks/useCustomEventTracker/index.test.tsx b/src/app/hooks/useCustomEventTracker/index.test.tsx
index 4fa0ddaed80..5c0502a00dc 100644
--- a/src/app/hooks/useCustomEventTracker/index.test.tsx
+++ b/src/app/hooks/useCustomEventTracker/index.test.tsx
@@ -60,7 +60,6 @@ beforeEach(() => {
atiAnalyticsProducerId: '70',
atiAnalyticsProducerName: 'PIDGIN',
service: 'pidgin',
- useReverb: true,
}),
);
});
@@ -114,7 +113,6 @@ describe('useCustomEventTracker', () => {
producerName: 'PIDGIN',
service: 'pidgin',
statsDestination: 'WS_NEWS_LANGUAGES_TEST',
- useReverb: true,
});
});
diff --git a/src/app/hooks/useCustomEventTracker/index.tsx b/src/app/hooks/useCustomEventTracker/index.tsx
index aef267599ad..61ce812b392 100644
--- a/src/app/hooks/useCustomEventTracker/index.tsx
+++ b/src/app/hooks/useCustomEventTracker/index.tsx
@@ -39,7 +39,7 @@ const useCustomEventTracker = ({
});
const { trackingIsEnabled } = useTrackingToggle();
- const { service, useReverb } = use(ServiceContext);
+ const { service } = use(ServiceContext);
const trackEvent = useCallback(
async (stringifiedData = '') => {
@@ -69,7 +69,6 @@ const useCustomEventTracker = ({
producerName,
service,
statsDestination,
- useReverb,
experimentName,
experimentVariant,
});
@@ -89,7 +88,6 @@ const useCustomEventTracker = ({
producerName,
service,
statsDestination,
- useReverb,
experimentName,
experimentVariant,
],
diff --git a/src/app/hooks/useSwipeTracker/index.tsx b/src/app/hooks/useSwipeTracker/index.tsx
index c23c3f1bd43..66dd2ca958a 100644
--- a/src/app/hooks/useSwipeTracker/index.tsx
+++ b/src/app/hooks/useSwipeTracker/index.tsx
@@ -11,7 +11,7 @@ import { EventTrackingContext } from '../../contexts/EventTrackingContext';
import dispatchTrackingRequests from '../../lib/analyticsUtils/dispatchTrackingRequests';
const getComponentSwipeTracker = (eventTrackingData?: EventTrackingData) => {
- const { service, useReverb } = use(ServiceContext);
+ const { service } = use(ServiceContext);
const eventTrackingContext = use(EventTrackingContext);
@@ -57,7 +57,6 @@ const getComponentSwipeTracker = (eventTrackingData?: EventTrackingData) => {
advertiserID,
url,
detailedPlacement,
- useReverb,
...(groupTracker && { groupTracker }),
...(itemTracker && { itemTracker }),
},
@@ -69,7 +68,7 @@ const getComponentSwipeTracker = (eventTrackingData?: EventTrackingData) => {
await dispatchTrackingRequests(swipeTrackingParameters);
},
- [eventTrackingContext, service, trackingIsEnabled, useReverb],
+ [eventTrackingContext, service, trackingIsEnabled],
);
return swipeTracker;
diff --git a/src/app/hooks/useViewTracker/index.test.tsx b/src/app/hooks/useViewTracker/index.test.tsx
index 1a94259fa5e..7977b07210f 100644
--- a/src/app/hooks/useViewTracker/index.test.tsx
+++ b/src/app/hooks/useViewTracker/index.test.tsx
@@ -92,7 +92,6 @@ beforeEach(() => {
atiAnalyticsProducerId: '70',
atiAnalyticsProducerName: 'PIDGIN',
service: 'pidgin',
- useReverb: false,
}),
);
});
@@ -104,16 +103,6 @@ afterEach(() => {
observers.clear();
});
-const urlToObject = (url: string) => {
- const { origin, pathname, searchParams } = new URL(url);
-
- return {
- origin,
- pathname,
- searchParams: Object.fromEntries(searchParams),
- };
-};
-
const defaultToggles = {
eventTracking: {
enabled: true,
@@ -175,145 +164,182 @@ describe('useViewTracker', () => {
url: 'http://www.bbc.com/pidgin/tori-51745682',
};
- it('should return a function that can be assigned to an element to observe for intersections', async () => {
- const { result } = renderHook(() => useViewTracker(trackingData), {
- wrapper,
- });
- const element = document.createElement('div');
+ describe('Optimizely', () => {
+ it('should send event to Optimizely when element is 50% or more in view for more than 1 second and optimizely object exists', async () => {
+ const { result } = renderHook(
+ () =>
+ useViewTracker({
+ ...trackingData,
+ sendOptimizelyEvents: true,
+ experimentName: 'dummy_experiment',
+ experimentVariant: 'variation_a',
+ }),
+ {
+ wrapper: props => wrapper({ ...props, atiData: atiAnalytics }),
+ },
+ );
+ const element = document.createElement('div');
- await result.current.ref(element);
+ await result.current.ref(element);
- const { observe } = getObserverInstance(element);
+ const observerInstance = getObserverInstance(element);
- expect(observe).toHaveBeenCalledWith(element);
- });
+ act(() => {
+ triggerIntersection({
+ changes: [{ isIntersecting: true }],
+ observer: observerInstance,
+ });
+ });
- it('should not send event to ATI when element is not in view', async () => {
- const { result } = renderHook(() => useViewTracker(trackingData), {
- wrapper,
+ act(() => {
+ jest.advanceTimersByTime(1100);
+ });
+
+ const [[, options]] = (global.IntersectionObserver as jest.Mock).mock
+ .calls;
+
+ expect(global.IntersectionObserver).toHaveBeenCalledTimes(1);
+ expect(options).toEqual({ threshold: [0.5] });
+ expect(defaultOptimizely.track).toHaveBeenCalledTimes(1);
+ expect(defaultOptimizely.track).toHaveBeenCalledWith(
+ 'most-read-views',
+ defaultOptimizely.user.id,
+ defaultOptimizely.user.attributes,
+ );
});
- const element = document.createElement('div');
- await result.current.ref(element);
+ it('should not send event to Optimizely when element is 50% or more in view for more than 1 second and optimizely object is undefined', async () => {
+ const mockOptimizelyTrack = jest.fn();
+ const mockOptimizely = undefined;
+
+ const { result } = renderHook(
+ () =>
+ useViewTracker({
+ ...trackingData,
+ // @ts-expect-error partial data for tests
+ ...mockOptimizely,
+ }),
+ {
+ wrapper,
+ initialProps: {},
+ },
+ );
+ const element = document.createElement('div');
- const observerInstance = getObserverInstance(element);
+ await result.current.ref(element);
- act(() => {
- triggerIntersection({
- changes: [{ isIntersecting: false }],
- observer: observerInstance,
+ const observerInstance = getObserverInstance(element);
+
+ act(() => {
+ triggerIntersection({
+ changes: [{ isIntersecting: true }],
+ observer: observerInstance,
+ });
});
- });
- act(() => {
- jest.advanceTimersByTime(1100);
- });
+ act(() => {
+ jest.advanceTimersByTime(1100);
+ });
- expect(global.fetch).not.toHaveBeenCalled();
- });
+ const [[, options]] = (global.IntersectionObserver as jest.Mock).mock
+ .calls;
- it('should skip initialising IntersectionObserver when eventTracking toggle is disabled', async () => {
- const { result } = renderHook(() => useViewTracker(trackingData), {
- wrapper: props =>
- wrapper({
- ...props,
- toggles: { eventTracking: { enabled: false } },
- }),
+ expect(global.IntersectionObserver).toHaveBeenCalledTimes(1);
+ expect(options).toEqual({ threshold: [0.5] });
+ expect(mockOptimizelyTrack).toHaveBeenCalledTimes(0);
});
- const element = document.createElement('div');
-
- await result.current.ref(element);
+ });
- try {
- getObserverInstance(element);
+ describe('View tracking - Reverb', () => {
+ it('should return a function that can be assigned to an element to observe for intersections', async () => {
+ const { result } = renderHook(() => useViewTracker(trackingData), {
+ wrapper,
+ });
+ const element = document.createElement('div');
- throw new Error('IntersectionObserver was initialised.');
- } catch (err) {
- const { message } = err as Error;
- expect(message).toEqual(
- 'Failed to find IntersectionObserver for element.',
- );
- }
+ await result.current.ref(element);
- expect(global.IntersectionObserver).not.toHaveBeenCalled();
- expect(global.fetch).not.toHaveBeenCalled();
- });
+ const { observe } = getObserverInstance(element);
- it('should skip initialising IntersectionObserver when ref is not assigned to element', async () => {
- renderHook(() => useViewTracker(trackingData), {
- wrapper,
- initialProps: {
- toggles: {
- eventTracking: {
- enabled: true,
- },
- },
- },
+ expect(observe).toHaveBeenCalledWith(element);
});
- expect(global.IntersectionObserver).not.toHaveBeenCalled();
- expect(global.fetch).not.toHaveBeenCalled();
- });
+ it('should not send event to ATI when element is not in view', async () => {
+ const { result } = renderHook(() => useViewTracker(trackingData), {
+ wrapper,
+ });
+ const element = document.createElement('div');
- it('should use componentName property if provided in eventTrackingData object', async () => {
- const { result } = renderHook(
- () =>
- useViewTracker({
- ...trackingData,
- experimentName: 'dummy_experiment',
- experimentVariant: 'variation_a',
- sendOptimizelyEvents: true,
- }),
- {
- wrapper: props => wrapper({ ...props, atiData: atiAnalytics }),
- },
- );
- const element = document.createElement('div');
+ await result.current.ref(element);
- await result.current.ref(element);
+ const observerInstance = getObserverInstance(element);
- const observerInstance = getObserverInstance(element);
+ act(() => {
+ triggerIntersection({
+ changes: [{ isIntersecting: false }],
+ observer: observerInstance,
+ });
+ });
- act(() => {
- triggerIntersection({
- changes: [{ isIntersecting: true }],
- observer: observerInstance,
+ act(() => {
+ jest.advanceTimersByTime(1100);
});
+
+ expect(reverbMock.userActionEvent).not.toHaveBeenCalled();
});
- act(() => {
- jest.advanceTimersByTime(1100);
+ it('should skip initialising IntersectionObserver when eventTracking toggle is disabled', async () => {
+ const { result } = renderHook(() => useViewTracker(trackingData), {
+ wrapper: props =>
+ wrapper({
+ ...props,
+ toggles: { eventTracking: { enabled: false } },
+ }),
+ });
+ const element = document.createElement('div');
+
+ await result.current.ref(element);
+
+ try {
+ getObserverInstance(element);
+
+ throw new Error('IntersectionObserver was initialised.');
+ } catch (err) {
+ const { message } = err as Error;
+ expect(message).toEqual(
+ 'Failed to find IntersectionObserver for element.',
+ );
+ }
+
+ expect(global.IntersectionObserver).not.toHaveBeenCalled();
+ expect(reverbMock.userActionEvent).not.toHaveBeenCalled();
});
- const [[, options]] = (global.IntersectionObserver as jest.Mock).mock
- .calls;
+ it('should skip initialising IntersectionObserver when ref is not assigned to element', async () => {
+ renderHook(() => useViewTracker(trackingData), {
+ wrapper,
+ initialProps: {
+ toggles: {
+ eventTracking: {
+ enabled: true,
+ },
+ },
+ },
+ });
- expect(global.IntersectionObserver).toHaveBeenCalledTimes(1);
- expect(options).toEqual({ threshold: [0.5] });
- expect(defaultOptimizely.track).toHaveBeenCalledTimes(1);
- expect(defaultOptimizely.track).toHaveBeenCalledWith(
- 'most-read-views',
- defaultOptimizely.user.id,
- { foo: 'bar' },
- );
- });
+ expect(global.IntersectionObserver).not.toHaveBeenCalled();
+ expect(reverbMock.userActionEvent).not.toHaveBeenCalled();
+ });
- it.each([
- {
- title: 'For no user defined threshold',
- threshold: undefined,
- expected: 0.5,
- },
- {
- title: 'For a user defined threshold of 0.8',
- threshold: 0.8,
- expected: 0.8,
- },
- ])(
- 'should send event to ATI and return correct tracking url when element is $expected or more in view for more than 1 second - $title',
- async ({ threshold, expected }) => {
+ it('should use componentName property if provided in eventTrackingData object', async () => {
const { result } = renderHook(
- () => useViewTracker({ ...trackingData, viewThreshold: threshold }),
+ () =>
+ useViewTracker({
+ ...trackingData,
+ experimentName: 'dummy_experiment',
+ experimentVariant: 'variation_a',
+ sendOptimizelyEvents: true,
+ }),
{
wrapper: props => wrapper({ ...props, atiData: atiAnalytics }),
},
@@ -337,310 +363,275 @@ describe('useViewTracker', () => {
const [[, options]] = (global.IntersectionObserver as jest.Mock).mock
.calls;
- const [[viewEventUrl]] = (global.fetch as jest.Mock).mock.calls;
expect(global.IntersectionObserver).toHaveBeenCalledTimes(1);
- expect(options).toEqual({ threshold: [expected] });
- expect(global.fetch).toHaveBeenCalledTimes(1);
- expect(urlToObject(viewEventUrl)).toEqual({
- origin: 'https://logws1363.ati-host.net',
- pathname: '/',
- searchParams: {
- ati: 'PUB-[article-sty]-[most-read]-[]-[CHD=promo::2]-[news::pidgin.news.story.51745682.page]-[]-[]-[http://www.bbc.com/pidgin/tori-51745682]',
- hl: expect.stringMatching(/^.+?x.+?x.+?$/), // timestamp based value
- idclient: expect.stringMatching(/^.+?-.+?-.+?-.+?$/),
- lng: 'en-US',
- p: 'news::pidgin.news.story.51745682.page',
- r: '0x0x24x24',
- re: '1024x768',
- s: '598343',
- s2: '70',
- type: 'AT',
- },
- });
- },
- );
-
- it('should only send one view event when mutiple elements are viewed', async () => {
- const { result } = renderHook(() => useViewTracker(trackingData), {
- wrapper: props => wrapper({ ...props, atiData: atiAnalytics }),
- });
- const elementA = document.createElement('div');
- const elementB = document.createElement('div');
-
- await result.current.ref(elementA);
- await result.current.ref(elementB);
-
- const observerInstanceA = getObserverInstance(elementA);
- const observerInstanceB = getObserverInstance(elementB);
-
- act(() => {
- triggerIntersection({
- changes: [{ isIntersecting: true }],
- observer: observerInstanceA,
- });
- triggerIntersection({
- changes: [{ isIntersecting: true }],
- observer: observerInstanceB,
- });
- });
-
- act(() => {
- jest.advanceTimersByTime(1100);
- });
-
- expect(global.fetch).toHaveBeenCalledTimes(1);
- });
-
- it('should send one view event for multiple observed elements when at least one of them is in view', async () => {
- const { result } = renderHook(() => useViewTracker(trackingData), {
- wrapper: props => wrapper({ ...props, atiData: atiAnalytics }),
+ expect(options).toEqual({ threshold: [0.5] });
+ expect(defaultOptimizely.track).toHaveBeenCalledTimes(1);
+ expect(defaultOptimizely.track).toHaveBeenCalledWith(
+ 'most-read-views',
+ defaultOptimizely.user.id,
+ { foo: 'bar' },
+ );
});
- const element = document.createElement('div');
- await result.current.ref(element);
+ it.each([
+ {
+ title: 'For no user defined threshold',
+ threshold: undefined,
+ expected: 0.5,
+ },
+ {
+ title: 'For a user defined threshold of 0.8',
+ threshold: 0.8,
+ expected: 0.8,
+ },
+ ])(
+ 'should send event to ATI and return correct tracking url when element is $expected or more in view for more than 1 second - $title',
+ async ({ threshold, expected }) => {
+ const { result } = renderHook(
+ () =>
+ useViewTracker({
+ ...trackingData,
+ viewThreshold: threshold,
+ }),
+ {
+ wrapper: props => wrapper({ ...props, atiData: atiAnalytics }),
+ },
+ );
+ const element = document.createElement('div');
- const observerInstance = getObserverInstance(element);
+ await result.current.ref(element);
- act(() => {
- triggerIntersection({
- changes: [{ isIntersecting: true }, { isIntersecting: false }],
- observer: observerInstance,
- });
- });
+ const observerInstance = getObserverInstance(element);
- act(() => {
- jest.advanceTimersByTime(1100);
- });
+ act(() => {
+ triggerIntersection({
+ changes: [{ isIntersecting: true }],
+ observer: observerInstance,
+ });
+ });
- expect(global.fetch).toHaveBeenCalledTimes(1);
- });
+ await act(() => {
+ jest.advanceTimersByTime(1100);
+ });
- it('should send multiple view events for multiple hook instances', async () => {
- const { result: resultA } = renderHook(
- () => useViewTracker(trackingData),
- {
- wrapper: props => wrapper({ ...props, atiData: atiAnalytics }),
+ const [[, options]] = (global.IntersectionObserver as jest.Mock).mock
+ .calls;
+
+ expect(global.IntersectionObserver).toHaveBeenCalledTimes(1);
+ expect(options).toEqual({ threshold: [expected] });
+ expect(reverbMock.userActionEvent).toHaveBeenCalledTimes(1);
+ expect(reverbMock.userActionEvent).toHaveBeenCalledWith(
+ 'viewability',
+ '',
+ {
+ event: { action: 'view', category: 'viewability' },
+ group: {
+ name: 'article-sty',
+ type: 'most-read',
+ },
+ item: {
+ link: 'http://www.bbc.com/pidgin/tori-51745682',
+ name: 'most-read',
+ },
+ },
+ undefined,
+ undefined,
+ false,
+ );
},
);
- const { result: resultB } = renderHook(
- () => useViewTracker(trackingData),
- {
+
+ it('should only send one view event when mutiple elements are viewed', async () => {
+ const { result } = renderHook(() => useViewTracker(trackingData), {
wrapper: props => wrapper({ ...props, atiData: atiAnalytics }),
- },
- );
- const elementA = document.createElement('div');
- const elementB = document.createElement('div');
+ });
+ const elementA = document.createElement('div');
+ const elementB = document.createElement('div');
- await resultA.current.ref(elementA);
- await resultB.current.ref(elementB);
+ await result.current.ref(elementA);
+ await result.current.ref(elementB);
- const observerInstanceA = getObserverInstance(elementA);
- const observerInstanceB = getObserverInstance(elementB);
+ const observerInstanceA = getObserverInstance(elementA);
+ const observerInstanceB = getObserverInstance(elementB);
- act(() => {
- triggerIntersection({
- changes: [{ isIntersecting: true }],
- observer: observerInstanceA,
+ act(() => {
+ triggerIntersection({
+ changes: [{ isIntersecting: true }],
+ observer: observerInstanceA,
+ });
+ triggerIntersection({
+ changes: [{ isIntersecting: true }],
+ observer: observerInstanceB,
+ });
});
- triggerIntersection({
- changes: [{ isIntersecting: true }],
- observer: observerInstanceB,
+
+ await act(() => {
+ jest.advanceTimersByTime(1100);
});
- });
- act(() => {
- jest.advanceTimersByTime(1100);
+ expect(reverbMock.userActionEvent).toHaveBeenCalledTimes(1);
});
- expect(global.fetch).toHaveBeenCalledTimes(2);
- });
-
- it('should disconnect IntersectionObserver after event is sent', async () => {
- const { result } = renderHook(() => useViewTracker(trackingData), {
- wrapper: props => wrapper({ ...props, atiData: atiAnalytics }),
- });
+ it('should send one view event for multiple observed elements when at least one of them is in view', async () => {
+ const { result } = renderHook(() => useViewTracker(trackingData), {
+ wrapper: props => wrapper({ ...props, atiData: atiAnalytics }),
+ });
+ const element = document.createElement('div');
- const element = document.createElement('div');
+ await result.current.ref(element);
- await result.current.ref(element);
+ const observerInstance = getObserverInstance(element);
- const observerInstance = getObserverInstance(element);
- const { disconnect } = observerInstance;
+ act(() => {
+ triggerIntersection({
+ changes: [{ isIntersecting: true }, { isIntersecting: false }],
+ observer: observerInstance,
+ });
+ });
- act(() => {
- triggerIntersection({
- changes: [{ isIntersecting: true }],
- observer: observerInstance,
+ await act(() => {
+ jest.advanceTimersByTime(1100);
});
- });
- act(() => {
- jest.advanceTimersByTime(1100);
+ expect(reverbMock.userActionEvent).toHaveBeenCalledTimes(1);
});
- expect(disconnect).toHaveBeenCalledTimes(1);
- });
+ it('should send multiple view events for multiple hook instances', async () => {
+ const { result: resultA } = renderHook(
+ () => useViewTracker(trackingData),
+ {
+ wrapper: props => wrapper({ ...props, atiData: atiAnalytics }),
+ },
+ );
+ const { result: resultB } = renderHook(
+ () => useViewTracker(trackingData),
+ {
+ wrapper: props => wrapper({ ...props, atiData: atiAnalytics }),
+ },
+ );
+ const elementA = document.createElement('div');
+ const elementB = document.createElement('div');
- it('should not disconnect IntersectionObserver before event is sent', async () => {
- const { result } = renderHook(() => useViewTracker(trackingData), {
- wrapper,
- initialProps: {},
- });
- const element = document.createElement('div');
+ await resultA.current.ref(elementA);
+ await resultB.current.ref(elementB);
- await result.current.ref(element);
+ const observerInstanceA = getObserverInstance(elementA);
+ const observerInstanceB = getObserverInstance(elementB);
- const observerInstance = getObserverInstance(element);
- const { disconnect } = observerInstance;
+ act(() => {
+ triggerIntersection({
+ changes: [{ isIntersecting: true }],
+ observer: observerInstanceA,
+ });
+ triggerIntersection({
+ changes: [{ isIntersecting: true }],
+ observer: observerInstanceB,
+ });
+ });
- act(() => {
- triggerIntersection({
- changes: [{ isIntersecting: true }],
- observer: observerInstance,
+ await act(() => {
+ jest.advanceTimersByTime(1100);
});
- });
- act(() => {
- jest.advanceTimersByTime(900);
+ expect(reverbMock.userActionEvent).toHaveBeenCalledTimes(2);
});
- expect(disconnect).toHaveBeenCalledTimes(0);
- });
-
- it('should not send event to ATI when element is in view for less than 1 second', async () => {
- const { result } = renderHook(() => useViewTracker(trackingData), {
- wrapper,
- initialProps: {},
- });
+ it('should disconnect IntersectionObserver after event is sent', async () => {
+ const { result } = renderHook(() => useViewTracker(trackingData), {
+ wrapper: props => wrapper({ ...props, atiData: atiAnalytics }),
+ });
- const element = document.createElement('div');
+ const element = document.createElement('div');
- await result.current.ref(element);
+ await result.current.ref(element);
- const observerInstance = getObserverInstance(element);
+ const observerInstance = getObserverInstance(element);
+ const { disconnect } = observerInstance;
- act(() => {
- // scroll element into view
- triggerIntersection({
- changes: [{ isIntersecting: true }],
- observer: observerInstance,
+ act(() => {
+ triggerIntersection({
+ changes: [{ isIntersecting: true }],
+ observer: observerInstance,
+ });
});
- });
- act(() => {
- jest.advanceTimersByTime(900);
- });
-
- act(() => {
- // scroll element out of view
- triggerIntersection({
- changes: [{ isIntersecting: false }],
- observer: observerInstance,
+ act(() => {
+ jest.advanceTimersByTime(1100);
});
- });
- act(() => {
- jest.advanceTimersByTime(1100);
+ expect(disconnect).toHaveBeenCalledTimes(1);
});
- expect(global.fetch).not.toHaveBeenCalled();
- });
-
- it('should not send event to ATI more than once when element is scrolled in and out of view', async () => {
- const { result } = renderHook(() => useViewTracker(trackingData), {
- wrapper: props => wrapper({ ...props, atiData: atiAnalytics }),
- });
- const element = document.createElement('div');
+ it('should not disconnect IntersectionObserver before event is sent', async () => {
+ const { result } = renderHook(() => useViewTracker(trackingData), {
+ wrapper,
+ initialProps: {},
+ });
+ const element = document.createElement('div');
- await result.current.ref(element);
+ await result.current.ref(element);
- const observerInstance = getObserverInstance(element);
+ const observerInstance = getObserverInstance(element);
+ const { disconnect } = observerInstance;
- act(() => {
- // scroll element into view
- triggerIntersection({
- changes: [{ isIntersecting: true }],
- observer: observerInstance,
+ act(() => {
+ triggerIntersection({
+ changes: [{ isIntersecting: true }],
+ observer: observerInstance,
+ });
});
- });
- act(() => {
- jest.advanceTimersByTime(1100);
- });
-
- act(() => {
- // scroll element out of view
- triggerIntersection({
- changes: [{ isIntersecting: false }],
- observer: observerInstance,
+ act(() => {
+ jest.advanceTimersByTime(900);
});
+
+ expect(disconnect).toHaveBeenCalledTimes(0);
});
- act(() => {
- // scroll element into view again
- triggerIntersection({
- changes: [{ isIntersecting: true }],
- observer: observerInstance,
+ it('should not send event to ATI when element is in view for less than 1 second', async () => {
+ const { result } = renderHook(() => useViewTracker(trackingData), {
+ wrapper,
+ initialProps: {},
});
- });
- act(() => {
- jest.advanceTimersByTime(1100);
- });
+ const element = document.createElement('div');
- const [[viewEventUrl]] = (global.fetch as jest.Mock).mock.calls;
+ await result.current.ref(element);
- expect(viewEventUrl).toMatch('https://logws1363.ati-host.net');
- expect(global.fetch).toHaveBeenCalledTimes(1);
- });
+ const observerInstance = getObserverInstance(element);
- it('should be able to override the campaignID that is sent to ATI', async () => {
- const { result } = renderHook(
- () =>
- useViewTracker({ ...trackingData, campaignID: 'custom-campaign' }),
- {
- wrapper: props => wrapper({ ...props, atiData: atiAnalytics }),
- },
- );
- const element = document.createElement('div');
+ act(() => {
+ // scroll element into view
+ triggerIntersection({
+ changes: [{ isIntersecting: true }],
+ observer: observerInstance,
+ });
+ });
- await result.current.ref(element);
+ act(() => {
+ jest.advanceTimersByTime(900);
+ });
- const observerInstance = getObserverInstance(element);
+ act(() => {
+ // scroll element out of view
+ triggerIntersection({
+ changes: [{ isIntersecting: false }],
+ observer: observerInstance,
+ });
+ });
- act(() => {
- triggerIntersection({
- changes: [{ isIntersecting: true }],
- observer: observerInstance,
+ act(() => {
+ jest.advanceTimersByTime(1100);
});
- });
- act(() => {
- jest.advanceTimersByTime(1100);
+ expect(reverbMock.userActionEvent).not.toHaveBeenCalled();
});
- const [[viewEventUrl]] = (global.fetch as jest.Mock).mock.calls;
-
- expect(urlToObject(viewEventUrl).searchParams.ati).toEqual(
- 'PUB-[custom-campaign]-[most-read]-[]-[CHD=promo::2]-[news::pidgin.news.story.51745682.page]-[]-[]-[http://www.bbc.com/pidgin/tori-51745682]',
- );
- });
-
- describe('Optimizely', () => {
- it('should send event to Optimizely when element is 50% or more in view for more than 1 second and optimizely object exists', async () => {
- const { result } = renderHook(
- () =>
- useViewTracker({
- ...trackingData,
- sendOptimizelyEvents: true,
- experimentName: 'dummy_experiment',
- experimentVariant: 'variation_a',
- }),
- {
- wrapper: props => wrapper({ ...props, atiData: atiAnalytics }),
- },
- );
+ it('should not send event to ATI more than once when element is scrolled in and out of view', async () => {
+ const { result } = renderHook(() => useViewTracker(trackingData), {
+ wrapper: props => wrapper({ ...props, atiData: atiAnalytics }),
+ });
const element = document.createElement('div');
await result.current.ref(element);
@@ -648,6 +639,7 @@ describe('useViewTracker', () => {
const observerInstance = getObserverInstance(element);
act(() => {
+ // scroll element into view
triggerIntersection({
changes: [{ isIntersecting: true }],
observer: observerInstance,
@@ -658,33 +650,53 @@ describe('useViewTracker', () => {
jest.advanceTimersByTime(1100);
});
- const [[, options]] = (global.IntersectionObserver as jest.Mock).mock
- .calls;
+ act(() => {
+ // scroll element out of view
+ triggerIntersection({
+ changes: [{ isIntersecting: false }],
+ observer: observerInstance,
+ });
+ });
- expect(global.IntersectionObserver).toHaveBeenCalledTimes(1);
- expect(options).toEqual({ threshold: [0.5] });
- expect(defaultOptimizely.track).toHaveBeenCalledTimes(1);
- expect(defaultOptimizely.track).toHaveBeenCalledWith(
- 'most-read-views',
- defaultOptimizely.user.id,
- defaultOptimizely.user.attributes,
+ act(() => {
+ // scroll element into view again
+ triggerIntersection({
+ changes: [{ isIntersecting: true }],
+ observer: observerInstance,
+ });
+ });
+
+ await act(() => {
+ jest.advanceTimersByTime(1100);
+ });
+
+ expect(reverbMock.userActionEvent).toHaveBeenCalledTimes(1);
+ expect(reverbMock.userActionEvent).toHaveBeenCalledWith(
+ 'viewability',
+ '',
+ {
+ event: { action: 'view', category: 'viewability' },
+ group: {
+ name: 'article-sty',
+ type: 'most-read',
+ },
+ item: {
+ link: 'http://www.bbc.com/pidgin/tori-51745682',
+ name: 'most-read',
+ },
+ },
+ undefined,
+ undefined,
+ false,
);
});
- it('should not send event to Optimizely when element is 50% or more in view for more than 1 second and optimizely object is undefined', async () => {
- const mockOptimizelyTrack = jest.fn();
- const mockOptimizely = undefined;
-
+ it('should be able to override the campaignID that is sent to ATI', async () => {
const { result } = renderHook(
() =>
- useViewTracker({
- ...trackingData,
- // @ts-expect-error partial data for tests
- ...mockOptimizely,
- }),
+ useViewTracker({ ...trackingData, campaignID: 'custom-campaign' }),
{
- wrapper,
- initialProps: {},
+ wrapper: props => wrapper({ ...props, atiData: atiAnalytics }),
},
);
const element = document.createElement('div');
@@ -700,31 +712,28 @@ describe('useViewTracker', () => {
});
});
- act(() => {
+ await act(() => {
jest.advanceTimersByTime(1100);
});
- const [[, options]] = (global.IntersectionObserver as jest.Mock).mock
- .calls;
-
- expect(global.IntersectionObserver).toHaveBeenCalledTimes(1);
- expect(options).toEqual({ threshold: [0.5] });
- expect(mockOptimizelyTrack).toHaveBeenCalledTimes(0);
- });
- });
-
- describe('View tracking - Reverb', () => {
- beforeEach(() => {
- jest.replaceProperty(
- serviceContextModule,
- 'ServiceContext',
- // @ts-expect-error override service context for tests
- createContext({
- atiAnalyticsProducerId: '70',
- atiAnalyticsProducerName: 'PIDGIN',
- service: 'pidgin',
- useReverb: true,
- }),
+ expect(reverbMock.userActionEvent).toHaveBeenCalledTimes(1);
+ expect(reverbMock.userActionEvent).toHaveBeenCalledWith(
+ 'viewability',
+ '',
+ {
+ event: { action: 'view', category: 'viewability' },
+ group: {
+ name: 'custom-campaign',
+ type: 'most-read',
+ },
+ item: {
+ link: 'http://www.bbc.com/pidgin/tori-51745682',
+ name: 'most-read',
+ },
+ },
+ undefined,
+ undefined,
+ false,
);
});
diff --git a/src/app/hooks/useViewTracker/index.tsx b/src/app/hooks/useViewTracker/index.tsx
index 6d0e7559048..87c673d8a31 100644
--- a/src/app/hooks/useViewTracker/index.tsx
+++ b/src/app/hooks/useViewTracker/index.tsx
@@ -52,7 +52,7 @@ const getComponentViewTracker = (eventTrackingData?: EventTrackingData) => {
const [eventSent, setEventSent] = useState(false);
const { trackingIsEnabled } = useTrackingToggle(componentName);
- const { service, useReverb } = use(ServiceContext);
+ const { service } = use(ServiceContext);
useEffect(() => {
if (componentHasComeIntoView && !timer.current) {
@@ -79,7 +79,6 @@ const getComponentViewTracker = (eventTrackingData?: EventTrackingData) => {
advertiserID,
url,
detailedPlacement,
- useReverb,
...(groupTracker && { groupTracker }),
...(itemTracker && { itemTracker }),
...(experimentVariant &&
@@ -134,7 +133,6 @@ const getComponentViewTracker = (eventTrackingData?: EventTrackingData) => {
experimentName,
experimentVariant,
detailedPlacement,
- useReverb,
itemTracker,
groupTracker,
alwaysInView,
diff --git a/src/app/legacy/components/RadioSchedule/ProgramCard/index.test.jsx b/src/app/legacy/components/RadioSchedule/ProgramCard/index.test.jsx
index f05cd3a88e2..209c1cea323 100644
--- a/src/app/legacy/components/RadioSchedule/ProgramCard/index.test.jsx
+++ b/src/app/legacy/components/RadioSchedule/ProgramCard/index.test.jsx
@@ -5,8 +5,6 @@ import { renderProgramCard, uniqueStates } from '../testHelpers/helper';
jest.mock('#lib/analyticsUtils', () => {
return {
...jest.requireActual('#lib/analyticsUtils'),
- getAtUserId: jest.fn(),
- getCurrentTime: jest.fn().mockReturnValue('00-00-00'),
};
});
diff --git a/src/app/legacy/containers/PageHandlers/__snapshots__/withContexts.test.jsx.snap b/src/app/legacy/containers/PageHandlers/__snapshots__/withContexts.test.jsx.snap
index 024ece5e159..c8bb49b19af 100644
--- a/src/app/legacy/containers/PageHandlers/__snapshots__/withContexts.test.jsx.snap
+++ b/src/app/legacy/containers/PageHandlers/__snapshots__/withContexts.test.jsx.snap
@@ -3,7 +3,7 @@
exports[`withContexts HOC should return all context providers 1`] = `
- {"lang":"en-GB","articleAuthor":"https://www.facebook.com/bbcnews","articleTimestampPrefix":"Updated","articleTimestampSuffix":"","atiAnalyticsAppName":"news","atiAnalyticsProducerId":"64","atiAnalyticsProducerName":"NEWS","useReverb":true,"chartbeatDomain":"bbc.co.uk","brandName":"BBC News","product":"BBC News","defaultImage":"https://static.files.bbci.co.uk/ws/simorgh-assets/public/news/images/metadata/poster-1024x576.png","defaultImageAltText":"BBC News","dir":"ltr","externalLinkText":", external","imageCaptionOffscreenText":"Image caption, ","videoCaptionOffscreenText":"Video caption, ","audioCaptionOffscreenText":"Audio caption","defaultCaptionOffscreenText":"Caption, ","imageCopyrightOffscreenText":"Image source, ","locale":"en_GB","datetimeLocale":"en-gb","service":"news","serviceName":"News","languageName":"English","twitterCreator":"@BBCNews","twitterSite":"@BBCNews","noBylinesPolicy":"https://www.bbc.com/news/help-41670342#authorexpertise","publishingPrinciples":"https://www.bbc.com/news/help-41670342","isTrustProjectParticipant":true,"script":{"atlas":{"groupA":{"fontSize":78,"lineHeight":84},"groupB":{"fontSize":96,"lineHeight":104},"groupD":{"fontSize":140,"lineHeight":148}},"elephant":{"groupA":{"fontSize":60,"lineHeight":64},"groupB":{"fontSize":78,"lineHeight":84},"groupD":{"fontSize":116,"lineHeight":124}},"imperial":{"groupA":{"fontSize":50,"lineHeight":54},"groupB":{"fontSize":64,"lineHeight":72},"groupD":{"fontSize":96,"lineHeight":104}},"royal":{"groupA":{"fontSize":40,"lineHeight":44},"groupB":{"fontSize":52,"lineHeight":60},"groupD":{"fontSize":76,"lineHeight":84}},"foolscap":{"groupA":{"fontSize":32,"lineHeight":36},"groupB":{"fontSize":40,"lineHeight":44},"groupD":{"fontSize":56,"lineHeight":60}},"canon":{"groupA":{"fontSize":28,"lineHeight":32},"groupB":{"fontSize":32,"lineHeight":36},"groupD":{"fontSize":44,"lineHeight":48}},"trafalgar":{"groupA":{"fontSize":20,"lineHeight":24},"groupB":{"fontSize":24,"lineHeight":28},"groupD":{"fontSize":32,"lineHeight":36}},"paragon":{"groupA":{"fontSize":20,"lineHeight":24},"groupB":{"fontSize":22,"lineHeight":26},"groupD":{"fontSize":28,"lineHeight":32}},"doublePica":{"groupA":{"fontSize":18,"lineHeight":22},"groupB":{"fontSize":20,"lineHeight":24},"groupD":{"fontSize":24,"lineHeight":28}},"greatPrimer":{"groupA":{"fontSize":18,"lineHeight":22},"groupB":{"fontSize":18,"lineHeight":22},"groupD":{"fontSize":20,"lineHeight":24}},"bodyCopy":{"groupA":{"fontSize":15,"lineHeight":20},"groupB":{"fontSize":16,"lineHeight":22},"groupD":{"fontSize":16,"lineHeight":22}},"pica":{"groupA":{"fontSize":15,"lineHeight":20},"groupB":{"fontSize":16,"lineHeight":20},"groupD":{"fontSize":16,"lineHeight":20}},"longPrimer":{"groupA":{"fontSize":15,"lineHeight":18},"groupB":{"fontSize":15,"lineHeight":18},"groupD":{"fontSize":14,"lineHeight":18}},"brevier":{"groupA":{"fontSize":14,"lineHeight":18},"groupB":{"fontSize":14,"lineHeight":18},"groupD":{"fontSize":13,"lineHeight":16}},"minion":{"groupA":{"fontSize":12,"lineHeight":16},"groupB":{"fontSize":12,"lineHeight":16},"groupD":{"fontSize":12,"lineHeight":16}}},"manifestPath":"https://static.files.bbci.co.uk/core/manifest.1ccdbcfd4cc3bf889128a50903c2b22c81758637.json","homePageTitle":"Home","showAdPlaceholder":false,"showRelatedTopics":true,"translations":{"ads":{"advertisementLabel":"Advertisement"},"home":"Home","currentPage":"Current page","skipLinkText":"Skip to content","relatedContent":"Related content","relatedTopics":"Related topics","moreOnThis":"","navMenuText":"Sections","mediaAssetPage":{"mediaPlayer":"Media player","audioPlayer":"Audio player","videoPlayer":"Video player"},"liveExperiencePage":{"liveLabel":"Live","liveCoverage":"Live Coverage","breaking":"Breaking","postedAt":"Posted at","summary":"Summary","shareButtonText":"Share"},"downloads":{"instructions":"You can download and view today’s news.","title":"File Download"},"gist":"At a glance","error":{"404":{"statusCode":"404","title":"Page cannot be found","message":"Sorry, we're unable to bring you the page you're looking for. Please try:","solutions":["Double checking the url","Hitting the refresh button in your browser","Searching for this page using the BBC search bar"],"callToActionFirst":"Alternatively, please visit the ","callToActionLinkText":"BBC News homepage.","callToActionLast":"","callToActionLinkUrl":"https://www.bbc.com/news"},"500":{"statusCode":"500","title":"Internal server error","message":"Sorry, we're currently unable to bring you the page you're looking for. Please try:","solutions":["Hitting the refresh button in your browser","Coming back again later"],"callToActionFirst":"Alternatively, please visit the ","callToActionLinkText":"BBC News homepage.","callToActionLast":"","callToActionLinkUrl":"https://www.bbc.com/news"}},"consentBanner":{"privacy":{"title":"We've updated our Privacy and Cookies Policy","description":{"uk":{"first":"We've made some important changes to our Privacy and Cookies Policy and we want you to know what this means for you and your data.","linkText":null,"last":null,"linkUrl":null},"international":{"first":"We've made some important changes to our Privacy and Cookies Policy and we want you to know what this means for you and your data.","linkText":null,"last":null,"linkUrl":null}},"accept":"OK","reject":"Find out what's changed","rejectUrl":"https://www.bbc.co.uk/usingthebbc/privacy-policy/"},"cookie":{"amp":{"accept":"Accept data collection and continue","reject":"Reject data collection and continue","initial":{"title":"Let us know you agree to data collection on AMP","description":{"first":"We and our partners use technologies, such as ","linkText":"cookies","last":", and collect browsing data to give you the best online experience and to personalise the content and advertising shown to you. Please let us know if you agree.","linkUrl":"https://www.bbc.co.uk/usingthebbc/cookies/what-do-i-need-to-know-about-cookies/"},"manage":"Manage my settings"},"manage":{"title":"Manage consent settings on AMP pages","description":{"para1":"These settings apply to AMP pages only. You may be asked to set these preferences again when you visit non-AMP BBC pages.","para2":"The lightweight mobile page you have visited has been built using Google AMP technology.","heading2":"Strictly necessary data collection","para3":"To make our web pages work, we store some limited information on your device without your consent.","para4":{"text":"Read more about the essential information we store on your device to make our web pages work.","url":"https://www.bbc.co.uk/usingthebbc/strictly-necessary-cookies/"},"para5":"We use local storage to store your consent preferences on your device.","heading3":"Optional data collection","para6":"When you consent to data collection on AMP pages you are consenting to allow us to display personalised ads that are relevant to you when you are outside of the UK.","para7":{"text":"Read more about how we personalise ads in the BBC and our advertising partners.","url":"https://www.bbc.com/usingthebbc/cookies/how-does-the-bbc-use-cookies-for-advertising/"},"para8":"You can choose not to receive personalised ads by clicking “Reject data collection and continue” below. Please note that you will still see advertising, but it will not be personalised to you.","para9":"You can change these settings by clicking “Ad Choices / Do not sell my info” in the footer at any time."}}},"canonical":{"title":"Let us know you agree to cookies","description":{"uk":{"first":"We use ","linkText":"cookies","last":" to give you the best online experience. Please let us know if you agree to all of these cookies.","linkUrl":"https://www.bbc.co.uk/usingthebbc/cookies/what-do-i-need-to-know-about-cookies/"},"international":{"first":"We use ","linkText":"cookies","last":" to give you the best online experience. Please let us know if you agree to all of these cookies.","linkUrl":"https://www.bbc.co.uk/usingthebbc/cookies/what-do-i-need-to-know-about-cookies/"}},"accept":"Yes, I agree","reject":"No, take me to settings","rejectUrl":"https://www.bbc.co.uk/usingthebbc/cookies/how-can-i-change-my-bbc-cookie-settings/"}}},"media":{"noJs":"To play this content, please enable JavaScript, or try a different browser","contentExpired":"This content is no longer available","audio":"Audio","photogallery":"Image gallery","video":"Video","listen":"Listen","watch":"Watch","liveLabel":"LIVE","nextLabel":"NEXT","previousRadioShow":"Previous radio show","nextRadioShow":"Next radio show","duration":"Duration"},"socialEmbed":{},"featuresAnalysisTitle":"More to explore"},"mostRead":{"header":"Popular Reads","lastUpdated":"Last updated:","numberOfItems":10,"hasMostRead":true},"radioSchedule":{"hasRadioSchedule":false},"footer":{"trustProjectLink":{"href":"https://www.bbc.com/news/help-41670342","text":"Why you can trust the BBC"},"externalLink":{"href":"https://www.bbc.co.uk/editorialguidelines/guidance/feeds-and-links","text":"Read about our approach to external linking."},"links":[{"href":"https://www.bbc.com/terms","text":"Terms of Use"},{"href":"https://www.bbc.co.uk/aboutthebbc/","text":"About the BBC"},{"href":"https://www.bbc.com/privacy/","text":"Privacy Policy"},{"href":"https://www.bbc.com/usingthebbc/cookies/","text":"Cookies"},{"href":"https://www.bbc.com/accessibility/","text":"Accessibility Help"},{"href":"https://www.bbc.com/contact/","text":"Contact the BBC"},{"id":"COOKIE_SETTINGS","href":"#","text":"Do not share or sell my info","lang":"en-GB"}],"copyrightText":"BBC. The BBC is not responsible for the content of external sites."},"timezone":"Europe/London","navigation":[{"title":"Home","url":"/news"},{"title":"UK","url":"/news/uk"},{"title":"World","url":"/news/world"},{"title":"Business","url":"/news/business"},{"title":"Politics","url":"/news/politics"},{"title":"Tech","url":"/news/technology"},{"title":"Science","url":"/news/science_and_environment"},{"title":"Health","url":"/news/health"},{"title":"Family & Education","url":"/news/education"},{"title":"Entertainment & Arts","url":"/news/entertainment_and_arts"},{"title":"Stories","url":"/news/stories"}]}
+ {"lang":"en-GB","articleAuthor":"https://www.facebook.com/bbcnews","articleTimestampPrefix":"Updated","articleTimestampSuffix":"","atiAnalyticsAppName":"news","atiAnalyticsProducerId":"64","atiAnalyticsProducerName":"NEWS","chartbeatDomain":"bbc.co.uk","brandName":"BBC News","product":"BBC News","defaultImage":"https://static.files.bbci.co.uk/ws/simorgh-assets/public/news/images/metadata/poster-1024x576.png","defaultImageAltText":"BBC News","dir":"ltr","externalLinkText":", external","imageCaptionOffscreenText":"Image caption, ","videoCaptionOffscreenText":"Video caption, ","audioCaptionOffscreenText":"Audio caption","defaultCaptionOffscreenText":"Caption, ","imageCopyrightOffscreenText":"Image source, ","locale":"en_GB","datetimeLocale":"en-gb","service":"news","serviceName":"News","languageName":"English","twitterCreator":"@BBCNews","twitterSite":"@BBCNews","noBylinesPolicy":"https://www.bbc.com/news/help-41670342#authorexpertise","publishingPrinciples":"https://www.bbc.com/news/help-41670342","isTrustProjectParticipant":true,"script":{"atlas":{"groupA":{"fontSize":78,"lineHeight":84},"groupB":{"fontSize":96,"lineHeight":104},"groupD":{"fontSize":140,"lineHeight":148}},"elephant":{"groupA":{"fontSize":60,"lineHeight":64},"groupB":{"fontSize":78,"lineHeight":84},"groupD":{"fontSize":116,"lineHeight":124}},"imperial":{"groupA":{"fontSize":50,"lineHeight":54},"groupB":{"fontSize":64,"lineHeight":72},"groupD":{"fontSize":96,"lineHeight":104}},"royal":{"groupA":{"fontSize":40,"lineHeight":44},"groupB":{"fontSize":52,"lineHeight":60},"groupD":{"fontSize":76,"lineHeight":84}},"foolscap":{"groupA":{"fontSize":32,"lineHeight":36},"groupB":{"fontSize":40,"lineHeight":44},"groupD":{"fontSize":56,"lineHeight":60}},"canon":{"groupA":{"fontSize":28,"lineHeight":32},"groupB":{"fontSize":32,"lineHeight":36},"groupD":{"fontSize":44,"lineHeight":48}},"trafalgar":{"groupA":{"fontSize":20,"lineHeight":24},"groupB":{"fontSize":24,"lineHeight":28},"groupD":{"fontSize":32,"lineHeight":36}},"paragon":{"groupA":{"fontSize":20,"lineHeight":24},"groupB":{"fontSize":22,"lineHeight":26},"groupD":{"fontSize":28,"lineHeight":32}},"doublePica":{"groupA":{"fontSize":18,"lineHeight":22},"groupB":{"fontSize":20,"lineHeight":24},"groupD":{"fontSize":24,"lineHeight":28}},"greatPrimer":{"groupA":{"fontSize":18,"lineHeight":22},"groupB":{"fontSize":18,"lineHeight":22},"groupD":{"fontSize":20,"lineHeight":24}},"bodyCopy":{"groupA":{"fontSize":15,"lineHeight":20},"groupB":{"fontSize":16,"lineHeight":22},"groupD":{"fontSize":16,"lineHeight":22}},"pica":{"groupA":{"fontSize":15,"lineHeight":20},"groupB":{"fontSize":16,"lineHeight":20},"groupD":{"fontSize":16,"lineHeight":20}},"longPrimer":{"groupA":{"fontSize":15,"lineHeight":18},"groupB":{"fontSize":15,"lineHeight":18},"groupD":{"fontSize":14,"lineHeight":18}},"brevier":{"groupA":{"fontSize":14,"lineHeight":18},"groupB":{"fontSize":14,"lineHeight":18},"groupD":{"fontSize":13,"lineHeight":16}},"minion":{"groupA":{"fontSize":12,"lineHeight":16},"groupB":{"fontSize":12,"lineHeight":16},"groupD":{"fontSize":12,"lineHeight":16}}},"manifestPath":"https://static.files.bbci.co.uk/core/manifest.1ccdbcfd4cc3bf889128a50903c2b22c81758637.json","homePageTitle":"Home","showAdPlaceholder":false,"showRelatedTopics":true,"translations":{"ads":{"advertisementLabel":"Advertisement"},"home":"Home","currentPage":"Current page","skipLinkText":"Skip to content","relatedContent":"Related content","relatedTopics":"Related topics","moreOnThis":"","navMenuText":"Sections","mediaAssetPage":{"mediaPlayer":"Media player","audioPlayer":"Audio player","videoPlayer":"Video player"},"liveExperiencePage":{"liveLabel":"Live","liveCoverage":"Live Coverage","breaking":"Breaking","postedAt":"Posted at","summary":"Summary","shareButtonText":"Share"},"downloads":{"instructions":"You can download and view today’s news.","title":"File Download"},"gist":"At a glance","error":{"404":{"statusCode":"404","title":"Page cannot be found","message":"Sorry, we're unable to bring you the page you're looking for. Please try:","solutions":["Double checking the url","Hitting the refresh button in your browser","Searching for this page using the BBC search bar"],"callToActionFirst":"Alternatively, please visit the ","callToActionLinkText":"BBC News homepage.","callToActionLast":"","callToActionLinkUrl":"https://www.bbc.com/news"},"500":{"statusCode":"500","title":"Internal server error","message":"Sorry, we're currently unable to bring you the page you're looking for. Please try:","solutions":["Hitting the refresh button in your browser","Coming back again later"],"callToActionFirst":"Alternatively, please visit the ","callToActionLinkText":"BBC News homepage.","callToActionLast":"","callToActionLinkUrl":"https://www.bbc.com/news"}},"consentBanner":{"privacy":{"title":"We've updated our Privacy and Cookies Policy","description":{"uk":{"first":"We've made some important changes to our Privacy and Cookies Policy and we want you to know what this means for you and your data.","linkText":null,"last":null,"linkUrl":null},"international":{"first":"We've made some important changes to our Privacy and Cookies Policy and we want you to know what this means for you and your data.","linkText":null,"last":null,"linkUrl":null}},"accept":"OK","reject":"Find out what's changed","rejectUrl":"https://www.bbc.co.uk/usingthebbc/privacy-policy/"},"cookie":{"amp":{"accept":"Accept data collection and continue","reject":"Reject data collection and continue","initial":{"title":"Let us know you agree to data collection on AMP","description":{"first":"We and our partners use technologies, such as ","linkText":"cookies","last":", and collect browsing data to give you the best online experience and to personalise the content and advertising shown to you. Please let us know if you agree.","linkUrl":"https://www.bbc.co.uk/usingthebbc/cookies/what-do-i-need-to-know-about-cookies/"},"manage":"Manage my settings"},"manage":{"title":"Manage consent settings on AMP pages","description":{"para1":"These settings apply to AMP pages only. You may be asked to set these preferences again when you visit non-AMP BBC pages.","para2":"The lightweight mobile page you have visited has been built using Google AMP technology.","heading2":"Strictly necessary data collection","para3":"To make our web pages work, we store some limited information on your device without your consent.","para4":{"text":"Read more about the essential information we store on your device to make our web pages work.","url":"https://www.bbc.co.uk/usingthebbc/strictly-necessary-cookies/"},"para5":"We use local storage to store your consent preferences on your device.","heading3":"Optional data collection","para6":"When you consent to data collection on AMP pages you are consenting to allow us to display personalised ads that are relevant to you when you are outside of the UK.","para7":{"text":"Read more about how we personalise ads in the BBC and our advertising partners.","url":"https://www.bbc.com/usingthebbc/cookies/how-does-the-bbc-use-cookies-for-advertising/"},"para8":"You can choose not to receive personalised ads by clicking “Reject data collection and continue” below. Please note that you will still see advertising, but it will not be personalised to you.","para9":"You can change these settings by clicking “Ad Choices / Do not sell my info” in the footer at any time."}}},"canonical":{"title":"Let us know you agree to cookies","description":{"uk":{"first":"We use ","linkText":"cookies","last":" to give you the best online experience. Please let us know if you agree to all of these cookies.","linkUrl":"https://www.bbc.co.uk/usingthebbc/cookies/what-do-i-need-to-know-about-cookies/"},"international":{"first":"We use ","linkText":"cookies","last":" to give you the best online experience. Please let us know if you agree to all of these cookies.","linkUrl":"https://www.bbc.co.uk/usingthebbc/cookies/what-do-i-need-to-know-about-cookies/"}},"accept":"Yes, I agree","reject":"No, take me to settings","rejectUrl":"https://www.bbc.co.uk/usingthebbc/cookies/how-can-i-change-my-bbc-cookie-settings/"}}},"media":{"noJs":"To play this content, please enable JavaScript, or try a different browser","contentExpired":"This content is no longer available","audio":"Audio","photogallery":"Image gallery","video":"Video","listen":"Listen","watch":"Watch","liveLabel":"LIVE","nextLabel":"NEXT","previousRadioShow":"Previous radio show","nextRadioShow":"Next radio show","duration":"Duration"},"socialEmbed":{},"featuresAnalysisTitle":"More to explore"},"mostRead":{"header":"Popular Reads","lastUpdated":"Last updated:","numberOfItems":10,"hasMostRead":true},"radioSchedule":{"hasRadioSchedule":false},"footer":{"trustProjectLink":{"href":"https://www.bbc.com/news/help-41670342","text":"Why you can trust the BBC"},"externalLink":{"href":"https://www.bbc.co.uk/editorialguidelines/guidance/feeds-and-links","text":"Read about our approach to external linking."},"links":[{"href":"https://www.bbc.com/terms","text":"Terms of Use"},{"href":"https://www.bbc.co.uk/aboutthebbc/","text":"About the BBC"},{"href":"https://www.bbc.com/privacy/","text":"Privacy Policy"},{"href":"https://www.bbc.com/usingthebbc/cookies/","text":"Cookies"},{"href":"https://www.bbc.com/accessibility/","text":"Accessibility Help"},{"href":"https://www.bbc.com/contact/","text":"Contact the BBC"},{"id":"COOKIE_SETTINGS","href":"#","text":"Do not share or sell my info","lang":"en-GB"}],"copyrightText":"BBC. The BBC is not responsible for the content of external sites."},"timezone":"Europe/London","navigation":[{"title":"Home","url":"/news"},{"title":"UK","url":"/news/uk"},{"title":"World","url":"/news/world"},{"title":"Business","url":"/news/business"},{"title":"Politics","url":"/news/politics"},{"title":"Tech","url":"/news/technology"},{"title":"Science","url":"/news/science_and_environment"},{"title":"Health","url":"/news/health"},{"title":"Family & Education","url":"/news/education"},{"title":"Entertainment & Arts","url":"/news/entertainment_and_arts"},{"title":"Stories","url":"/news/stories"}]}
{"env":"live","id":"c0000000000o","isUK":true,"origin":"https://www.bbc.com","pageType":"article","derivedPageType":null,"isAmp":true,"isApp":false,"isLite":false,"isNextJs":false,"platform":"amp","statsDestination":"NEWS_PS_TEST","statusCode":200,"variant":null,"timeOnServer":null,"showAdsBasedOnLocation":true,"showCookieBannerBasedOnCountry":true,"service":"news","pathname":"/pathname","canonicalLink":"https://www.bbc.com/pathname","ampLink":"https://www.bbc.com/pathname.amp","canonicalUkLink":"https://www.bbc.co.uk/pathname","ampUkLink":"https://www.bbc.co.uk/pathname.amp","canonicalNonUkLink":"https://www.bbc.com/pathname","ampNonUkLink":"https://www.bbc.com/pathname.amp","serverSideExperiments":[{"experimentName":"foo","variation":"bar"}],"country":null,"nonce":null,"cspHeader":null}
diff --git a/src/app/lib/analyticsUtils/dispatchTrackingRequests/index.test.ts b/src/app/lib/analyticsUtils/dispatchTrackingRequests/index.test.ts
index c52e1b53459..04ab9178b22 100644
--- a/src/app/lib/analyticsUtils/dispatchTrackingRequests/index.test.ts
+++ b/src/app/lib/analyticsUtils/dispatchTrackingRequests/index.test.ts
@@ -44,7 +44,6 @@ const viewTrackerRequestsParameters = {
advertiserID: 'advertiser id',
url: 'http://example.com',
detailedPlacement: 'detailed placement',
- useReverb: true,
groupTracker: {
name: 'test group',
type: 'portrait-video-modal',
diff --git a/src/app/lib/analyticsUtils/index.client.test.js b/src/app/lib/analyticsUtils/index.client.test.js
index 24b28f22519..7842edcfeed 100644
--- a/src/app/lib/analyticsUtils/index.client.test.js
+++ b/src/app/lib/analyticsUtils/index.client.test.js
@@ -16,47 +16,13 @@ const windowLocationHrefSpy = jest.spyOn(window.location, 'href', 'get');
const {
getDestination,
enforceLegacyDestinationForJapanese,
- getScreenInfo,
- getBrowserViewPort,
- getCurrentTime,
- getDeviceLanguage,
getAppType,
getHref,
getReferrer,
- getPublishedDatetime,
- getAtUserId,
sanitise,
- getAtiUrl,
- getEventInfo,
- getThingAttributes,
- getXtorMarketingString,
- getCampaignType,
- getRSSMarketingString,
- getAffiliateMarketingString,
- getSLMarketingString,
- getEmailMarketingString,
- getCustomMarketingString,
- getDisplayMarketingString,
- getATIMarketingString,
onOnionTld,
- getContentId,
} = require('./index');
-const FIXTURE_PAGEDATA = {
- metadata: {
- analyticsLabels: {
- contentId: 'urn:bbc:cps:curie:asset:29375628-9511-42e6-be88-ebaa1158f597',
- },
- },
-};
-
-const SRC_RSS_FIXTURE = {
- key: 'src_medium',
- description: 'rss campaign prefix',
- value: 'RSS',
- wrap: false,
-};
-
const returnsNullWhenOffClient = func => {
describe('returns null when not on client', () => {
beforeEach(() => {
@@ -183,101 +149,6 @@ describe('analyticsUtils', () => {
});
});
- describe('getScreenInfo', () => {
- returnsNullWhenOffClient(getScreenInfo);
-
- it('should concat screen values, joined by "x"', () => {
- jest.replaceProperty(window.screen, 'width', 1);
- jest.replaceProperty(window.screen, 'height', 2);
- jest.replaceProperty(window.screen, 'colorDepth', 3);
- jest.replaceProperty(window.screen, 'pixelDepth', 4);
-
- const screenInfo = getScreenInfo();
-
- expect(screenInfo).toEqual('1x2x3x4');
- });
-
- it('should use 0 to fill unknown values', () => {
- jest.replaceProperty(window.screen, 'width', 1);
- jest.replaceProperty(window.screen, 'height', 2);
- jest.replaceProperty(window.screen, 'colorDepth', null);
- jest.replaceProperty(window.screen, 'pixelDepth', null);
-
- const screenInfo = getScreenInfo();
-
- expect(screenInfo).toEqual('1x2x0x0');
- });
- });
-
- describe('getBrowserViewPort', () => {
- returnsNullWhenOffClient(getBrowserViewPort);
-
- it('should concat values, joined by "x"', () => {
- jest.spyOn(window, 'innerWidth', 'get').mockImplementation(() => 1234);
- jest.spyOn(window, 'innerHeight', 'get').mockImplementation(() => 4321);
-
- const browserViewPort = getBrowserViewPort();
-
- expect(browserViewPort).toEqual('1234x4321');
- });
-
- it('should use 0 to fill unknown values', () => {
- jest.spyOn(window, 'innerWidth', 'get').mockImplementation(() => null);
- jest.spyOn(window, 'innerHeight', 'get').mockImplementation(() => 4321);
-
- const browserViewPort = getBrowserViewPort();
-
- expect(browserViewPort).toEqual('0x4321');
- });
- });
-
- describe('getCurrentTime', () => {
- const originalDate = global.Date;
-
- afterEach(() => {
- global.Date = originalDate;
- });
-
- returnsNullWhenOffClient(getCurrentTime);
-
- it('should return hours, mins and seconds joined by "x"', () => {
- const mockDate = {
- getHours: jest.fn().mockReturnValue('12'),
- getMinutes: jest.fn().mockReturnValue('23'),
- getSeconds: jest.fn().mockReturnValue('45'),
- };
- global.Date = jest.fn(() => mockDate);
-
- const ATITime = getCurrentTime();
-
- expect(ATITime).toEqual('12x23x45');
- });
- });
-
- describe('getDeviceLanguage', () => {
- returnsNullWhenOffClient(getDeviceLanguage);
-
- it('should return navigator language', () => {
- jest
- .spyOn(window.navigator, 'language', 'get')
- .mockImplementation(() => 'abc');
-
- const deviceLanguage = getDeviceLanguage();
-
- expect(deviceLanguage).toEqual('abc');
- });
-
- it('should return null if language is not set', () => {
- jest
- .spyOn(window.navigator, 'language', 'get')
- .mockImplementation(() => null);
-
- const deviceLanguage = getDeviceLanguage();
-
- expect(deviceLanguage).toEqual(null);
- });
- });
-
describe('isLocServeCookieSet', () => {
beforeEach(() => {
Cookie.remove('loc_serve');
@@ -304,25 +175,6 @@ describe('analyticsUtils', () => {
});
});
- describe('getContentId', () => {
- it('should return content id when its present in the data', () => {
- const expectedResult =
- 'urn:bbc:cps:curie:asset:29375628-9511-42e6-be88-ebaa1158f597';
- const result = getContentId(FIXTURE_PAGEDATA);
- expect(result).toEqual(expectedResult);
- });
-
- it('should return null when no data is present', () => {
- const result = getContentId({});
- expect(result).toEqual(null);
- });
-
- it('should return null when data is invalid', () => {
- const result = getContentId('hello world');
- expect(result).toEqual(null);
- });
- });
-
describe('getHref', () => {
returnsNullWhenOffClient(getHref);
@@ -382,466 +234,21 @@ describe('analyticsUtils', () => {
});
});
- describe('getPublishedDatetime', () => {
- const data = {
- metadata: {
- firstPublished: 946688461000,
- seconds: 1504785600000,
- invalidDate: 'foobar',
- },
- };
-
- it('should find value in good data', () => {
- const publishedTime = getPublishedDatetime('firstPublished', data);
-
- expect(publishedTime).toEqual('2000-01-01T01:01:01.000Z');
- });
-
- it('should autodetect timestamp in seconds and autocorrect', () => {
- const secondsTimestamp = getPublishedDatetime('seconds', data);
-
- expect(secondsTimestamp).toEqual('2017-09-07T12:00:00.000Z');
- });
-
- it('should return null if type not found', () => {
- const publishedTime = getPublishedDatetime('foobar', data);
-
- expect(publishedTime).toEqual(null);
- });
-
- it('should return null if timestamp is invalid', () => {
- const publishedTime = getPublishedDatetime('invalidDate', data);
-
- expect(publishedTime).toEqual(null);
- });
- });
-
- describe('getAtiUrl', () => {
- it('should return url', () => {
- const data = [
- {
- key: 'a',
- value: 'a1',
- wrap: false,
- },
- {
- key: 'b',
- value: 'b1',
- wrap: true,
- },
- {
- key: 'c',
- value: 'c1',
- wrap: false,
- },
- ];
- expect(getAtiUrl(data)).toEqual('a=a1&b=[b1]&c=c1');
- });
-
- it('should return empty string', () => {
- const data = [];
- expect(getAtiUrl(data)).toEqual('');
- });
- });
-
- describe('getEventInfo', () => {
- const params = {
- pageIdentifier: 'page-identifier',
- componentName: 'component-name',
- campaignID: 'campaign-id',
- url: 'url',
- format: 'format',
- detailedPlacement: 'detailed-placement',
- advertiserID: 'mundo',
- experimentVariant: 'a/b-test',
- };
-
- it('should return url section', () => {
- expect(getEventInfo(params)).toEqual(
- 'PUB-[campaign-id]-[component-name]-[a/b-test]-[format]-[page-identifier]-[detailed-placement]-[mundo]-[url]',
- );
- });
-
- it('should allow empty values', () => {
- expect(getEventInfo()).toContain('PUB-[]-[]-[]-[]-[]-[]-[]-[]');
- });
- });
-
- describe('getAtUserId', () => {
- let cookieSetterSpy;
-
- returnsNullWhenOffClient(getAtUserId);
- beforeEach(() => {
- jest.clearAllMocks();
- Cookie.remove('atuserid');
- cookieSetterSpy = jest.spyOn(Cookie, 'set');
- });
-
- it('should return the AT user id', () => {
- Cookie.set('atuserid', '{ "val": "some-random-uuid" }', { secure: true });
- cookieSetterSpy.mockClear();
- const atUserId = getAtUserId();
-
- expect(atUserId).toEqual('some-random-uuid');
- });
-
- it('should store the existing AT user id as a stringified JSON value in cookies again so that we update the cookie expiration date', () => {
- Cookie.set('atuserid', '{ "val": "some-random-uuid" }', { secure: true });
- cookieSetterSpy.mockClear();
- const atUserId = getAtUserId();
- const [[cookieName, cookieValue, cookieOptions]] =
- cookieSetterSpy.mock.calls;
-
- expect(atUserId).toEqual('some-random-uuid');
- expect(cookieName).toEqual('atuserid');
- expect(JSON.parse(cookieValue)).toEqual({
- val: atUserId,
- });
- expect(cookieOptions).toEqual({ expires: 397, path: '/', secure: true });
- expect(cookieSetterSpy).toHaveBeenCalledTimes(1);
- });
-
- it('should create a new AT user id if the atuserid cookie does not already exist and then store the id as a stringified JSON value in the cookies', () => {
- const atUserId = getAtUserId();
- const [[cookieName, cookieValue, cookieOptions]] =
- cookieSetterSpy.mock.calls;
-
- expect(cookieName).toEqual('atuserid');
- expect(JSON.parse(cookieValue)).toEqual({
- val: atUserId,
- });
- expect(cookieOptions).toEqual({ expires: 397, path: '/', secure: true });
- expect(cookieSetterSpy).toHaveBeenCalledTimes(1);
- });
- });
-
- describe('getThingAttributes', () => {
- const data = {
- metadata: {
- tags: {
- about: [{ thingId: 'foo bar' }, { thingId: 'baz' }],
- },
- },
- };
-
- it('should return thing names in good data', () => {
- const thingAttributes = getThingAttributes('thingId', data);
-
- expect(thingAttributes).toEqual('foo%20bar~baz');
- });
-
- it('should return null if type not found', () => {
- const thingAttributes = getThingAttributes('fooBar', data);
-
- expect(thingAttributes).toEqual(null);
- });
-
- it('should return null if invalid data', () => {
- const thingAttributes = getThingAttributes('fooBar', {});
-
- expect(thingAttributes).toEqual(null);
- });
- });
-
- describe('getCampaignType', () => {
- test.each`
- qsValue | expected
- ${'?at_medium=email'} | ${'email'}
- ${'?at_medium=affiliate'} | ${'affiliate'}
- ${'?at_medium=custom123'} | ${'custom123'}
- ${'?at_medium=sl'} | ${'sl'}
- ${'?at_medium=foo'} | ${null}
- ${'?xtor=123'} | ${'XTOR'}
- ${'?at_medium=RSS'} | ${'RSS'}
- `('should return a campaign type of $expected', ({ qsValue, expected }) => {
- windowLocationHrefSpy.mockImplementation(
- () => `https://www.bbc.com/mundo${qsValue}`,
- );
-
- const campaignType = getCampaignType();
-
- expect(campaignType).toEqual(expected);
- });
-
- it('should return campaign type of XTOR', () => {
- windowLocationHrefSpy.mockImplementation(
- () => 'https://www.bbc.com/mundo#xtor',
- );
-
- const campaignType = getCampaignType();
-
- expect(campaignType).toEqual('XTOR');
- });
- });
-
- describe('getRSSMarketingString', () => {
- describe('"RSS" prefix', () => {
- it('returns "src_medium" when marketing string is present in url', () => {
- const href = 'https://www.bbc.com/mundo?at_medium=RSS';
- expect(getRSSMarketingString(href, 'RSS')).toEqual([SRC_RSS_FIXTURE]);
- });
- it('return empty array when campaign is not RSS', () => {
- const href = 'https://www.bbc.com/mundo?at_medium=affiliate';
- expect(getRSSMarketingString(href, 'affiliate')).toEqual([]);
- });
-
- it('return empty array when campaign is null', () => {
- const href = 'https://www.bbc.com/mundo?at_medium=affiliate';
- expect(getRSSMarketingString(href, null)).toEqual([]);
- });
-
- it('return empty array when campaign is undefined', () => {
- const href = 'https://www.bbc.com/mundo?at_medium=affiliate';
- expect(getRSSMarketingString(href, undefined)).toEqual([]);
- });
-
- describe('with optional params', () => {
- it.each`
- expectation | href | expectedValue
- ${'omits value if prefix "at_" is not present'} | ${'https://www.bbc.com/mundo?at_medium=RSS&someKey=someValue'} | ${[SRC_RSS_FIXTURE]}
- ${'the value of the "at_someKey" field'} | ${'https://www.bbc.com/mundo?at_medium=RSS&at_someKey=someValue'} | ${[SRC_RSS_FIXTURE, { key: 'src_someKey', description: 'src_someKey field', value: 'someValue', wrap: false }]}
- `(
- 'should return marketing string for $expectation',
- ({ href, expectedValue }) => {
- expect(getRSSMarketingString(href, 'RSS')).toEqual(expectedValue);
- },
- );
- });
- });
- });
-
- describe('getAffiliateMarketingString', () => {
- describe('should return the "al" prefix', () => {
- describe('with optional params', () => {
- it.each`
- expectation | href | expectedValue
- ${'the value of the "at_campaign" field'} | ${'https://www.bbc.com/mundo?at_medium=affiliate&at_campaign=73'} | ${'al-73-----'}
- ${'the value of the "at_type" field, wrapped in square brackets'} | ${'https://www.bbc.com/mundo?at_medium=affiliate&at_type=partner'} | ${'al--[partner]----'}
- ${'the value of the "at_identifier" field, wrapped in square brackets'} | ${'https://www.bbc.com/mundo?at_medium=affiliate&at_identifier=whatsapp'} | ${'al---[whatsapp]---'}
- ${'whe value of the "at_format" field, wrapped in square brackets'} | ${'https://www.bbc.com/mundo?at_medium=affiliate&at_format=Link'} | ${'al----[Link]--'}
- ${'the value of the "at_creation" field, wrapped in square brackets'} | ${'https://www.bbc.com/mundo?at_medium=affiliate&at_creation=wsmundo'} | ${'al-----[wsmundo]-'}
- ${'the value of the "at_variant" field, wrapped in square brackets'} | ${'https://www.bbc.com/mundo?at_medium=affiliate&at_variant=Editorial'} | ${'al------[Editorial]'}
- `(
- 'should return marketing string for $expectation',
- ({ href, expectedValue }) => {
- expect(getAffiliateMarketingString(href)).toEqual(expectedValue);
- },
- );
- });
- describe('with all params', () => {
- it('should return all fields', () => {
- const href =
- 'https://www.bbc.com/mundo?at_medium=affiliate&at_campaign=73&at_creation=wsmundo&at_format=Link&at_identifier=whatsapp&at_type=partner&at_variant=Editorial';
- const expected =
- 'al-73-[partner]-[whatsapp]-[Link]-[wsmundo]-[Editorial]';
-
- expect(getAffiliateMarketingString(href)).toEqual(expected);
- });
- });
- });
- });
-
- describe('getSLMarketingString', () => {
- describe('should return the "SEC" prefix', () => {
- describe('with optional params', () => {
- it.each`
- expectation | href | expectedValue
- ${'the value of the "at_campaign" field'} | ${'https://www.bbc.com/mundo?at_medium=sl&at_campaign=73'} | ${'SEC-73-----'}
- ${'with the value of the "at_platform" field, wrapped in square brackets'} | ${'https://www.bbc.com/mundo?at_medium=sl&at_platform=google'} | ${'SEC--[google]----'}
- ${'the value of the "at_creation" field, wrapped in square brackets'} | ${'https://www.bbc.com/mundo?at_medium=sl&at_creation=my_adgroup'} | ${'SEC---[my_adgroup]---'}
- ${'the value of the "at_variant" field, wrapped in square brackets'} | ${'https://www.bbc.com/mundo?at_medium=sl&at_variant=Editorial'} | ${'SEC----[Editorial]--'}
- ${'the value of the "at_network" field when "at_network" field is "search"'} | ${'https://www.bbc.com/mundo?at_medium=sl&at_network=search'} | ${'SEC-----F=S-'}
- ${'the value of the "at_network" field when "at_network" field is "content"'} | ${'https://www.bbc.com/mundo?at_medium=sl&at_network=content'} | ${'SEC-----F=C-'}
- ${'the value of the "at_network" field when "at_network" field is neither "content" or "search"'} | ${'https://www.bbc.com/mundo?at_medium=sl&at_network=foobar'} | ${'SEC------'}
- ${'the value of the at_term field, wrapped in square brackets'} | ${'https://www.bbc.com/mundo?at_medium=sl&at_term=article'} | ${'SEC------[article]'}
- `(
- 'should return marketing string for $expectation',
- ({ href, expectedValue }) => {
- expect(getSLMarketingString(href)).toEqual(expectedValue);
- },
- );
- });
- describe('with all params', () => {
- it('should return all fields', () => {
- const href =
- 'https://www.bbc.com/mundo?at_medium=sl&at_term=article&at_network=search&at_creation=my_adgroup&at_variant=Editorial&at_platform=google&at_campaign=73';
- const expected =
- 'SEC-73-[google]-[my_adgroup]-[Editorial]-F=S-[article]';
-
- expect(getSLMarketingString(href)).toEqual(expected);
- });
- });
- });
- });
-
- describe('getEmailMarketingString', () => {
- describe('should return the "SEC" prefix', () => {
- describe('with optional params', () => {
- it.each`
- expectation | href | expectedValue
- ${'the value of "at_emailtype" field when its value is "acquisition"'} | ${'https://www.bbc.com/mundo?at_medium=email&at_emailtype=acquisition'} | ${'EREC-----@'}
- ${'the value of "at_emailtype" field when its value is "retention"'} | ${'https://www.bbc.com/mundo?at_medium=email&at_emailtype=retention'} | ${'EPR-----@'}
- ${'the value of "at_emailtype" field when its value is "promotion"'} | ${'https://www.bbc.com/mundo?at_medium=email&at_emailtype=promotion'} | ${'ES-----@'}
- ${'the value of "at_emailtype" field when its value is neither "promotion", "acquisition" or "retention"'} | ${'https://www.bbc.com/mundo?at_medium=email&at_emailtype=foobar'} | ${'-----@'}
- ${'the value of the "at_campaign" field'} | ${'https://www.bbc.com/mundo?at_medium=email&at_emailtype=promotion&at_campaign=56'} | ${'ES-56----@'}
- ${'the value of the "at_creation" field, wrapped in square brackets'} | ${'https://www.bbc.com/mundo?at_medium=email&at_emailtype=promotion&at_creation=wsmundo'} | ${'ES--[wsmundo]---@'}
- ${'the value of the at_send_date field'} | ${'https://www.bbc.com/mundo?at_medium=email&at_emailtype=promotion&at_send_date=20190401'} | ${'ES---20190401--@'}
- ${'the value of the at_link field, wrapped in square brackets'} | ${'https://www.bbc.com/mundo?at_medium=email&at_emailtype=promotion&at_link=cta_button'} | ${'ES----[cta_button]-@'}
- ${'the value of the at_recipient_id field followed by the @ symbol and the value of the at_recipient_list field'} | ${'https://www.bbc.com/mundo?at_medium=email&at_emailtype=promotion&at_recipient_id=5633&at_recipient_list=200'} | ${'ES-----5633@200'}
- ${'the value of the at_recipient_id field followed by the @ symbol when the value of the at_recipient_list field is not available'} | ${'https://www.bbc.com/mundo?at_medium=email&at_emailtype=promotion&at_recipient_id=5633'} | ${'ES-----5633@'}
- ${'the @ symbol followed by the value of the at_recipient_list field when the value of the at_recipient_id field is not available'} | ${'https://www.bbc.com/mundo?at_medium=email&at_emailtype=promotion&at_recipient_list=200'} | ${'ES-----@200'}
- `('should return $expectation', ({ href, expectedValue }) => {
- expect(getEmailMarketingString(href)).toEqual(expectedValue);
- });
- });
- describe('with all params', () => {
- it('should return all fields', () => {
- const href =
- 'https://www.bbc.com/mundo?at_medium=email&at_emailtype=promotion&at_campaign=56&at_creation=wsmundo&at_send_date=20190401&at_link=cta_button&at_recipient_id=5633&at_recipient_list=200';
- const expected = 'ES-56-[wsmundo]-20190401-[cta_button]-5633@200';
-
- expect(getEmailMarketingString(href)).toEqual(expected);
- });
- });
- });
- });
-
- describe('getDisplayMarketingString', () => {
- describe('should return the "AD" prefix', () => {
- describe('with optional params', () => {
- it.each`
- expectation | href | expectedValue
- ${'the value of the "at_campaign" field'} | ${'https://www.bbc.com/mundo?at_medium=display&at_campaign=56'} | ${'AD-56------'}
- ${'the value of the "at_creation" field, wrapped in square brackets'} | ${'https://www.bbc.com/mundo?at_medium=display&at_creation=wsmundo'} | ${'AD--[wsmundo]-----'}
- ${'the value of the "at_variant" field, wrapped in square brackets'} | ${'https://www.bbc.com/mundo?at_medium=custom123&at_variant=Editorial'} | ${'AD---[Editorial]----'}
- ${'the value of the "at_format" field, wrapped in square brackets'} | ${'https://www.bbc.com/mundo?at_medium=custom123&at_format=Link'} | ${'AD----[Link]---'}
- ${'the value of the "at_general_placement" field, wrapped in square brackets'} | ${'https://www.bbc.com/mundo?at_medium=custom123&at_general_placement=home'} | ${'AD------[home]-'}
- ${'the value of the "at_detail_placement" field, wrapped in square brackets'} | ${'https://www.bbc.com/mundo?at_medium=custom123&at_detail_placement=sidebar'} | ${'AD-------[sidebar]'}
- `(
- 'should return marketing string for $expectation',
- ({ href, expectedValue }) => {
- expect(getDisplayMarketingString(href)).toEqual(expectedValue);
- },
- );
- });
- describe('with all params', () => {
- it('should return all fields', () => {
- const href =
- 'https://www.bbc.com/mundo?at_medium=display&at_campaign=56&at_creation=wsmundo&at_variant=Editorial&at_format=Link&at_general_placement=home&at_detail_placement=sidebar';
- const expected =
- 'AD-56-[wsmundo]-[Editorial]-[Link]--[home]-[sidebar]';
-
- expect(getDisplayMarketingString(href)).toEqual(expected);
- });
- });
- });
- });
-
- describe('getCustomMarketingString', () => {
- describe('should return the "CS" prefix followed by the part of the at_medium field following the word custom', () => {
- describe('with optional params', () => {
- it.each`
- expectation | href | expectedValue
- ${'the value of the "at_campaign" field'} | ${'https://www.bbc.com/mundo?at_medium=custom123&at_campaign=56'} | ${'CS123-56----'}
- ${'the value of the "at_custom1" field, wrapped in square brackets'} | ${'https://www.bbc.com/mundo?at_medium=custom123&at_custom1=var_1'} | ${'CS123--[var_1]---'}
- ${'the value of the "at_custom2" field, wrapped in square brackets'} | ${'https://www.bbc.com/mundo?at_medium=custom123&at_custom2=var_2'} | ${'CS123---[var_2]--'}
- ${'the value of the "at_custom3" field, wrapped in square brackets'} | ${'https://www.bbc.com/mundo?at_medium=custom123&at_custom3=var_3'} | ${'CS123----[var_3]-'}
- ${'the value of the "at_custom4" field, wrapped in square brackets'} | ${'https://www.bbc.com/mundo?at_medium=custom123&at_custom4=var_4'} | ${'CS123-----[var_4]'}
- `(
- 'should return marketing string for $expectation',
- ({ href, expectedValue }) => {
- expect(getCustomMarketingString(href)).toEqual(expectedValue);
- },
- );
- });
- describe('with all params', () => {
- it('should return all fields', () => {
- const href =
- 'https://www.bbc.com/mundo?at_medium=custom123&at_campaign=56&at_custom1=var_1&at_custom2=var_2&at_custom3=var_3&at_custom4=var_4';
- const expected = 'CS123-56-[var_1]-[var_2]-[var_3]-[var_4]';
-
- expect(getCustomMarketingString(href)).toEqual(expected);
- });
- });
- });
- });
-
- describe('getXtorMarketingString', () => {
+ describe('onOnionTld', () => {
it.each`
- expectation | href | expectedValue
- ${'the value of the "xtor" field when it is a hash param from an anchor'} | ${'https://www.bbc.com/mundo/#at_medium=sl&xtor=AD-3030'} | ${'AD-3030'}
- ${'the value of the xtor field when xtor is a query param and there is a hash param'} | ${'https://www.bbc.com/mundo?xtor=AD-3030#at_medium=AD-3040'} | ${'AD-3030'}
- ${'the value of the xtor field when it is a query param'} | ${'https://www.bbc.com/mundo?xtor=AD-3030'} | ${'AD-3030'}
- ${'null when xtor param is not available'} | ${'https://www.bbc.com/mundo#at_medium'} | ${null}
- `('should return $expectation', ({ href, expectedValue }) => {
- expect(getXtorMarketingString(href)).toEqual(expectedValue);
- });
- });
-
- describe('getATIMarketingString', () => {
- describe('for query params', () => {
- it.each`
- campaignType | href | expectedValue
- ${'affiliate'} | ${'https://www.bbc.com/mundo?at_medium=affiliate&at_campaign=73&at_creation=wsmundo&at_format=Link&at_identifier=whatsapp&at_type=partner&at_variant=Editorial'} | ${'al-73-[partner]-[whatsapp]-[Link]-[wsmundo]-[Editorial]'}
- ${'sl'} | ${'https://www.bbc.com/mundo?at_medium=sl&at_term=article&at_network=search&at_creation=my_adgroup&at_variant=Editorial&at_platform=google&at_campaign=73'} | ${'SEC-73-[google]-[my_adgroup]-[Editorial]-F=S-[article]'}
- ${'email'} | ${'https://www.bbc.com/mundo?at_medium=email&at_emailtype=promotion&at_campaign=56&at_creation=wsmundo&at_send_date=20190401&at_link=cta_button&at_recipient_id=5633&at_recipient_list=200'} | ${'ES-56-[wsmundo]-20190401-[cta_button]-5633@200'}
- ${'display'} | ${'https://www.bbc.com/mundo?at_medium=display&at_campaign=56&at_creation=wsmundo&at_variant=Editorial&at_format=Link&at_general_placement=home&at_detail_placement=sidebar'} | ${'AD-56-[wsmundo]-[Editorial]-[Link]--[home]-[sidebar]'}
- ${'custom'} | ${'https://www.bbc.com/mundo?at_medium=custom123&at_campaign=56&at_custom1=var_1&at_custom2=var_2&at_custom3=var_3&at_custom4=var_4'} | ${'CS123-56-[var_1]-[var_2]-[var_3]-[var_4]'}
- ${'XTOR'} | ${'https://www.bbc.com/mundo?xtor=AD-3030-[ad_version7]-[without_text]-[468]-[www.bbc.com]-[GT]-[top_page]'} | ${'AD-3030-[ad_version7]-[without_text]-[468]-[www.bbc.com]-[GT]-[top_page]'}
- ${'unsupported-type'} | ${'https://www.bbc.com/mundo?at_medium=foo'} | ${null}
- ${null} | ${null} | ${null}
- ${'XTOR'} | ${null} | ${null}
- `(
- 'should return $expectedValue for campaign type of $campaignType when href is $href',
- ({ href, expectedValue, campaignType }) => {
- expect(getATIMarketingString(href, campaignType)).toEqual(
- expectedValue,
- );
- },
- );
- });
- describe('for hash params params', () => {
- it.each`
- campaignType | href | expectedValue
- ${'affiliate'} | ${'https://www.bbc.com/mundo#at_medium=affiliate&at_campaign=73&at_creation=wsmundo&at_format=Link&at_identifier=whatsapp&at_type=partner&at_variant=Editorial'} | ${'al-73-[partner]-[whatsapp]-[Link]-[wsmundo]-[Editorial]'}
- ${'sl'} | ${'https://www.bbc.com/mundo#at_medium=sl&at_term=article&at_network=search&at_creation=my_adgroup&at_variant=Editorial&at_platform=google&at_campaign=73'} | ${'SEC-73-[google]-[my_adgroup]-[Editorial]-F=S-[article]'}
- ${'email'} | ${'https://www.bbc.com/mundo/#at_medium=email&at_emailtype=promotion&at_campaign=56&at_creation=wsmundo&at_send_date=20190401&at_link=cta_button&at_recipient_id=5633&at_recipient_list=200'} | ${'ES-56-[wsmundo]-20190401-[cta_button]-5633@200'}
- ${'display'} | ${'https://www.bbc.com/mundo#at_medium=display&at_campaign=56&at_creation=wsmundo&at_variant=Editorial&at_format=Link&at_general_placement=home&at_detail_placement=sidebar'} | ${'AD-56-[wsmundo]-[Editorial]-[Link]--[home]-[sidebar]'}
- ${'custom'} | ${'https://www.bbc.com/mundo/#at_medium=custom123&at_campaign=56&at_custom1=var_1&at_custom2=var_2&at_custom3=var_3&at_custom4=var_4'} | ${'CS123-56-[var_1]-[var_2]-[var_3]-[var_4]'}
- ${'XTOR'} | ${'https://www.bbc.com/mundo#xtor=AD-3030-[ad_version7]-[without_text]-[468]-[www.bbc.com]-[GT]-[top_page]'} | ${'AD-3030-[ad_version7]-[without_text]-[468]-[www.bbc.com]-[GT]-[top_page]'}
- ${'unsupported-type'} | ${'https://www.bbc.com/mundo/#at_medium=foo'} | ${null}
- ${null} | ${null} | ${null}
- ${'XTOR'} | ${null} | ${null}
- `(
- 'should return $expectedValue for campaign type of $campaignType when href is $href',
- ({ href, expectedValue, campaignType }) => {
- windowLocationHrefSpy.mockImplementation(() => href);
-
- expect(getATIMarketingString(href, campaignType)).toEqual(
- expectedValue,
- );
- },
- );
- });
-
- describe('onOnionTld', () => {
- it.each`
- expectation | currentUrl | expectedValue
- ${'true for onion TLD'} | ${'https://www.bbcnewsd73hkzno2ini43t4gblxvycyac5aw4gnv7t2rccijh7745uqd.onion/news'} | ${true}
- ${'true for onion TLD'} | ${'https://www.bbcweb3hytmzhn5d532owbu6oqadra5z3ar726vq5kgwwn6aucdccrad.onion/russian'} | ${true}
- ${'true for onion TLD'} | ${'https://www.bbcweb3hytmzhn5d532owbu6oqadra5z3ar726vq5kgwwn6aucdccrad.onion/russian/news-60699063'} | ${true}
- ${'false for .co.uk TLD'} | ${'https://www.bbc.co.uk/news'} | ${false}
- ${'false for .com TLD'} | ${'https://www.bbc.com/news'} | ${false}
- ${'false for .com TLD'} | ${'https://www.bbcrussian.com/russian/live/news-60661774'} | ${false}
- `('should return $expectation', ({ currentUrl, expectedValue }) => {
- const { host } = new URL(currentUrl);
-
- jest
- .spyOn(window.location, 'host', 'get')
- .mockImplementation(() => host);
-
- expect(onOnionTld()).toEqual(expectedValue);
- });
+ expectation | currentUrl | expectedValue
+ ${'true for onion TLD'} | ${'https://www.bbcnewsd73hkzno2ini43t4gblxvycyac5aw4gnv7t2rccijh7745uqd.onion/news'} | ${true}
+ ${'true for onion TLD'} | ${'https://www.bbcweb3hytmzhn5d532owbu6oqadra5z3ar726vq5kgwwn6aucdccrad.onion/russian'} | ${true}
+ ${'true for onion TLD'} | ${'https://www.bbcweb3hytmzhn5d532owbu6oqadra5z3ar726vq5kgwwn6aucdccrad.onion/russian/news-60699063'} | ${true}
+ ${'false for .co.uk TLD'} | ${'https://www.bbc.co.uk/news'} | ${false}
+ ${'false for .com TLD'} | ${'https://www.bbc.com/news'} | ${false}
+ ${'false for .com TLD'} | ${'https://www.bbcrussian.com/russian/live/news-60661774'} | ${false}
+ `('should return $expectation', ({ currentUrl, expectedValue }) => {
+ const { host } = new URL(currentUrl);
+
+ jest.spyOn(window.location, 'host', 'get').mockImplementation(() => host);
+
+ expect(onOnionTld()).toEqual(expectedValue);
});
});
});
diff --git a/src/app/lib/analyticsUtils/index.js b/src/app/lib/analyticsUtils/index.js
index 0adf459a7bb..5987c28f6c9 100644
--- a/src/app/lib/analyticsUtils/index.js
+++ b/src/app/lib/analyticsUtils/index.js
@@ -1,14 +1,5 @@
import Cookie from 'js-cookie';
-import pathOr from 'ramda/src/pathOr';
-import path from 'ramda/src/path';
import onClient from '#lib/utilities/onClient';
-import getUUID from '#lib/utilities/getUUID';
-import isOperaProxy from '#lib/utilities/isOperaProxy';
-import {
- MEDIUM_CAMPAIGN_IDENTIFIER,
- XTOR_CAMPAIGN_IDENTIFIER,
- SUPPORTED_MEDIUM_CAMPAIGN_TYPES,
-} from './analytics.const';
import getAmpDestination from './getAmpDestination';
export const getDestination = (platform, statsDestination) => {
@@ -101,70 +92,6 @@ export const isLocServeCookieSet = platform => {
return null;
};
-export const getScreenInfo = platform => {
- if (platform === 'amp') {
- return `\${screenWidth}x\${screenHeight}x\${screenColorDepth}`;
- }
-
- if (onClient()) {
- const { width, height, colorDepth, pixelDepth } = window.screen;
- const orderArray = [
- width || 0,
- height || 0,
- colorDepth || 0,
- pixelDepth || 0,
- ];
-
- return orderArray.join('x');
- }
-
- return null;
-};
-
-export const getBrowserViewPort = platform => {
- if (platform === 'amp') {
- return `\${availableScreenWidth}x\${availableScreenHeight}`;
- }
-
- if (onClient()) {
- const { innerWidth, innerHeight } = window;
-
- return [innerWidth || 0, innerHeight || 0].join('x');
- }
-
- return null;
-};
-
-export const getCurrentTime = platform => {
- if (platform === 'amp') {
- return `\${timestamp}`;
- }
-
- if (onClient()) {
- const now = new Date();
- const hours = now.getHours();
- const mins = now.getMinutes();
- const secs = now.getSeconds();
-
- return [hours, mins, secs].join('x');
- }
-
- return null;
-};
-
-export const getDeviceLanguage = platform => {
- if (platform === 'amp') {
- // Using browserlanguage since AMP doesn't have access to device language
- return `\${browserLanguage}`;
- }
-
- if (onClient() && navigator.language) {
- return navigator.language;
- }
-
- return null;
-};
-
export const getHref = platform => {
if (platform === 'amp') {
return `\${sourceUrl}`;
@@ -194,456 +121,9 @@ export const getReferrer = platform => {
return null;
};
-export const getAtUserId = () => {
- if (!onClient()) return null;
-
- // Users accessing the site on opera "extreme data saving mode" have the pages rendered by an intermediate service
- // Attempting to track these users is just tracking that proxy, causing all opera mini visitors to have the same id
- if (isOperaProxy()) return null;
-
- const cookieName = 'atuserid';
- let cookie = Cookie.get(cookieName);
- const expires = 397; // expires in 13 months
-
- if (cookie) {
- try {
- cookie = JSON.parse(cookie);
- } catch (error) {
- // eslint-disable-next-line no-console
- console.log(error);
- cookie = null;
- }
- }
-
- const val = path(['val'], cookie) || getUUID();
-
- Cookie.set(cookieName, JSON.stringify({ val }), {
- expires,
- path: '/',
- secure: true,
- });
-
- return val;
-};
-
export const sanitise = initialString =>
initialString ? initialString.trim().replace(/\s/g, '%20') : null;
-const isValidDateTime = dateTime => !isNaN(dateTime); // eslint-disable-line no-restricted-globals
-
-const getISODate = unixTimestamp => {
- const date = new Date(unixTimestamp);
- return date.toISOString();
-};
-
-export const getPublishedDatetime = (attribute, data) => {
- const publishedDatetime = pathOr(null, ['metadata', attribute], data);
-
- return publishedDatetime && isValidDateTime(publishedDatetime)
- ? getISODate(publishedDatetime)
- : null;
-};
-
-export const getContentId = pathOr(null, [
- 'metadata',
- 'analyticsLabels',
- 'contentId',
-]);
-
-export const getAtiUrl = (data = []) => {
- const cleanedValues = data
- .filter(({ value }) => value)
- .map(item => {
- const { value, disableEncoding } = item;
- const finalValue = disableEncoding ? value : encodeURIComponent(value);
- return { ...item, value: finalValue };
- });
-
- const parsedAtiValues = cleanedValues.map(({ key, value, wrap }) =>
- wrap ? `${key}=[${value}]` : `${key}=${value}`,
- );
-
- return parsedAtiValues.join('&');
-};
-
-export const getEventInfo = ({
- pageIdentifier = '',
- componentName = '',
- campaignID = '',
- experimentVariant = '',
- format = '',
- detailedPlacement = '',
- advertiserID = '',
- url = '',
-} = {}) => {
- const generalPlacement = pageIdentifier;
- const creation = componentName;
-
- return `PUB-[${campaignID}]-[${creation}]-[${experimentVariant}]-[${format}]-[${generalPlacement}]-[${detailedPlacement}]-[${advertiserID}]-[${url}]`;
-};
-
-export const getThingAttributes = (attribute, articleData) => {
- const things = pathOr(null, ['metadata', 'tags', 'about'], articleData);
-
- if (things) {
- const attributes = [];
-
- things.forEach(thing => {
- if (thing[attribute]) {
- attributes.push(thing[attribute].trim().replace(/\s/g, '%20'));
- }
- });
-
- return attributes.join('~') || null;
- }
-
- return null;
-};
-
-/* This transforms urls with a hash param to query params
- ie. from bbc.com/mundo#some_param_1=24&some_param_2=48 to bbc.com/mundo?some_param_1=24&some_param_2=48
-*/
-const parameteriseHash = hash => {
- const { searchParams } = new URL(
- hash.replace('#', '?'),
- 'https://www.bbc.com',
- );
-
- return Object.fromEntries(searchParams);
-};
-
-const getQueryParamsFromURL = href => {
- const { searchParams, hash } = new URL(href, 'https://www.bbc.com');
- const query = Object.fromEntries(searchParams);
-
- const hashParams = hash ? parameteriseHash(hash) : {};
-
- return { ...query, ...hashParams };
-};
-
-export const getCampaignType = () => {
- if (!onClient()) return null;
-
- // Gets the query string parameters from the current url parsing them as an object
- const queryWithParams = getQueryParamsFromURL(window.location.href);
-
- // Check for the presence of the `?at_medium` QS
- const isMediumCampaign = Object.prototype.hasOwnProperty.call(
- queryWithParams,
- MEDIUM_CAMPAIGN_IDENTIFIER,
- );
-
- // Checks for the presence of the `?xtor` WS or anchor e.g. `#xtor`
- const isXtorCampaign = Object.prototype.hasOwnProperty.call(
- queryWithParams,
- XTOR_CAMPAIGN_IDENTIFIER,
- );
-
- if (isMediumCampaign) {
- const isSupportedMediumCampaignType = SUPPORTED_MEDIUM_CAMPAIGN_TYPES.some(
- type => queryWithParams[MEDIUM_CAMPAIGN_IDENTIFIER].includes(type),
- );
-
- return isSupportedMediumCampaignType
- ? queryWithParams[MEDIUM_CAMPAIGN_IDENTIFIER]
- : null;
- }
-
- if (isXtorCampaign) return 'XTOR';
-
- return null;
-};
-
-const getMarketingUrlParam = (href, field) => {
- const queryWithParams = getQueryParamsFromURL(href);
-
- return Object.prototype.hasOwnProperty.call(queryWithParams, field)
- ? queryWithParams[field]
- : '';
-};
-
-const buildMarketingString = marketingValues =>
- marketingValues
- .map(({ value, wrap }) => (wrap && value ? `[${value}]` : value))
- .join('-');
-
-/*
- * RSS marketing string uses v2 full-custom campaigns which uses specifies that parameters are in the format "src_myproperty: myvalue" for each property in the campaign.
- * more information at https://developers.atinternet-solutions.com/as2-tagging-en/javascript-en/campaigns-javascript-en/marketing-campaigns-v2/?kw=at_custom#full-custom-campaigns_13
- */
-const buildRSSMarketingString = href => {
- const queryWithParams = getQueryParamsFromURL(href);
-
- return Object.keys(queryWithParams).reduce((accum, currVal) => {
- if (currVal.includes('at_')) {
- const type = currVal.replace('at_', '');
-
- if (type === 'medium') {
- return [
- {
- key: 'src_medium',
- description: 'rss campaign prefix',
- value: 'RSS',
- wrap: false,
- },
- ];
- }
-
- return [
- ...accum,
- {
- key: `src_${type}`,
- description: `src_${type} field`,
- value: getMarketingUrlParam(href, currVal),
- wrap: false,
- },
- ];
- }
- return accum;
- }, []);
-};
-
-export const getRSSMarketingString = (href, campaignType) =>
- campaignType === 'RSS' ? buildRSSMarketingString(href) : [];
-
-export const getAffiliateMarketingString = href =>
- buildMarketingString([
- {
- description: 'affiliate campaign prefix',
- value: 'al',
- wrap: false,
- },
- {
- description: 'at_campaign field',
- value: getMarketingUrlParam(href, 'at_campaign'),
- wrap: false,
- },
- {
- description: 'at_type field',
- value: getMarketingUrlParam(href, 'at_type'),
- wrap: true,
- },
- {
- description: 'at_identifier field',
- value: getMarketingUrlParam(href, 'at_identifier'),
- wrap: true,
- },
- {
- description: 'at_format field',
- value: getMarketingUrlParam(href, 'at_format'),
- wrap: true,
- },
- {
- description: 'at_creation field',
- value: getMarketingUrlParam(href, 'at_creation'),
- wrap: true,
- },
- {
- description: 'at_variant field',
- value: getMarketingUrlParam(href, 'at_variant'),
- wrap: true,
- },
- ]);
-
-export const getSLMarketingString = href =>
- buildMarketingString([
- {
- description: 'sponsored links campaign prefix',
- value: 'SEC',
- wrap: false,
- },
- {
- description: 'at_campaign field',
- value: getMarketingUrlParam(href, 'at_campaign'),
- wrap: false,
- },
- {
- description: 'at_platform field',
- value: getMarketingUrlParam(href, 'at_platform'),
- wrap: true,
- },
- {
- description: 'at_creation field',
- value: getMarketingUrlParam(href, 'at_creation'),
- wrap: true,
- },
- {
- description: 'at_variant field',
- value: getMarketingUrlParam(href, 'at_variant'),
- wrap: true,
- },
- {
- description: 'at_network field',
- value:
- {
- search: 'F=S',
- content: 'F=C',
- }[getMarketingUrlParam(href, 'at_network')] || '',
- wrap: false,
- },
- {
- description: 'at_term field',
- value: getMarketingUrlParam(href, 'at_term'),
- wrap: true,
- },
- ]);
-
-export const getEmailMarketingString = href =>
- buildMarketingString([
- {
- description:
- 'email campaign prefix depending on value of at_emailtype param',
- value:
- {
- acquisition: 'EREC',
- retention: 'EPR',
- promotion: 'ES',
- }[getMarketingUrlParam(href, 'at_emailtype')] || '',
- wrap: false,
- },
- {
- description: 'at_campaign field',
- value: getMarketingUrlParam(href, 'at_campaign'),
- wrap: false,
- },
- {
- description: 'at_creation field',
- value: getMarketingUrlParam(href, 'at_creation'),
- wrap: true,
- },
- {
- description: 'at_send_date field',
- value: getMarketingUrlParam(href, 'at_send_date'),
- wrap: false,
- },
- {
- description: 'at_link field',
- value: getMarketingUrlParam(href, 'at_link'),
- wrap: true,
- },
- {
- description: 'at_recipient_id + @ + at_recipient_list field',
- value: `${getMarketingUrlParam(
- href,
- 'at_recipient_id',
- )}@${getMarketingUrlParam(href, 'at_recipient_list')}`,
- wrap: false,
- },
- ]);
-
-export const getDisplayMarketingString = href =>
- buildMarketingString([
- {
- description: 'display campaign prefix',
- value: 'AD',
- wrap: false,
- },
- {
- description: 'at_campaign field',
- value: getMarketingUrlParam(href, 'at_campaign'),
- wrap: false,
- },
- {
- description: 'at_creation field',
- value: getMarketingUrlParam(href, 'at_creation'),
- wrap: true,
- },
- {
- description: 'at_variant field',
- value: getMarketingUrlParam(href, 'at_variant'),
- wrap: true,
- },
- {
- description: 'at_format field',
- value: getMarketingUrlParam(href, 'at_format'),
- wrap: true,
- },
- {
- description: 'blank value (-)',
- value: '',
- wrap: false,
- },
- {
- description: 'at_general_placement field',
- value: getMarketingUrlParam(href, 'at_general_placement'),
- wrap: true,
- },
- {
- description: 'at_detail_placement field',
- value: getMarketingUrlParam(href, 'at_detail_placement'),
- wrap: true,
- },
- ]);
-
-export const getCustomMarketingString = href =>
- buildMarketingString([
- {
- description: 'custom campaign prefix',
- value: `CS${getMarketingUrlParam(href, 'at_medium').replace(
- 'custom',
- '',
- )}`,
- wrap: false,
- },
- {
- description: 'at_campaign field',
- value: getMarketingUrlParam(href, 'at_campaign'),
- wrap: false,
- },
- {
- description: 'at_custom1 field',
- value: getMarketingUrlParam(href, 'at_custom1'),
- wrap: true,
- },
- {
- description: 'at_custom2 field',
- value: getMarketingUrlParam(href, 'at_custom2'),
- wrap: true,
- },
- {
- description: 'at_custom_3 field',
- value: getMarketingUrlParam(href, 'at_custom3'),
- wrap: true,
- },
- {
- description: 'at_custom_4 field',
- value: getMarketingUrlParam(href, 'at_custom4'),
- wrap: true,
- },
- ]);
-
-export const getXtorMarketingString = href => {
- const field = 'xtor';
-
- const queryWithParams = getQueryParamsFromURL(href);
-
- return queryWithParams[field] || null;
-};
-
-export const getATIMarketingString = (href, campaignType) => {
- if (!campaignType) return null;
-
- const supportedCampaignMappings = {
- affiliate: () => getAffiliateMarketingString(href),
- sl: () => getSLMarketingString(href),
- email: () => getEmailMarketingString(href),
- display: () => getDisplayMarketingString(href),
- custom: () => getCustomMarketingString(href),
- XTOR: () => getXtorMarketingString(href),
- };
-
- const isSupportedCampaign = campaignMapping =>
- campaignType.startsWith(campaignMapping);
-
- const selectedCampaignType = Object.keys(supportedCampaignMappings).find(
- campaignMapping => isSupportedCampaign(campaignMapping),
- );
-
- return supportedCampaignMappings[selectedCampaignType]
- ? supportedCampaignMappings[selectedCampaignType]()
- : null;
-};
-
export const LIBRARY_VERSION = 'simorgh';
export const onOnionTld = () =>
diff --git a/src/app/lib/analyticsUtils/sendBeacon/index.test.ts b/src/app/lib/analyticsUtils/sendBeacon/index.test.ts
index 5187d7ffdde..8f00ca37127 100644
--- a/src/app/lib/analyticsUtils/sendBeacon/index.test.ts
+++ b/src/app/lib/analyticsUtils/sendBeacon/index.test.ts
@@ -2,10 +2,10 @@
import loggerMock from '#testHelpers/loggerMock';
import { ATI_LOGGING_ERROR } from '#app/lib/logger.const';
import { ReverbBeaconConfig } from '#app/components/ATIAnalytics/types';
+import { waitFor } from '#app/components/react-testing-library-with-providers';
import sendBeacon from './index';
import * as onClient from '../../utilities/onClient';
-let fetchResponse: Promise;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let isOnClient: any;
@@ -26,29 +26,12 @@ jest.spyOn(onClient, 'default').mockImplementation(() => isOnClient);
describe('sendBeacon', () => {
beforeEach(() => {
isOnClient = true;
- (fetch as jest.Mock).mockImplementation(() => fetchResponse);
});
afterEach(() => {
jest.clearAllMocks();
});
- it(`should fetch`, () => {
- sendBeacon('https://foobar.com');
-
- expect(fetch).toHaveBeenCalledWith('https://foobar.com', {
- credentials: 'include',
- });
- });
-
- it(`should not fetch when not on client`, () => {
- isOnClient = false;
-
- sendBeacon('https://foobar.com');
-
- expect(fetch).not.toHaveBeenCalled();
- });
-
describe('Reverb', () => {
const reverbConfig = {
params: {
@@ -110,21 +93,14 @@ describe('sendBeacon', () => {
},
} as unknown as ReverbBeaconConfig;
- // Simulates reverbBeaconConfig set to null in ATIAnalytics and sendEventBeacon
- // in the event useReverb resolves to 'false'
- const reverbConfigWhenReverbIsDisabled = null;
-
it('should call Reverb viewEvent if Reverb config is passed', async () => {
- await sendBeacon('https://foobar.com', reverbConfig);
+ await sendBeacon(reverbConfig);
expect(reverbMock.viewEvent).toHaveBeenCalledTimes(1);
});
it('should call Reverb userActionEvent if Reverb config is passed for a component view event', async () => {
- await sendBeacon(
- 'https://foobar.com',
- reverbViewabilityConfigComponentView,
- );
+ await sendBeacon(reverbViewabilityConfigComponentView);
expect(reverbMock.userActionEvent).toHaveBeenCalledTimes(1);
expect(reverbMock.userActionEvent).toHaveBeenCalledWith(
@@ -151,10 +127,7 @@ describe('sendBeacon', () => {
});
it('should call Reverb userActionEvent if Reverb config is passed for a component click event', async () => {
- await sendBeacon(
- 'https://foobar.com',
- reverbViewabilityConfigComponentClick,
- );
+ await sendBeacon(reverbViewabilityConfigComponentClick);
expect(reverbMock.userActionEvent).toHaveBeenCalledTimes(1);
expect(reverbMock.userActionEvent).toHaveBeenCalledWith(
@@ -180,29 +153,53 @@ describe('sendBeacon', () => {
);
});
- it('should not call Reverb viewEvent if Reverb is not enabled for a service', async () => {
- await sendBeacon('https://foobar.com', reverbConfigWhenReverbIsDisabled);
+ it(`should not call Reverb when not on client`, async () => {
+ isOnClient = false;
+
+ await sendBeacon(reverbConfig);
expect(reverbMock.viewEvent).not.toHaveBeenCalled();
});
+ });
- it('should not call "fetch" if Reverb config is passed', async () => {
- await sendBeacon('https://foobar.com', reverbConfig);
+ describe('Error Handling', () => {
+ const error: Error = new Error('An error');
- expect(fetch).not.toHaveBeenCalled();
- });
- });
+ const reverbConfig = {
+ params: {
+ page: 'page',
+ user: '1234-5678',
+ },
+ eventDetails: {
+ eventName: 'pageView',
+ },
+ } as unknown as ReverbBeaconConfig;
- describe('when the fetch fails', () => {
- let error: Error;
+ it(`should send error to the logger when Reverb fails to load`, async () => {
+ // eslint-disable-next-line no-underscore-dangle
+ window.__reverb = {
+ __reverbLoadedPromise: Promise.reject(error),
+ };
- beforeEach(() => {
- error = new Error('An error');
- fetchResponse = Promise.reject(error);
+ await sendBeacon(reverbConfig);
+
+ expect(loggerMock.error).toHaveBeenCalledWith(ATI_LOGGING_ERROR, {
+ error: 'Failed to load reverb. No event sent',
+ });
});
- it(`should send error to logger`, async () => {
- await sendBeacon('https://foobar.com');
+ it(`should send error to the logger when viewEvent fails`, async () => {
+ const errorReverbMock = {
+ ...reverbMock,
+ viewEvent: jest.fn(() => Promise.reject(error)),
+ };
+
+ // eslint-disable-next-line no-underscore-dangle
+ window.__reverb = {
+ __reverbLoadedPromise: Promise.resolve(errorReverbMock),
+ };
+
+ await waitFor(() => sendBeacon(reverbConfig));
expect(loggerMock.error).toHaveBeenCalledWith(ATI_LOGGING_ERROR, {
error,
diff --git a/src/app/lib/analyticsUtils/sendBeacon/index.ts b/src/app/lib/analyticsUtils/sendBeacon/index.ts
index 40b792339f0..c1bdfe56b56 100644
--- a/src/app/lib/analyticsUtils/sendBeacon/index.ts
+++ b/src/app/lib/analyticsUtils/sendBeacon/index.ts
@@ -69,7 +69,7 @@ const reverbPageViews = async ({
}: {
reverbInstance: ReverbClient;
}) => {
- reverbInstance.viewEvent();
+ return reverbInstance.viewEvent();
};
type ReverbComponentTrackingProps = {
@@ -115,7 +115,7 @@ const callReverb = async (eventDetails: ReverbEventDetails) => {
const { eventName } = eventDetails;
// eslint-disable-next-line no-underscore-dangle
- window.__reverb.__reverbLoadedPromise.then(
+ return window.__reverb.__reverbLoadedPromise.then(
async reverb => {
if (!reverb.isReady()) await reverb.initialise();
@@ -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,
diff --git a/src/app/lib/analyticsUtils/staticATITracking/constructATIUrl/index.ts b/src/app/lib/analyticsUtils/staticATITracking/constructATIUrl/index.ts
deleted file mode 100644
index 9e62071e888..00000000000
--- a/src/app/lib/analyticsUtils/staticATITracking/constructATIUrl/index.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { buildATIEventTrackUrl } from '#app/components/ATIAnalytics/atiUrl';
-import extractATITrackingProps from '#app/lib/analyticsUtils/extractATITrackingProps';
-import { EventTrackingProps } from '#app/lib/analyticsUtils/types';
-
-export default ({
- eventTrackingData,
- eventType,
- isStatic = false,
-}: EventTrackingProps & {
- isStatic?: boolean;
-}) => {
- const atiTrackingParams = extractATITrackingProps({
- eventTrackingData,
- eventType,
- });
- return buildATIEventTrackUrl({ ...atiTrackingParams, isStatic });
-};
diff --git a/src/app/lib/analyticsUtils/staticATITracking/processClientDeviceAndSendStaticBeacon/index.client.test.ts b/src/app/lib/analyticsUtils/staticATITracking/processClientDeviceAndSendStaticBeacon/index.client.test.ts
index b578ea81c02..c381486a3d5 100644
--- a/src/app/lib/analyticsUtils/staticATITracking/processClientDeviceAndSendStaticBeacon/index.client.test.ts
+++ b/src/app/lib/analyticsUtils/staticATITracking/processClientDeviceAndSendStaticBeacon/index.client.test.ts
@@ -123,23 +123,7 @@ describe('addProcessClientDeviceAndSendStaticBeaconToWindow script', () => {
it.each([
{
title:
- 'Prioritises ATI url, when an ATI url is provided and a reverb url is not',
- atiUrl: 'https://logws1363.ati-host.net/?',
- reverbUrl: undefined,
- expectedParsedParams: {
- idclient: 'userCookieId',
- hl: `${testHour}x${testMinute}x${testSecond}`,
- lng: 'en-GB',
- r: '100x400x24x24',
- re: '4060x1080',
- app_type: 'lite',
- ref: 'https://www.bbc.com',
- },
- },
- {
- title:
- 'Prioritises the reverb url, when both an ATI url and reverb url is provided - Reverb',
- atiUrl: 'https://logws1363.ati-host.net/?',
+ 'Triggers the ATI/Piano request using the reverb url, when the reverb url is provided - Reverb',
reverbUrl:
'https://a1.api.bbc.co.uk/hit.xiti?idclient={idclient}&s=598343&s2=69&p=persian.articles.c4vlle3q337o.page&r={screenResolutionColourDepth}&re={browserViewportResolution}&hl={timestamp}&lng={language}&x1=[urn%3Abbc%3Aoptimo%3Aasset%3Ac4vlle3q337o]&x2=[lite]&x3=[news-persian]&x4=[fa]&x5=[http%25253A%25252F%25252Flocalhost%25253A7080%25252Fpersian%25252Farticles%25252Fc4vlle3q337o]&x6=[{referrer}]&x7=[article]&x8=[simorgh]&x9=[%D9%BE%D9%87%D9%BE%D8%A7%D8%AF%DB%8C%2520%DA%A9%D9%87%2520%D8%A8%D8%B1%D8%A7%DB%8C%D8%AA%D8%A7%D9%86%2520%D9%82%D9%87%D9%88%D9%87%2520%D9%85%DB%8C%E2%80%8C%D8%A2%D9%88%D8%B1%D8%AF]&x11=[2019-05-28T13%3A42%3A44.996Z]&x12=[2019-07-23T15%3A47%3A11.893Z]&app_type=lite&ref={referrer}',
expectedParsedParams: {
@@ -156,7 +140,6 @@ describe('addProcessClientDeviceAndSendStaticBeaconToWindow script', () => {
{
title:
'Calls sendStaticBeacon() with the event parameter formatted for the viewability model - Reverb',
- atiUrl: 'https://logws1363.ati-host.net/?',
reverbUrl:
'https://logws1363.ati-host.net/hit.xiti?idclient={idclient}&s=598343&r={screenResolutionColourDepth}&re={browserViewportResolution}&hl={timestamp}&ts={epochTimestamp}&lng={language}&x6=[{referrer}]&app_type=lite&ref={referrer}&app_name=news-gahuza&language=rw&content_type=article&events=%5B%7B%22name%22%3A%22viewability.view%22%2C%22data%22%3A%7B%22item%22%3A%7B%22name%22%3A%22scrollable-navigation%22%2C%22link%22%3A%22{forwardingLink}%22%7D%2C%22event%22%3A%7B%22category%22%3A%22viewability%22%2C%22action%22%3A%22view%22%7D%2C%22group%22%3A%7B%22name%22%3A%22article%22%7D%2C%22user%22%3A%7B%22id%22%3Anull%7D%2C%22app%22%3A%7B%22type%22%3A%22lite%22%2C%22name%22%3A%22news-gahuza%22%7D%7D%7D%5D&context=%5B%7B%22data%22%3A%7B%22page%22%3A%7B%22%24%22%3A%22gahuza.articles.cy4849j0jyzo.page%22%7D%7D%7D%5D',
expectedParsedParams: {
@@ -164,7 +147,7 @@ describe('addProcessClientDeviceAndSendStaticBeaconToWindow script', () => {
s: '598343',
r: '100x400x24x24',
re: '4060x1080',
- hl: '16x30x2',
+ hl: `${testHour}x${testMinute}x${testSecond}`,
ts: '1731515402000',
lng: 'en-GB',
x6: '[https://www.bbc.com]',
@@ -179,7 +162,7 @@ describe('addProcessClientDeviceAndSendStaticBeaconToWindow script', () => {
'[{"data":{"page":{"$":"gahuza.articles.cy4849j0jyzo.page"}}}]',
},
},
- ])('$title', ({ atiUrl, reverbUrl, expectedParsedParams }) => {
+ ])('$title', ({ reverbUrl, expectedParsedParams }) => {
document.cookie =
'atuserid={"val":"userCookieId"}; path=/; max-age=397; Secure;';
@@ -195,7 +178,7 @@ describe('addProcessClientDeviceAndSendStaticBeaconToWindow script', () => {
jest.spyOn(window, 'innerWidth', 'get').mockReturnValue(4060);
jest.spyOn(window, 'innerHeight', 'get').mockReturnValue(1080);
- window.processClientDeviceAndSendStaticBeacon({ atiUrl, reverbUrl });
+ window.processClientDeviceAndSendStaticBeacon({ reverbUrl });
const callParam = (window.sendStaticBeacon as jest.Mock).mock.calls[0][0];
@@ -205,6 +188,31 @@ describe('addProcessClientDeviceAndSendStaticBeaconToWindow script', () => {
expect(parsedTrackingParams).toMatchObject(expectedParsedParams);
});
+ it('Does not call sendStaticBeacon() when no reverb url is provided', () => {
+ const reverbUrl = undefined;
+ document.cookie =
+ 'atuserid={"val":"userCookieId"}; path=/; max-age=397; Secure;';
+
+ Object.defineProperty(document, 'referrer', {
+ value: 'https://www.bbc.com',
+ });
+
+ jest.replaceProperty(window.screen, 'width', 100);
+ jest.replaceProperty(window.screen, 'height', 400);
+ jest.replaceProperty(window.screen, 'colorDepth', 24);
+ jest.replaceProperty(window.screen, 'pixelDepth', 24);
+
+ jest.spyOn(window, 'innerWidth', 'get').mockReturnValue(4060);
+ jest.spyOn(window, 'innerHeight', 'get').mockReturnValue(1080);
+
+ window.processClientDeviceAndSendStaticBeacon({ reverbUrl });
+
+ const sendStaticBeaconCalls = (window.sendStaticBeacon as jest.Mock).mock
+ .calls;
+
+ expect(sendStaticBeaconCalls.length).toBe(0);
+ });
+
it.each([
{
type: 'reverb',
@@ -212,12 +220,6 @@ describe('addProcessClientDeviceAndSendStaticBeaconToWindow script', () => {
reverbUrl: 'https://logws1363.xiti.net/?',
},
},
- {
- type: 'ati',
- sendBeaconProps: {
- atiUrl: 'https://logws1363.ati-host.net/?',
- },
- },
])(
'Adds marketing parameters to the beacon URL - $type',
({ sendBeaconProps }) => {
@@ -262,12 +264,6 @@ describe('addProcessClientDeviceAndSendStaticBeaconToWindow script', () => {
reverbUrl: 'https://logws1363.xiti.net/?',
},
},
- {
- type: 'ati',
- sendBeaconProps: {
- atiUrl: 'https://logws1363.ati-host.net/?',
- },
- },
])(
'Does not add garbage params as marketing parameters to the beacon URL - $type',
({ sendBeaconProps }) => {
@@ -311,13 +307,15 @@ describe('addProcessClientDeviceAndSendStaticBeaconToWindow script', () => {
window.innerHeight = 1080;
window.processClientDeviceAndSendStaticBeacon({
- atiUrl: 'https://logws1363.ati-host.net/?',
+ reverbUrl:
+ 'https://a1.api.bbc.co.uk/hit.xiti?idclient={idclient}&s=598343&s2=69&p=persian.articles.c4vlle3q337o.page&r={screenResolutionColourDepth}&re={browserViewportResolution}&hl={timestamp}&lng={language}&x1=[urn%3Abbc%3Aoptimo%3Aasset%3Ac4vlle3q337o]&x2=[lite]&x3=[news-persian]&x4=[fa]&x5=[http%25253A%25252F%25252Flocalhost%25253A7080%25252Fpersian%25252Farticles%25252Fc4vlle3q337o]&x6=[{referrer}]&x7=[article]&x8=[simorgh]&x9=[%D9%BE%D9%87%D9%BE%D8%A7%D8%AF%DB%8C%2520%DA%A9%D9%87%2520%D8%A8%D8%B1%D8%A7%DB%8C%D8%AA%D8%A7%D9%86%2520%D9%82%D9%87%D9%88%D9%87%2520%D9%85%DB%8C%E2%80%8C%D8%A2%D9%88%D8%B1%D8%AF]&x11=[2019-05-28T13%3A42%3A44.996Z]&x12=[2019-07-23T15%3A47%3A11.893Z]&app_type=lite&ref={referrer}',
});
const callParam = (window.sendStaticBeacon as jest.Mock).mock.calls[0][0];
- const parsedATIParams = Object.fromEntries(
- new URLSearchParams(callParam),
- );
+
+ const { searchParams } = new URL(callParam);
+ const parsedATIParams = Object.fromEntries(searchParams);
+
expect(parsedATIParams).toMatchObject({
idclient: 'userCookieId',
hl: `${testHour}x${testMinute}x${testSecond}`,
diff --git a/src/app/lib/analyticsUtils/staticATITracking/processClientDeviceAndSendStaticBeacon/index.ts b/src/app/lib/analyticsUtils/staticATITracking/processClientDeviceAndSendStaticBeacon/index.ts
index a5d7a6e7a96..6e6722b426d 100644
--- a/src/app/lib/analyticsUtils/staticATITracking/processClientDeviceAndSendStaticBeacon/index.ts
+++ b/src/app/lib/analyticsUtils/staticATITracking/processClientDeviceAndSendStaticBeacon/index.ts
@@ -1,7 +1,6 @@
/* istanbul ignore next */
export const addProcessClientDeviceAndSendStaticBeaconToWindow = () => {
window.processClientDeviceAndSendStaticBeacon = ({
- atiUrl,
reverbUrl,
forwardingUrl = '',
}) => {
@@ -87,48 +86,19 @@ export const addProcessClientDeviceAndSendStaticBeaconToWindow = () => {
const searchParams = new URLSearchParams(window.location.search);
searchParams.forEach((value, key) => {
- if (key.startsWith('utm_') || key.startsWith('at_')) {
+ if (
+ key.startsWith('utm_') ||
+ key.startsWith('at_') ||
+ key.startsWith('xtor')
+ ) {
processedReverbUrl +=
- `&${encodeURIComponent(key)}=${encodeURIComponent(value)}`.replace(
- 'at_',
- 'src_',
- );
+ `&${encodeURIComponent(key)}=${encodeURIComponent(value)}`
+ .replace('at_', 'src_')
+ .replace('xtor', 'xto');
}
});
window.sendStaticBeacon(processedReverbUrl);
- } else if (atiUrl) {
- const containsMarketingAtUtcParams = window.location.search.length;
- if (isLiteSite && containsMarketingAtUtcParams) {
- const kvpairs: Record = window.location.search
- .substring(1)
- .split('&')
- .map((param): [string, string] => {
- const pieces = param.split('=');
- return [
- decodeURIComponent(pieces[0]),
- decodeURIComponent(pieces[1]),
- ];
- })
- .reduce>((values, kv) => {
- // eslint-disable-next-line no-param-reassign, prefer-destructuring
- values[kv[0]] = kv[1];
- return values;
- }, {});
-
- Object.keys(kvpairs).forEach(keyName => {
- if (keyName.indexOf('at_') === 0) {
- params[keyName.replace('at_', 'src_')] = kvpairs[keyName];
- } else if (keyName.indexOf('utm_') === 0) {
- params[keyName] = kvpairs[keyName];
- }
- });
- }
-
- const paramValues = Object.keys(params)
- .map(key => `${key}=${params[key]}`)
- .join('&');
- window.sendStaticBeacon(`${atiUrl}&${paramValues}`);
}
};
};
diff --git a/src/app/lib/config/services/afaanoromoo.ts b/src/app/lib/config/services/afaanoromoo.ts
index 4b471a5d380..c5975243b67 100644
--- a/src/app/lib/config/services/afaanoromoo.ts
+++ b/src/app/lib/config/services/afaanoromoo.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-afaanoromoo',
atiAnalyticsProducerId: '2',
atiAnalyticsProducerName: 'AFAAN_OROMOO',
- useReverb: true,
chartbeatDomain: 'afaanoromoo.bbc.co.uk',
brandName: 'BBC News Afaan Oromoo',
product: 'BBC News',
diff --git a/src/app/lib/config/services/afrique.ts b/src/app/lib/config/services/afrique.ts
index 3009efe3537..9b5e63eb040 100644
--- a/src/app/lib/config/services/afrique.ts
+++ b/src/app/lib/config/services/afrique.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-afrique',
atiAnalyticsProducerId: '3',
atiAnalyticsProducerName: 'AFRIQUE',
- useReverb: true,
chartbeatDomain: 'afrique.bbc.co.uk',
brandName: 'BBC News Afrique',
product: 'BBC News',
diff --git a/src/app/lib/config/services/amharic.ts b/src/app/lib/config/services/amharic.ts
index 0a71e0e36c8..eec5468f0cd 100644
--- a/src/app/lib/config/services/amharic.ts
+++ b/src/app/lib/config/services/amharic.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-amharic',
atiAnalyticsProducerId: '4',
atiAnalyticsProducerName: 'AMHARIC',
- useReverb: true,
chartbeatDomain: 'amharic.bbc.co.uk',
brandName: 'BBC News አማርኛ',
product: 'BBC News',
diff --git a/src/app/lib/config/services/arabic.ts b/src/app/lib/config/services/arabic.ts
index 152f33c20d1..c9b129f7140 100644
--- a/src/app/lib/config/services/arabic.ts
+++ b/src/app/lib/config/services/arabic.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-arabic',
atiAnalyticsProducerId: '5',
atiAnalyticsProducerName: 'ARABIC',
- useReverb: true,
chartbeatDomain: 'arabic.bbc.co.uk',
brandName: 'BBC News عربي',
product: 'BBC News',
diff --git a/src/app/lib/config/services/azeri.ts b/src/app/lib/config/services/azeri.ts
index 6b386b1b478..72c0213d099 100644
--- a/src/app/lib/config/services/azeri.ts
+++ b/src/app/lib/config/services/azeri.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-azeri',
atiAnalyticsProducerId: '6',
atiAnalyticsProducerName: 'AZERI',
- useReverb: true,
chartbeatDomain: 'azeri.bbc.co.uk',
brandName: 'BBC News Azərbaycanca',
product: 'BBC News',
diff --git a/src/app/lib/config/services/bengali.ts b/src/app/lib/config/services/bengali.ts
index ce16a0c63c1..44e2b4e72e0 100644
--- a/src/app/lib/config/services/bengali.ts
+++ b/src/app/lib/config/services/bengali.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-bengali',
atiAnalyticsProducerId: '31',
atiAnalyticsProducerName: 'BENGALI',
- useReverb: true,
chartbeatDomain: 'bengali.bbc.co.uk',
brandName: 'BBC News বাংলা',
product: 'BBC News',
diff --git a/src/app/lib/config/services/burmese.ts b/src/app/lib/config/services/burmese.ts
index 70b9cf55ccb..77966a31a97 100644
--- a/src/app/lib/config/services/burmese.ts
+++ b/src/app/lib/config/services/burmese.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-burmese',
atiAnalyticsProducerId: '35',
atiAnalyticsProducerName: 'BURMESE',
- useReverb: true,
chartbeatDomain: 'burmese.bbc.co.uk',
brandName: 'BBC News မြန်မာ',
product: 'BBC News',
diff --git a/src/app/lib/config/services/cymrufyw.ts b/src/app/lib/config/services/cymrufyw.ts
index d6eac8af608..727a1bc5392 100644
--- a/src/app/lib/config/services/cymrufyw.ts
+++ b/src/app/lib/config/services/cymrufyw.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-cymrufyw',
atiAnalyticsProducerId: '100',
atiAnalyticsProducerName: 'WALES',
- useReverb: true,
chartbeatDomain: 'cymrufyw.bbc.co.uk',
brandName: 'BBC Cymru Fyw',
product: 'BBC News',
diff --git a/src/app/lib/config/services/dari.ts b/src/app/lib/config/services/dari.ts
index 3a68b2224c6..fc93e82c6fd 100644
--- a/src/app/lib/config/services/dari.ts
+++ b/src/app/lib/config/services/dari.ts
@@ -14,7 +14,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-dari',
atiAnalyticsProducerId: '142',
atiAnalyticsProducerName: 'DARI',
- useReverb: true,
chartbeatDomain: 'dari.bbc.co.uk',
brandName: 'BBC News دری',
serviceLocalizedName: 'دری',
diff --git a/src/app/lib/config/services/gahuza.ts b/src/app/lib/config/services/gahuza.ts
index ca865ce7966..e7e9393c66f 100644
--- a/src/app/lib/config/services/gahuza.ts
+++ b/src/app/lib/config/services/gahuza.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-gahuza',
atiAnalyticsProducerId: '40',
atiAnalyticsProducerName: 'GAHUZA',
- useReverb: true,
chartbeatDomain: 'gahuza.bbc.co.uk',
brandName: 'BBC News Gahuza',
product: 'BBC News',
diff --git a/src/app/lib/config/services/gujarati.ts b/src/app/lib/config/services/gujarati.ts
index 3fedc18e9db..996cea95a33 100644
--- a/src/app/lib/config/services/gujarati.ts
+++ b/src/app/lib/config/services/gujarati.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-gujarati',
atiAnalyticsProducerId: '50',
atiAnalyticsProducerName: 'GUJARATI',
- useReverb: true,
chartbeatDomain: 'gujarati.bbc.co.uk',
brandName: 'BBC News ગુજરાતી',
product: 'BBC News',
diff --git a/src/app/lib/config/services/hausa.ts b/src/app/lib/config/services/hausa.ts
index 95725d40889..274139bea7e 100644
--- a/src/app/lib/config/services/hausa.ts
+++ b/src/app/lib/config/services/hausa.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-hausa',
atiAnalyticsProducerId: '51',
atiAnalyticsProducerName: 'HAUSA',
- useReverb: true,
chartbeatDomain: 'hausa.bbc.co.uk',
brandName: 'BBC News Hausa',
product: 'BBC News',
diff --git a/src/app/lib/config/services/hindi.ts b/src/app/lib/config/services/hindi.ts
index a509490bcdf..9750859fa70 100644
--- a/src/app/lib/config/services/hindi.ts
+++ b/src/app/lib/config/services/hindi.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-hindi',
atiAnalyticsProducerId: '52',
atiAnalyticsProducerName: 'HINDI',
- useReverb: true,
chartbeatDomain: 'hindi.bbc.co.uk',
brandName: 'BBC News हिंदी',
product: 'BBC News',
diff --git a/src/app/lib/config/services/igbo.ts b/src/app/lib/config/services/igbo.ts
index 22915e25751..8d8be4cf2a0 100644
--- a/src/app/lib/config/services/igbo.ts
+++ b/src/app/lib/config/services/igbo.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-igbo',
atiAnalyticsProducerId: '53',
atiAnalyticsProducerName: 'IGBO',
- useReverb: true,
chartbeatDomain: 'igbo.bbc.co.uk',
brandName: 'BBC News Ìgbò',
product: 'BBC News',
diff --git a/src/app/lib/config/services/indonesia.ts b/src/app/lib/config/services/indonesia.ts
index b8fd9655542..4eb6e46de4b 100644
--- a/src/app/lib/config/services/indonesia.ts
+++ b/src/app/lib/config/services/indonesia.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-indonesia',
atiAnalyticsProducerId: '54',
atiAnalyticsProducerName: 'INDONESIAN',
- useReverb: true,
chartbeatDomain: 'indonesian.bbc.co.uk', // this is meant to be different to the service name
brandName: 'BBC News Indonesia',
product: 'BBC News',
diff --git a/src/app/lib/config/services/japanese.ts b/src/app/lib/config/services/japanese.ts
index 88e465cb1f5..9c294c6b7ec 100644
--- a/src/app/lib/config/services/japanese.ts
+++ b/src/app/lib/config/services/japanese.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-japanese',
atiAnalyticsProducerId: '56',
atiAnalyticsProducerName: 'JAPANESE',
- useReverb: true,
chartbeatDomain: 'japanese.bbc.co.uk',
brandName: 'BBCニュース',
product: 'BBC News',
diff --git a/src/app/lib/config/services/korean.ts b/src/app/lib/config/services/korean.ts
index 4ee0d4bb6ef..ae538d771a9 100644
--- a/src/app/lib/config/services/korean.ts
+++ b/src/app/lib/config/services/korean.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-korean',
atiAnalyticsProducerId: '57',
atiAnalyticsProducerName: 'KOREAN',
- useReverb: true,
chartbeatDomain: 'korean.bbc.co.uk',
brandName: 'BBC News 코리아',
product: 'BBC News',
diff --git a/src/app/lib/config/services/kyrgyz.ts b/src/app/lib/config/services/kyrgyz.ts
index ced60d5ba24..62a3cbe8fdb 100644
--- a/src/app/lib/config/services/kyrgyz.ts
+++ b/src/app/lib/config/services/kyrgyz.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-kyrgyz',
atiAnalyticsProducerId: '58',
atiAnalyticsProducerName: 'KYRGYZ',
- useReverb: true,
chartbeatDomain: 'kyrgyz.bbc.co.uk',
brandName: 'BBC News Кыргыз Кызматы',
product: 'BBC News',
diff --git a/src/app/lib/config/services/magyarul.ts b/src/app/lib/config/services/magyarul.ts
index 35245033cd8..fa8fdbcb6f0 100644
--- a/src/app/lib/config/services/magyarul.ts
+++ b/src/app/lib/config/services/magyarul.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-magyarul',
atiAnalyticsProducerId: '134',
atiAnalyticsProducerName: 'HUNGARIAN',
- useReverb: true,
chartbeatDomain: 'magyarul.bbc.co.uk',
brandName: 'BBC News Magyarul',
product: 'BBC News',
diff --git a/src/app/lib/config/services/marathi.ts b/src/app/lib/config/services/marathi.ts
index 0b8b5072d21..c40ad68934a 100644
--- a/src/app/lib/config/services/marathi.ts
+++ b/src/app/lib/config/services/marathi.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-marathi',
atiAnalyticsProducerId: '59',
atiAnalyticsProducerName: 'MARATHI',
- useReverb: true,
chartbeatDomain: 'marathi.bbc.co.uk',
brandName: 'BBC News मराठी',
product: 'BBC News',
diff --git a/src/app/lib/config/services/mundo.ts b/src/app/lib/config/services/mundo.ts
index f4110f2bb9b..d0e40c58453 100644
--- a/src/app/lib/config/services/mundo.ts
+++ b/src/app/lib/config/services/mundo.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-mundo',
atiAnalyticsProducerId: '62',
atiAnalyticsProducerName: 'MUNDO',
- useReverb: true,
chartbeatDomain: 'mundo.bbc.co.uk',
brandName: 'BBC News Mundo',
product: 'BBC News',
diff --git a/src/app/lib/config/services/naidheachdan.ts b/src/app/lib/config/services/naidheachdan.ts
index 5e39105fae5..2dae6f0302b 100644
--- a/src/app/lib/config/services/naidheachdan.ts
+++ b/src/app/lib/config/services/naidheachdan.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-naidheachdan',
atiAnalyticsProducerId: '79',
atiAnalyticsProducerName: 'SCOTLAND',
- useReverb: true,
chartbeatDomain: 'bbc.co.uk',
brandName: 'BBC Naidheachdan',
product: 'BBC News',
diff --git a/src/app/lib/config/services/nepali.ts b/src/app/lib/config/services/nepali.ts
index 27f2667c3c3..46877c1f2f3 100644
--- a/src/app/lib/config/services/nepali.ts
+++ b/src/app/lib/config/services/nepali.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-nepali',
atiAnalyticsProducerId: '63',
atiAnalyticsProducerName: 'NEPALI',
- useReverb: true,
chartbeatDomain: 'nepali.bbc.co.uk',
brandName: 'BBC News नेपाली',
product: 'BBC News',
diff --git a/src/app/lib/config/services/news.ts b/src/app/lib/config/services/news.ts
index 413b092ea9c..f425711a7d6 100644
--- a/src/app/lib/config/services/news.ts
+++ b/src/app/lib/config/services/news.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news',
atiAnalyticsProducerId: '64',
atiAnalyticsProducerName: 'NEWS',
- useReverb: true,
chartbeatDomain: 'bbc.co.uk',
brandName: 'BBC News',
product: 'BBC News',
diff --git a/src/app/lib/config/services/newsround.ts b/src/app/lib/config/services/newsround.ts
index 0001b995425..280ac0e7a57 100644
--- a/src/app/lib/config/services/newsround.ts
+++ b/src/app/lib/config/services/newsround.ts
@@ -14,7 +14,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'newsround',
atiAnalyticsProducerId: '65',
atiAnalyticsProducerName: 'NEWSROUND',
- useReverb: true,
chartbeatDomain: 'bbc.co.uk',
brandName: 'CBBC Newsround',
product: 'CBBC Newsround',
diff --git a/src/app/lib/config/services/pashto.ts b/src/app/lib/config/services/pashto.ts
index 6a7616cba27..3fc83e5dbb6 100644
--- a/src/app/lib/config/services/pashto.ts
+++ b/src/app/lib/config/services/pashto.ts
@@ -15,7 +15,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-pashto',
atiAnalyticsProducerId: '68',
atiAnalyticsProducerName: 'PASHTO',
- useReverb: true,
brandName: 'BBC News پښتو',
chartbeatDomain: 'pashto.bbc.co.uk',
serviceLocalizedName: 'پښتو',
diff --git a/src/app/lib/config/services/persian.ts b/src/app/lib/config/services/persian.ts
index cb4bde8d072..318540772ff 100644
--- a/src/app/lib/config/services/persian.ts
+++ b/src/app/lib/config/services/persian.ts
@@ -15,7 +15,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-persian',
atiAnalyticsProducerId: '69',
atiAnalyticsProducerName: 'PERSIAN',
- useReverb: true,
chartbeatDomain: 'persian.bbc.co.uk',
brandName: 'BBC News فارسی',
serviceLocalizedName: 'فارسی',
diff --git a/src/app/lib/config/services/pidgin.ts b/src/app/lib/config/services/pidgin.ts
index 2dcfeeb045d..51ab1549231 100644
--- a/src/app/lib/config/services/pidgin.ts
+++ b/src/app/lib/config/services/pidgin.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-pidgin',
atiAnalyticsProducerId: '70',
atiAnalyticsProducerName: 'PIDGIN',
- useReverb: true,
chartbeatDomain: 'pidgin.bbc.co.uk',
brandName: 'BBC News Pidgin',
product: 'BBC News',
diff --git a/src/app/lib/config/services/polska.ts b/src/app/lib/config/services/polska.ts
index 7f4bf0597e9..e082a82f339 100644
--- a/src/app/lib/config/services/polska.ts
+++ b/src/app/lib/config/services/polska.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-polska',
atiAnalyticsProducerId: '135',
atiAnalyticsProducerName: 'POLISH',
- useReverb: true,
chartbeatDomain: 'polska.bbc.co.uk',
brandName: 'BBC News Polska',
product: 'BBC News',
diff --git a/src/app/lib/config/services/portuguese.ts b/src/app/lib/config/services/portuguese.ts
index 7c60c88e3cf..647c70ff64e 100644
--- a/src/app/lib/config/services/portuguese.ts
+++ b/src/app/lib/config/services/portuguese.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-portuguese',
atiAnalyticsProducerId: '33',
atiAnalyticsProducerName: 'BRASIL',
- useReverb: true,
chartbeatDomain: 'brasil.bbc.co.uk', // this is meant to be different to the service name
brandName: 'BBC News Brasil',
product: 'BBC News',
diff --git a/src/app/lib/config/services/punjabi.ts b/src/app/lib/config/services/punjabi.ts
index fb940e412fe..30129c4c844 100644
--- a/src/app/lib/config/services/punjabi.ts
+++ b/src/app/lib/config/services/punjabi.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-punjabi',
atiAnalyticsProducerId: '73',
atiAnalyticsProducerName: 'PUNJABI',
- useReverb: true,
chartbeatDomain: 'punjabi.bbc.co.uk',
brandName: 'BBC News ਪੰਜਾਬੀ',
product: 'BBC News',
diff --git a/src/app/lib/config/services/romania.ts b/src/app/lib/config/services/romania.ts
index ec163438eca..c26f767b07f 100644
--- a/src/app/lib/config/services/romania.ts
+++ b/src/app/lib/config/services/romania.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-romanian',
atiAnalyticsProducerId: '136',
atiAnalyticsProducerName: 'ROMANIAN',
- useReverb: true,
chartbeatDomain: 'romania.bbc.co.uk',
brandName: 'BBC News România',
product: 'BBC News',
diff --git a/src/app/lib/config/services/russian.ts b/src/app/lib/config/services/russian.ts
index 48d6c46d007..b577e8a57fb 100644
--- a/src/app/lib/config/services/russian.ts
+++ b/src/app/lib/config/services/russian.ts
@@ -119,7 +119,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-russian',
atiAnalyticsProducerId: '75',
atiAnalyticsProducerName: 'RUSSIAN',
- useReverb: true,
chartbeatDomain: 'russian.bbc.co.uk',
brandName: 'BBC News Русская служба',
product: 'BBC News',
diff --git a/src/app/lib/config/services/scotland.ts b/src/app/lib/config/services/scotland.ts
index d83e008affb..fcbff6d34cd 100644
--- a/src/app/lib/config/services/scotland.ts
+++ b/src/app/lib/config/services/scotland.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'scotland',
atiAnalyticsProducerId: '79',
atiAnalyticsProducerName: 'SCOTLAND',
- useReverb: true,
chartbeatDomain: 'bbc.co.uk',
brandName: 'BBC Scotland',
product: 'BBC Scotland',
diff --git a/src/app/lib/config/services/serbian.ts b/src/app/lib/config/services/serbian.ts
index 56997da323d..87a2bb0c66d 100644
--- a/src/app/lib/config/services/serbian.ts
+++ b/src/app/lib/config/services/serbian.ts
@@ -12,7 +12,6 @@ const baseServiceConfig = {
atiAnalyticsAppName: 'news-serbian',
atiAnalyticsProducerId: '81',
atiAnalyticsProducerName: 'SERBIAN',
- useReverb: true,
chartbeatDomain: 'serbian.bbc.co.uk',
product: 'BBC News',
defaultImage:
diff --git a/src/app/lib/config/services/sinhala.ts b/src/app/lib/config/services/sinhala.ts
index fbb789ade57..79347a400fa 100644
--- a/src/app/lib/config/services/sinhala.ts
+++ b/src/app/lib/config/services/sinhala.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-sinhala',
atiAnalyticsProducerId: '82',
atiAnalyticsProducerName: 'SINHALA',
- useReverb: true,
chartbeatDomain: 'sinhala.bbc.co.uk',
brandName: 'BBC News සිංහල',
product: 'BBC News',
diff --git a/src/app/lib/config/services/somali.ts b/src/app/lib/config/services/somali.ts
index 5d996027990..5078ed0806b 100644
--- a/src/app/lib/config/services/somali.ts
+++ b/src/app/lib/config/services/somali.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-somali',
atiAnalyticsProducerId: '83',
atiAnalyticsProducerName: 'SOMALI',
- useReverb: true,
chartbeatDomain: 'somali.bbc.co.uk',
brandName: 'BBC News Somali',
product: 'BBC News',
diff --git a/src/app/lib/config/services/sport.ts b/src/app/lib/config/services/sport.ts
index 8d5c893e248..484238bcec6 100644
--- a/src/app/lib/config/services/sport.ts
+++ b/src/app/lib/config/services/sport.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'sport',
atiAnalyticsProducerId: '85',
atiAnalyticsProducerName: 'SPORT',
- useReverb: true,
chartbeatDomain: 'bbc.co.uk',
brandName: 'BBC Sport',
product: 'BBC Sport',
diff --git a/src/app/lib/config/services/swahili.ts b/src/app/lib/config/services/swahili.ts
index b4082960a5b..6694e7aca96 100644
--- a/src/app/lib/config/services/swahili.ts
+++ b/src/app/lib/config/services/swahili.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-swahili',
atiAnalyticsProducerId: '86',
atiAnalyticsProducerName: 'SWAHILI',
- useReverb: true,
chartbeatDomain: 'swahili.bbc.co.uk',
brandName: 'BBC News Swahili',
product: 'BBC News',
diff --git a/src/app/lib/config/services/tamil.ts b/src/app/lib/config/services/tamil.ts
index 620fca14f3c..e103adeaff4 100644
--- a/src/app/lib/config/services/tamil.ts
+++ b/src/app/lib/config/services/tamil.ts
@@ -13,7 +13,7 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-tamil',
atiAnalyticsProducerId: '87',
atiAnalyticsProducerName: 'TAMIL',
- useReverb: true,
+
chartbeatDomain: 'tamil.bbc.co.uk',
brandName: 'BBC News தமிழ்',
product: 'BBC News',
diff --git a/src/app/lib/config/services/telugu.ts b/src/app/lib/config/services/telugu.ts
index 67293d30429..18178ef1f14 100644
--- a/src/app/lib/config/services/telugu.ts
+++ b/src/app/lib/config/services/telugu.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-telugu',
atiAnalyticsProducerId: '89',
atiAnalyticsProducerName: 'TELUGU',
- useReverb: true,
chartbeatDomain: 'telugu.bbc.co.uk',
brandName: 'BBC News తెలుగు',
product: 'BBC News',
diff --git a/src/app/lib/config/services/thai.ts b/src/app/lib/config/services/thai.ts
index 88de63c6c18..d900f562dd7 100644
--- a/src/app/lib/config/services/thai.ts
+++ b/src/app/lib/config/services/thai.ts
@@ -15,7 +15,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-thai',
atiAnalyticsProducerId: '90',
atiAnalyticsProducerName: 'THAI',
- useReverb: true,
chartbeatDomain: 'thai.bbc.co.uk',
brandName: 'BBC News ไทย',
product: 'BBC News',
diff --git a/src/app/lib/config/services/tigrinya.ts b/src/app/lib/config/services/tigrinya.ts
index ea91b922df1..d09ca3aade2 100644
--- a/src/app/lib/config/services/tigrinya.ts
+++ b/src/app/lib/config/services/tigrinya.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-tigrinya',
atiAnalyticsProducerId: '91',
atiAnalyticsProducerName: 'TIGRINYA',
- useReverb: true,
chartbeatDomain: 'tigrinya.bbc.co.uk',
brandName: 'BBC News ትግርኛ',
product: 'BBC News',
diff --git a/src/app/lib/config/services/turkce.ts b/src/app/lib/config/services/turkce.ts
index 277fbd87419..2556e964bcb 100644
--- a/src/app/lib/config/services/turkce.ts
+++ b/src/app/lib/config/services/turkce.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-turkce',
atiAnalyticsProducerId: '92',
atiAnalyticsProducerName: 'TURKISH',
- useReverb: true,
chartbeatDomain: 'turkish.bbc.co.uk', // this is meant to be different to the service name
brandName: 'BBC News Türkçe',
product: 'BBC News',
diff --git a/src/app/lib/config/services/ukchina.ts b/src/app/lib/config/services/ukchina.ts
index edcf67e82e6..8da37ddea57 100644
--- a/src/app/lib/config/services/ukchina.ts
+++ b/src/app/lib/config/services/ukchina.ts
@@ -12,7 +12,6 @@ const baseServiceConfig = {
atiAnalyticsAppName: 'news-ukchina',
atiAnalyticsProducerId: '93',
atiAnalyticsProducerName: 'UK_CHINA',
- useReverb: true,
chartbeatDomain: 'ukchina.bbc.co.uk',
brandName: 'BBC 英伦网',
product: 'BBC',
diff --git a/src/app/lib/config/services/ukrainian.ts b/src/app/lib/config/services/ukrainian.ts
index 9eb3613e266..c6afee07ea2 100644
--- a/src/app/lib/config/services/ukrainian.ts
+++ b/src/app/lib/config/services/ukrainian.ts
@@ -17,7 +17,6 @@ const baseServiceConfig = {
atiAnalyticsAppName: 'news-ukrainian',
atiAnalyticsProducerId: '94',
atiAnalyticsProducerName: 'UKRAINIAN',
- useReverb: true,
chartbeatDomain: 'ukrainian.bbc.co.uk',
brandName: 'BBC News Україна',
product: 'BBC News',
diff --git a/src/app/lib/config/services/urdu.ts b/src/app/lib/config/services/urdu.ts
index 473840edbc5..bcd46bd4c05 100644
--- a/src/app/lib/config/services/urdu.ts
+++ b/src/app/lib/config/services/urdu.ts
@@ -14,7 +14,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-urdu',
atiAnalyticsProducerId: '95',
atiAnalyticsProducerName: 'URDU',
- useReverb: true,
chartbeatDomain: 'urdu.bbc.co.uk',
brandName: 'BBC News اردو',
defaultImage:
diff --git a/src/app/lib/config/services/uzbek.ts b/src/app/lib/config/services/uzbek.ts
index 00ae156e606..d3fa3b98c8a 100644
--- a/src/app/lib/config/services/uzbek.ts
+++ b/src/app/lib/config/services/uzbek.ts
@@ -12,7 +12,6 @@ const baseServiceConfig = {
atiAnalyticsAppName: 'news-uzbek',
atiAnalyticsProducerId: '96',
atiAnalyticsProducerName: 'UZBEK',
- useReverb: true,
chartbeatDomain: 'uzbek.bbc.co.uk',
product: 'BBC News',
defaultImage:
diff --git a/src/app/lib/config/services/vietnamese.ts b/src/app/lib/config/services/vietnamese.ts
index 6880c889965..54c85ed3669 100644
--- a/src/app/lib/config/services/vietnamese.ts
+++ b/src/app/lib/config/services/vietnamese.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-vietnamese',
atiAnalyticsProducerId: '97',
atiAnalyticsProducerName: 'VIETNAMESE',
- useReverb: true,
chartbeatDomain: 'vietnamese.bbc.co.uk',
brandName: 'BBC News Tiếng Việt',
product: 'BBC News',
diff --git a/src/app/lib/config/services/ws.ts b/src/app/lib/config/services/ws.ts
index 076cb5b9822..1aeb8efd311 100644
--- a/src/app/lib/config/services/ws.ts
+++ b/src/app/lib/config/services/ws.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news',
atiAnalyticsProducerId: '30',
atiAnalyticsProducerName: 'BBC_WORLD_NEWS',
- useReverb: true,
chartbeatDomain: 'bbc.co.uk',
brandName: 'BBC World Service',
serviceLocalizedName: 'World Service',
diff --git a/src/app/lib/config/services/yoruba.ts b/src/app/lib/config/services/yoruba.ts
index 1ccacf6a12a..e414c9fbf03 100644
--- a/src/app/lib/config/services/yoruba.ts
+++ b/src/app/lib/config/services/yoruba.ts
@@ -13,7 +13,6 @@ export const service: DefaultServiceConfig = {
atiAnalyticsAppName: 'news-yoruba',
atiAnalyticsProducerId: '107',
atiAnalyticsProducerName: 'YORUBA',
- useReverb: true,
chartbeatDomain: 'yoruba.bbc.co.uk',
brandName: 'BBC News Yorùbá',
product: 'BBC News',
diff --git a/src/app/lib/config/services/zhongwen.ts b/src/app/lib/config/services/zhongwen.ts
index 71c0e4833e9..c956ce31d1f 100644
--- a/src/app/lib/config/services/zhongwen.ts
+++ b/src/app/lib/config/services/zhongwen.ts
@@ -13,7 +13,6 @@ const baseServiceConfig = {
atiAnalyticsAppName: 'news-zhongwen',
atiAnalyticsProducerId: '38',
atiAnalyticsProducerName: 'CHINESE',
- useReverb: true,
chartbeatDomain: 'zhongwen.bbc.co.uk',
brandName: 'BBC News 中文',
product: 'BBC News',
diff --git a/src/app/models/types/serviceConfig.ts b/src/app/models/types/serviceConfig.ts
index 4033eda3547..8bde0a8bb01 100644
--- a/src/app/models/types/serviceConfig.ts
+++ b/src/app/models/types/serviceConfig.ts
@@ -45,7 +45,6 @@ export type ServiceConfig = {
atiAnalyticsAppName: string;
atiAnalyticsProducerId: string;
atiAnalyticsProducerName?: string;
- useReverb?: boolean;
chartbeatDomain: string;
brandName: string;
product: string;
diff --git a/src/app/pages/LiveRadioPage/index.test.tsx b/src/app/pages/LiveRadioPage/index.test.tsx
index 090c96d28a9..d72d2a18e5b 100644
--- a/src/app/pages/LiveRadioPage/index.test.tsx
+++ b/src/app/pages/LiveRadioPage/index.test.tsx
@@ -1,6 +1,5 @@
import { BrowserRouter } from 'react-router-dom';
import { RequestContextProvider } from '#contexts/RequestContext';
-import * as analyticsUtils from '#lib/analyticsUtils';
import { ToggleContextProvider } from '#contexts/ToggleContext';
import { LIVE_RADIO_PAGE } from '#app/routes/utils/pageTypes';
import { Services } from '#app/models/types/global';
@@ -36,8 +35,6 @@ const Page = ({ pageData, service, lang }: Props) => (
);
-(analyticsUtils.getAtUserId as jest.Mock) = jest.fn();
-
jest.mock('../../components/ChartbeatAnalytics', () => {
const ChartbeatAnalytics = () => chartbeat
;
return ChartbeatAnalytics;
diff --git a/src/app/pages/MostReadPage/index.test.jsx b/src/app/pages/MostReadPage/index.test.jsx
index 8e20a68ac35..87af50ec9ea 100644
--- a/src/app/pages/MostReadPage/index.test.jsx
+++ b/src/app/pages/MostReadPage/index.test.jsx
@@ -13,7 +13,6 @@ fetch.mockResponse(JSON.stringify(pidginMostReadData));
jest.mock('#lib/analyticsUtils', () => {
return {
...jest.requireActual('#lib/analyticsUtils'),
- getAtUserId: jest.fn(),
};
});
diff --git a/src/app/pages/OnDemandAudioPage/index.test.tsx b/src/app/pages/OnDemandAudioPage/index.test.tsx
index eabcf0f47f1..47334a05aba 100644
--- a/src/app/pages/OnDemandAudioPage/index.test.tsx
+++ b/src/app/pages/OnDemandAudioPage/index.test.tsx
@@ -5,7 +5,6 @@ import indonesianOnDemandAudio from '#data/indonesia/bbc_indonesian_radio/w172xy
import swahiliExpiredOnDemandAudio from '#data/swahili/bbc_swahili_radio/w3ct1y1s.json';
import koreanOnDemandAudio from '#data/korean/bbc_korean_radio/w3ct1vk5.json';
import zhongwenOnDemandAudio from '#data/zhongwen/bbc_cantonese_radio/w172xwswq9t42v6.json';
-import * as analyticsUtils from '#lib/analyticsUtils';
import getInitialData from '#app/routes/onDemandAudio/getInitialData';
import withMediaError from '#lib/utilities/episodeAvailability/withMediaError';
import { AUDIO_PAGE } from '#app/routes/utils/pageTypes';
@@ -70,8 +69,6 @@ const renderPage = async ({
return result;
};
-(analyticsUtils.getAtUserId as jest.Mock) = jest.fn();
-
jest.mock('../../components/ChartbeatAnalytics', () => {
const ChartbeatAnalytics = () => chartbeat
;
return ChartbeatAnalytics;
diff --git a/src/app/pages/OnDemandTvPage/index.test.tsx b/src/app/pages/OnDemandTvPage/index.test.tsx
index 47517c11ad0..2e1fc831d12 100644
--- a/src/app/pages/OnDemandTvPage/index.test.tsx
+++ b/src/app/pages/OnDemandTvPage/index.test.tsx
@@ -1,6 +1,5 @@
import { FetchMock } from 'jest-fetch-mock';
import pashtoPageData from '#data/pashto/bbc_pashto_tv/tv_programmes/w13xttn4.json';
-import * as analyticsUtils from '#lib/analyticsUtils';
import getInitialData from '#app/routes/onDemandTV/getInitialData';
import withMediaError from '#lib/utilities/episodeAvailability/withMediaError';
import { TV_PAGE } from '#app/routes/utils/pageTypes';
@@ -43,8 +42,6 @@ const renderPage = async ({ pageData, service }: Props) => {
return result;
};
-(analyticsUtils.getAtUserId as jest.Mock) = jest.fn();
-
const fetchMock = fetch as FetchMock;
jest.mock('../../components/ChartbeatAnalytics', () => {
diff --git a/ws-nextjs-app/cypress/e2e/articlePage/index.cy.ts b/ws-nextjs-app/cypress/e2e/articlePage/index.cy.ts
index 7183bf2233d..953b887809e 100644
--- a/ws-nextjs-app/cypress/e2e/articlePage/index.cy.ts
+++ b/ws-nextjs-app/cypress/e2e/articlePage/index.cy.ts
@@ -289,7 +289,6 @@ const atiAnalyticsTestSuites = [
siteId: 51,
applicationType: 'responsive',
contentType: 'article-sfv',
- useReverb: true,
tests: [
assertPageView,
assertLatestMediaComponentView,
@@ -317,7 +316,6 @@ const atiAnalyticsTestSuites = [
siteId: 40,
applicationType: 'responsive',
contentType: 'article',
- useReverb: true,
tests: [
assertPageView,
assertArticleLiteSiteLinkComponentView,
@@ -344,7 +342,6 @@ const atiAnalyticsTestSuites = [
siteId: 70,
applicationType: 'responsive',
contentType: 'article',
- useReverb: true,
tests: [
assertPageView,
assertFeaturesAnalysisComponentView,
@@ -368,7 +365,6 @@ const atiAnalyticsTestSuites = [
siteId: 70,
applicationType: 'responsive',
contentType: 'article',
- useReverb: true,
tests: [
assertPageView,
assertFeaturesAnalysisComponentView,
@@ -393,7 +389,6 @@ const atiAnalyticsTestSuites = [
siteId: 70,
applicationType: 'responsive',
contentType: 'article-sfv',
- useReverb: true,
tests: [
assertPageView,
assertLatestMediaComponentClick,
@@ -412,7 +407,6 @@ const atiAnalyticsTestSuites = [
siteId: 135,
applicationType: 'responsive',
contentType: 'article',
- useReverb: true,
tests: [
assertPageView,
assertTopBarOJComponentClick,
@@ -466,7 +460,6 @@ const atiAmpTestSuites = atiAnalyticsTestSuites
return {
...testSuite,
path: getPathWithSuffix({ path: testSuite.path, suffix: '.amp' }),
- useReverb: true,
applicationType: 'amp',
tests: [assertPageView],
};
@@ -480,7 +473,6 @@ const atiAmpTestSuites = atiAnalyticsTestSuites
siteId: 64,
applicationType: 'amp',
contentType: 'article',
- useReverb: true,
tests: [assertPageView],
},
{
@@ -491,7 +483,6 @@ const atiAmpTestSuites = atiAnalyticsTestSuites
siteId: 64,
applicationType: 'amp',
contentType: 'article',
- useReverb: true,
tests: [assertPageView],
},
]);
@@ -524,7 +515,6 @@ const atiLiteTestSuites = atiAnalyticsTestSuites
...testSuite,
path: getPathWithSuffix({ path: testSuite.path, suffix: '.lite' }),
applicationType: 'lite',
- useReverb: true,
tests: [...liteSiteTests],
};
});
diff --git a/ws-nextjs-app/cypress/e2e/homePage/index.cy.ts b/ws-nextjs-app/cypress/e2e/homePage/index.cy.ts
index a7ccf078f8a..82777a67dbe 100644
--- a/ws-nextjs-app/cypress/e2e/homePage/index.cy.ts
+++ b/ws-nextjs-app/cypress/e2e/homePage/index.cy.ts
@@ -120,7 +120,6 @@ const atiAnalyticsTestSuites = [
siteId: 3,
applicationType: 'responsive',
contentType: 'index-home',
- useReverb: true,
tests: [
assertPageView,
assertBillboardComponentView,
@@ -135,7 +134,6 @@ const atiAnalyticsTestSuites = [
siteId: 142,
applicationType: 'responsive',
contentType: 'index-home',
- useReverb: true,
tests: [...atiAnalyticsNavigationComponentTests],
},
{
@@ -146,7 +144,6 @@ const atiAnalyticsTestSuites = [
siteId: 58,
applicationType: 'responsive',
contentType: 'index-home',
- useReverb: true,
tests: [
...atiAnalyticsNavigationComponentTests,
assertMessageBannerComponentView,
@@ -163,7 +160,6 @@ const atiAnalyticsTestSuites = [
siteId: 30,
applicationType: 'responsive',
contentType: 'index-home',
- useReverb: true,
tests: [assertPageView],
},
{
@@ -174,7 +170,6 @@ const atiAnalyticsTestSuites = [
siteId: 68,
applicationType: 'responsive',
contentType: 'index-home',
- useReverb: true,
tests: [
assertPageView,
assertRadioScheduleComponentView,
@@ -189,7 +184,6 @@ const atiAnalyticsTestSuites = [
siteId: 33,
applicationType: 'responsive',
contentType: 'index-home',
- useReverb: true,
tests: [
assertPageView,
assertPortraitVideoCarouselComponentView,
@@ -204,7 +198,6 @@ const atiAnalyticsTestSuites = [
siteId: 81,
applicationType: 'responsive',
contentType: 'index-home',
- useReverb: true,
tests: [
assertPageView,
assertMostReadComponentView,
@@ -219,7 +212,6 @@ const atiAnalyticsTestSuites = [
siteId: 96,
applicationType: 'responsive',
contentType: 'index-home',
- useReverb: true,
tests: [
assertPageView,
assertMessageBannerComponentView,
@@ -258,7 +250,6 @@ const atiAnalyticsLiteTestSuites = atiAnalyticsTestSuites.map(testSuite => {
...testSuite,
path: getPathWithSuffix({ path: testSuite.path, suffix: '.lite' }),
applicationType: 'lite',
- useReverb: true,
siteId: testSuite.service === 'magyarul' ? 134 : testSuite.siteId,
tests: [...liteSiteTests],
};
diff --git a/ws-nextjs-app/cypress/e2e/languagesPage/index.cy.ts b/ws-nextjs-app/cypress/e2e/languagesPage/index.cy.ts
index 4b26769a18d..51f8ca6042c 100644
--- a/ws-nextjs-app/cypress/e2e/languagesPage/index.cy.ts
+++ b/ws-nextjs-app/cypress/e2e/languagesPage/index.cy.ts
@@ -40,7 +40,6 @@ const atiAnalyticsTestSuites = [
siteId: 30,
applicationType: 'responsive',
contentType: 'index-home',
- useReverb: true,
tests: [assertPageView],
},
] as unknown as TestDataType[];
diff --git a/ws-nextjs-app/cypress/e2e/livePage/index.cy.ts b/ws-nextjs-app/cypress/e2e/livePage/index.cy.ts
index a0fa0ceef62..8aa52fbcd37 100644
--- a/ws-nextjs-app/cypress/e2e/livePage/index.cy.ts
+++ b/ws-nextjs-app/cypress/e2e/livePage/index.cy.ts
@@ -46,7 +46,6 @@ const atiAnalyticsTestSuites = [
siteId: 5,
applicationType: 'responsive',
contentType: 'live-coverage',
- useReverb: true,
tests: [
assertPageView,
assertScrollableNavigationComponentView,
@@ -63,7 +62,6 @@ const atiAnalyticsTestSuites = [
siteId: 70,
applicationType: 'responsive',
contentType: 'live-coverage',
- useReverb: true,
tests: [
assertPageView,
assertScrollableNavigationComponentView,
@@ -80,7 +78,6 @@ const atiAnalyticsTestSuites = [
siteId: 95,
applicationType: 'responsive',
contentType: 'live-coverage',
- useReverb: true,
tests: [
assertPageView,
assertScrollableNavigationComponentView,
diff --git a/ws-nextjs-app/cypress/e2e/mediaAssetPage/index.cy.ts b/ws-nextjs-app/cypress/e2e/mediaAssetPage/index.cy.ts
index 4d7be52d987..7063b332aeb 100644
--- a/ws-nextjs-app/cypress/e2e/mediaAssetPage/index.cy.ts
+++ b/ws-nextjs-app/cypress/e2e/mediaAssetPage/index.cy.ts
@@ -217,7 +217,6 @@ const atiAnalyticsTestSuites = [
siteId: 51,
applicationType: 'responsive',
contentType: 'article-media-asset',
- useReverb: true,
tests: [...atiAnalyticsTests],
},
{
@@ -228,7 +227,6 @@ const atiAnalyticsTestSuites = [
siteId: 69,
applicationType: 'responsive',
contentType: 'article-media-asset',
- useReverb: true,
tests: [...atiAnalyticsTests],
},
{
@@ -239,7 +237,6 @@ const atiAnalyticsTestSuites = [
siteId: 69,
applicationType: 'responsive',
contentType: 'article-media-asset',
- useReverb: true,
tests: [...atiAnalyticsTests],
},
{
@@ -250,7 +247,6 @@ const atiAnalyticsTestSuites = [
siteId: 69,
applicationType: 'responsive',
contentType: 'article-media-asset',
- useReverb: true,
tests: [...atiAnalyticsTests],
},
] as unknown as TestDataType[];
diff --git a/ws-nextjs-app/cypress/e2e/photoGalleryPage/index.cy.ts b/ws-nextjs-app/cypress/e2e/photoGalleryPage/index.cy.ts
index 3505d131a91..99f0ca84e5d 100644
--- a/ws-nextjs-app/cypress/e2e/photoGalleryPage/index.cy.ts
+++ b/ws-nextjs-app/cypress/e2e/photoGalleryPage/index.cy.ts
@@ -112,7 +112,6 @@ const atiAnalyticsTestSuites = [
siteId: 2,
applicationType: 'responsive',
contentType: 'article-photo-gallery',
- useReverb: true,
tests: [...atiAnalyticsTests],
},
{
@@ -123,7 +122,6 @@ const atiAnalyticsTestSuites = [
siteId: 69,
applicationType: 'responsive',
contentType: 'article-photo-gallery',
- useReverb: true,
tests: [...atiAnalyticsTests],
},
{
@@ -134,7 +132,6 @@ const atiAnalyticsTestSuites = [
siteId: 70,
applicationType: 'responsive',
contentType: 'article-photo-gallery',
- useReverb: true,
tests: [...atiAnalyticsTests],
},
{
@@ -145,7 +142,6 @@ const atiAnalyticsTestSuites = [
siteId: 90,
applicationType: 'responsive',
contentType: 'article-photo-gallery',
- useReverb: true,
tests: [...atiAnalyticsTests],
},
{
@@ -156,7 +152,6 @@ const atiAnalyticsTestSuites = [
siteId: 38,
applicationType: 'responsive',
contentType: 'article-photo-gallery',
- useReverb: true,
tests: [...atiAnalyticsTests],
},
] as unknown as TestDataType[];
diff --git a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/articleLiteSiteLink.ts b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/articleLiteSiteLink.ts
index 6d4694ed31c..9b128bdfbf9 100644
--- a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/articleLiteSiteLink.ts
+++ b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/articleLiteSiteLink.ts
@@ -11,7 +11,6 @@ const { ARTICLE_LITE_SITE_LINK } = COMPONENTS;
export const assertArticleLiteSiteLinkComponentView = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -28,7 +27,6 @@ export const assertArticleLiteSiteLinkComponentView = ({
component: ARTICLE_LITE_SITE_LINK,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
@@ -38,7 +36,6 @@ export const assertArticleLiteSiteLinkComponentView = ({
export const assertArticleLiteSiteLinkComponentClick = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -58,7 +55,6 @@ export const assertArticleLiteSiteLinkComponentClick = ({
component: ARTICLE_LITE_SITE_LINK,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
diff --git a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/billboard.ts b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/billboard.ts
index 6018f12b721..62478db2e98 100644
--- a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/billboard.ts
+++ b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/billboard.ts
@@ -5,8 +5,6 @@ const { BILLBOARD } = COMPONENTS;
export const assertBillboardComponentView = ({
pageIdentifier,
- contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -22,8 +20,6 @@ export const assertBillboardComponentView = ({
assertATIComponentViewEvent({
component: BILLBOARD,
pageIdentifier,
- contentType,
- useReverb,
applicationType,
siteId,
});
@@ -32,8 +28,6 @@ export const assertBillboardComponentView = ({
export const assertBillboardComponentClick = ({
pageIdentifier,
- contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -52,8 +46,6 @@ export const assertBillboardComponentClick = ({
assertATIComponentClickEvent({
component: BILLBOARD,
pageIdentifier,
- contentType,
- useReverb,
applicationType,
siteId,
});
diff --git a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/continueReadingButton.ts b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/continueReadingButton.ts
index fcaa7d4576e..fba47465733 100644
--- a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/continueReadingButton.ts
+++ b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/continueReadingButton.ts
@@ -32,6 +32,7 @@ export const assertContinueReadingButtonComponentView = ({
component: CONTINUE_READING_BUTTON,
pageIdentifier,
contentType,
+ applicationType,
siteId,
});
},
@@ -64,6 +65,7 @@ export const assertContinueReadingButtonComponentClick = ({
component: CONTINUE_READING_BUTTON,
pageIdentifier,
contentType,
+ applicationType,
siteId,
});
},
diff --git a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/featuresAnalysis.ts b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/featuresAnalysis.ts
index 5661514ef68..0538a4e867f 100644
--- a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/featuresAnalysis.ts
+++ b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/featuresAnalysis.ts
@@ -11,7 +11,6 @@ const { FEATURES } = COMPONENTS;
export const assertFeaturesAnalysisComponentView = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -28,7 +27,6 @@ export const assertFeaturesAnalysisComponentView = ({
component: FEATURES,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
@@ -38,7 +36,6 @@ export const assertFeaturesAnalysisComponentView = ({
export const assertFeaturesAnalysisComponentClick = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -56,7 +53,6 @@ export const assertFeaturesAnalysisComponentClick = ({
component: FEATURES,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
diff --git a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/index.ts b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/index.ts
index 04b25404e60..00305b96af4 100644
--- a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/index.ts
+++ b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/index.ts
@@ -6,7 +6,7 @@ import {
import {
ATI_PAGE_VIEW,
ATI_PAGE_VIEW_REVERB,
- // ATI_USER_ID_COOKIE,
+ ATI_USER_ID_COOKIE,
getATIParamsFromURL,
interceptATIAnalyticsBeacons,
getExpectedAtiDestination,
@@ -14,7 +14,7 @@ import {
import environment from '../../../../support/helpers/getAppEnv';
const usesReverbViewabilityModel = applicationType =>
- applicationType !== 'lite';
+ !['lite', 'amp'].includes(applicationType);
const getAppName = service => {
if (service === 'ws') {
@@ -93,7 +93,14 @@ const assertLocationSpecificPianoDestinationExists = ({ service }) => {
});
};
-const assertReverbViewabilityComponentEventParamsExist = ({ params }) => {
+const assertReverbViewabilityComponentEventParamsExist = ({
+ params,
+ applicationType,
+}) => {
+ if (['responsive', 'lite'].includes(applicationType)) {
+ expect(params).to.have.property('idclient');
+ }
+
expect(params).to.have.property('s'); // destination
expect(params).to.have.property('events'); // event details
expect(params).to.have.property('context');
@@ -183,7 +190,6 @@ const validateViewabilityEventDetails = ({ payload, actionType }) => {
};
export const assertPageView = ({
- useReverb,
pageIdentifier,
applicationType,
contentType,
@@ -196,10 +202,9 @@ export const assertPageView = ({
cy.visit(path, { retryOnStatusCodeFailure: true });
const useViewabilty = usesReverbViewabilityModel(applicationType);
- const atiPageViewAlias =
- useReverb && useViewabilty && applicationType !== 'amp'
- ? ATI_PAGE_VIEW_REVERB
- : ATI_PAGE_VIEW;
+ const atiPageViewAlias = useViewabilty
+ ? ATI_PAGE_VIEW_REVERB
+ : ATI_PAGE_VIEW;
cy.wait(`@${atiPageViewAlias}`).then(({ request }) => {
const params = getATIParamsFromURL(request.url);
@@ -210,13 +215,12 @@ export const assertPageView = ({
applicationType,
});
- // TODO: Commenting out temporarily until old ATI code is removed - https://bbc.atlassian.net/browse/WS-222
- // if (['responsive', 'lite'].includes(applicationType)) {
- // expect(params.idclient).to.equal(
- // ATI_USER_ID_COOKIE,
- // 'params.idclient (atuserid cookie value)',
- // );
- // }
+ if (['responsive', 'lite'].includes(applicationType)) {
+ expect(params.idclient).to.equal(
+ ATI_USER_ID_COOKIE,
+ 'params.idclient (atuserid cookie value)',
+ );
+ }
expect(params.p).to.equal(pageIdentifier, 'params.p (page identifier)');
expect(parseInt(params.s2, 10)).to.equal(
@@ -246,20 +250,12 @@ export const assertPageView = ({
const assertViewabilityModelViewEvent = ({
pageIdentifier,
params,
- // applicationType,
+ applicationType,
siteId,
}) => {
const eventContext = JSON.parse(params.context);
- assertReverbViewabilityComponentEventParamsExist({ params });
-
- // TODO: Commenting out temporarily until old ATI code is removed - https://bbc.atlassian.net/browse/WS-222
- // if (['responsive', 'lite'].includes(applicationType)) {
- // expect(params.idclient).to.equal(
- // ATI_USER_ID_COOKIE,
- // 'params.idclient (atuserid cookie value)',
- // );
- // }
+ assertReverbViewabilityComponentEventParamsExist({ params, applicationType });
expect(params.events).to.satisfy(
payload =>
@@ -274,6 +270,7 @@ const assertViewabilityModelViewEvent = ({
export const assertATIComponentViewEvent = ({
component,
pageIdentifier,
+ applicationType,
siteId,
}) => {
const requestAlias = `@${component}-viewability-view`;
@@ -286,6 +283,7 @@ export const assertATIComponentViewEvent = ({
assertViewabilityModelViewEvent({
pageIdentifier,
params,
+ applicationType,
siteId,
});
});
@@ -294,23 +292,16 @@ export const assertATIComponentViewEvent = ({
const assertViewabilityModelClickEvent = ({
pageIdentifier,
params,
- // applicationType,
+ applicationType,
siteId,
}) => {
const eventContext = JSON.parse(params.context);
assertReverbViewabilityComponentEventParamsExist({
params,
+ applicationType,
});
- // TODO: Commenting out temporarily until old ATI code is removed - https://bbc.atlassian.net/browse/WS-222
- // if (['responsive', 'lite'].includes(applicationType)) {
- // expect(params.idclient).to.equal(
- // ATI_USER_ID_COOKIE,
- // 'params.idclient (atuserid cookie value)',
- // );
- // }
-
expect(params.events).to.satisfy(
payload =>
validateViewabilityEventDetails({
@@ -327,6 +318,7 @@ const assertViewabilityModelClickEvent = ({
export const assertATIComponentClickEvent = ({
component,
pageIdentifier,
+ applicationType,
siteId,
}) => {
const requestAlias = `@${component}-viewability-click`;
@@ -338,6 +330,7 @@ export const assertATIComponentClickEvent = ({
assertViewabilityModelClickEvent({
pageIdentifier,
params,
+ applicationType,
siteId,
});
});
diff --git a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/latestMedia.ts b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/latestMedia.ts
index 1e146ae27ef..49513669d18 100644
--- a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/latestMedia.ts
+++ b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/latestMedia.ts
@@ -11,7 +11,6 @@ const { LATEST_MEDIA } = COMPONENTS;
export const assertLatestMediaComponentView = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -28,7 +27,6 @@ export const assertLatestMediaComponentView = ({
component: LATEST_MEDIA,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
@@ -38,7 +36,6 @@ export const assertLatestMediaComponentView = ({
export const assertLatestMediaComponentClick = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -58,7 +55,6 @@ export const assertLatestMediaComponentClick = ({
component: LATEST_MEDIA,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
diff --git a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/messageBanner.ts b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/messageBanner.ts
index 1d36cf5c2e3..1cd7563b6a5 100644
--- a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/messageBanner.ts
+++ b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/messageBanner.ts
@@ -7,7 +7,6 @@ export const assertMessageBannerComponentView = ({
pageIdentifier,
contentType,
componentTrackingContentType,
- useReverb,
path,
applicationType,
siteId,
@@ -24,7 +23,6 @@ export const assertMessageBannerComponentView = ({
component: MESSAGE_BANNER,
pageIdentifier,
contentType: componentTrackingContentType || contentType,
- useReverb,
applicationType,
siteId,
});
@@ -35,7 +33,6 @@ export const assertMessageBannerComponentClick = ({
pageIdentifier,
contentType,
componentTrackingContentType,
- useReverb,
path,
applicationType,
siteId,
@@ -55,7 +52,6 @@ export const assertMessageBannerComponentClick = ({
component: MESSAGE_BANNER,
pageIdentifier,
contentType: componentTrackingContentType || contentType,
- useReverb,
applicationType,
siteId,
});
diff --git a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/mostRead.ts b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/mostRead.ts
index 7d41e4ea47e..e2fdca940e8 100644
--- a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/mostRead.ts
+++ b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/mostRead.ts
@@ -13,7 +13,6 @@ const { MOST_READ } = COMPONENTS;
export const assertMostReadComponentView = ({
pageIdentifier,
contentType,
- useReverb,
path,
service,
applicationType,
@@ -37,7 +36,6 @@ export const assertMostReadComponentView = ({
component: MOST_READ,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
@@ -47,7 +45,6 @@ export const assertMostReadComponentView = ({
export const assertMostReadComponentClick = ({
pageIdentifier,
contentType,
- useReverb,
path,
service,
applicationType,
@@ -72,7 +69,6 @@ export const assertMostReadComponentClick = ({
component: MOST_READ,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
diff --git a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/navigation.ts b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/navigation.ts
index d16f89d878c..570f07ae4ca 100644
--- a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/navigation.ts
+++ b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/navigation.ts
@@ -12,7 +12,6 @@ export const assertScrollableNavigationComponentView = ({
pageIdentifier,
contentType,
componentTrackingContentType,
- useReverb,
path,
applicationType,
siteId,
@@ -33,7 +32,6 @@ export const assertScrollableNavigationComponentView = ({
component: SCROLLABLE_NAVIGATION,
pageIdentifier,
contentType: componentTrackingContentType || contentType,
- useReverb,
applicationType,
siteId,
});
@@ -44,7 +42,6 @@ export const assertScrollableNavigationComponentClick = ({
pageIdentifier,
contentType,
componentTrackingContentType,
- useReverb,
path,
applicationType,
siteId,
@@ -64,7 +61,6 @@ export const assertScrollableNavigationComponentClick = ({
component: SCROLLABLE_NAVIGATION,
pageIdentifier,
contentType: componentTrackingContentType || contentType,
- useReverb,
applicationType,
siteId,
});
@@ -76,7 +72,6 @@ export const assertDropdownNavigationComponentView = ({
pageIdentifier,
contentType,
componentTrackingContentType,
- useReverb,
path,
applicationType,
siteId,
@@ -92,7 +87,6 @@ export const assertDropdownNavigationComponentView = ({
component: DROPDOWN_NAVIGATION,
pageIdentifier,
contentType: componentTrackingContentType || contentType,
- useReverb,
applicationType,
siteId,
});
@@ -103,7 +97,6 @@ export const assertDropdownNavigationComponentClick = ({
pageIdentifier,
contentType,
componentTrackingContentType,
- useReverb,
path,
applicationType,
siteId,
@@ -122,7 +115,6 @@ export const assertDropdownNavigationComponentClick = ({
component: DROPDOWN_NAVIGATION,
pageIdentifier,
contentType: componentTrackingContentType || contentType,
- useReverb,
applicationType,
siteId,
});
diff --git a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/podcastPromo.ts b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/podcastPromo.ts
index 8b7c8b98141..f125c052bcd 100644
--- a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/podcastPromo.ts
+++ b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/podcastPromo.ts
@@ -11,7 +11,6 @@ const { PODCAST_PROMO } = COMPONENTS;
export const assertPodcastPromoComponentView = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -32,7 +31,6 @@ export const assertPodcastPromoComponentView = ({
component: PODCAST_PROMO,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
@@ -42,7 +40,6 @@ export const assertPodcastPromoComponentView = ({
export const assertPodcastPromoComponentClick = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -62,7 +59,6 @@ export const assertPodcastPromoComponentClick = ({
component: PODCAST_PROMO,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
diff --git a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/portraitVideoCarousel.ts b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/portraitVideoCarousel.ts
index 6df2a891283..0fdce6785a5 100644
--- a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/portraitVideoCarousel.ts
+++ b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/portraitVideoCarousel.ts
@@ -7,7 +7,6 @@ export const assertPortraitVideoCarouselComponentView = ({
pageIdentifier,
contentType,
componentTrackingContentType,
- useReverb,
path,
applicationType,
siteId,
@@ -28,7 +27,6 @@ export const assertPortraitVideoCarouselComponentView = ({
component: PORTRAIT_VIDEO_CAROUSEL,
pageIdentifier,
contentType: componentTrackingContentType || contentType,
- useReverb,
applicationType,
siteId,
});
diff --git a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/portraitVideoModal.ts b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/portraitVideoModal.ts
index 6ea2336256b..6fb588607a7 100644
--- a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/portraitVideoModal.ts
+++ b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/portraitVideoModal.ts
@@ -7,7 +7,6 @@ export const assertPortraitVideoModalComponentView = ({
pageIdentifier,
contentType,
componentTrackingContentType,
- useReverb,
path,
applicationType,
siteId,
@@ -30,7 +29,6 @@ export const assertPortraitVideoModalComponentView = ({
component: PORTRAIT_VIDEO_MODAL,
pageIdentifier,
contentType: componentTrackingContentType || contentType,
- useReverb,
applicationType,
siteId,
});
diff --git a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/radioSchedule.ts b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/radioSchedule.ts
index 8f961b66d9b..bb51cab3374 100644
--- a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/radioSchedule.ts
+++ b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/radioSchedule.ts
@@ -6,7 +6,6 @@ const { RADIO_SCHEDULE } = COMPONENTS;
export const assertRadioScheduleComponentView = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -32,7 +31,6 @@ export const assertRadioScheduleComponentView = ({
export const assertRadioScheduleComponentClick = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -52,7 +50,6 @@ export const assertRadioScheduleComponentClick = ({
component: RADIO_SCHEDULE,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
diff --git a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/recommendations.ts b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/recommendations.ts
index bbd3cc9de52..dc00e429310 100644
--- a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/recommendations.ts
+++ b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/recommendations.ts
@@ -11,7 +11,6 @@ const { RECOMMENDATIONS } = COMPONENTS;
export const assertRecommendationsComponentView = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -32,7 +31,6 @@ export const assertRecommendationsComponentView = ({
component: RECOMMENDATIONS,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
@@ -42,7 +40,6 @@ export const assertRecommendationsComponentView = ({
export const assertRecommendationsComponentClick = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -65,7 +62,6 @@ export const assertRecommendationsComponentClick = ({
component: RECOMMENDATIONS,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
diff --git a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/relatedContent.ts b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/relatedContent.ts
index 10360b7d3e4..4b114175535 100644
--- a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/relatedContent.ts
+++ b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/relatedContent.ts
@@ -11,7 +11,6 @@ const { RELATED_CONTENT } = COMPONENTS;
export const assertRelatedContentComponentView = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -32,7 +31,6 @@ export const assertRelatedContentComponentView = ({
component: RELATED_CONTENT,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
@@ -42,7 +40,6 @@ export const assertRelatedContentComponentView = ({
export const assertRelatedContentComponentClick = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -62,7 +59,6 @@ export const assertRelatedContentComponentClick = ({
component: RELATED_CONTENT,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
diff --git a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/relatedTopics.ts b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/relatedTopics.ts
index 30375524890..635622c4ec2 100644
--- a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/relatedTopics.ts
+++ b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/relatedTopics.ts
@@ -11,7 +11,6 @@ const { RELATED_TOPICS } = COMPONENTS;
export const assertRelatedTopicsComponentView = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -32,7 +31,6 @@ export const assertRelatedTopicsComponentView = ({
component: RELATED_TOPICS,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
@@ -42,7 +40,6 @@ export const assertRelatedTopicsComponentView = ({
export const assertRelatedTopicsComponentClick = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -62,7 +59,6 @@ export const assertRelatedTopicsComponentClick = ({
component: RELATED_TOPICS,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
diff --git a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/scrollablePromo.ts b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/scrollablePromo.ts
index f8e6a8f259c..3243b41d0b1 100644
--- a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/scrollablePromo.ts
+++ b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/scrollablePromo.ts
@@ -11,7 +11,6 @@ const { SCROLLABLE_PROMO } = COMPONENTS;
export const assertScrollablePromoComponentView = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -32,7 +31,6 @@ export const assertScrollablePromoComponentView = ({
component: SCROLLABLE_PROMO,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
@@ -42,7 +40,6 @@ export const assertScrollablePromoComponentView = ({
export const assertScrollablePromoComponentClick = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -62,7 +59,6 @@ export const assertScrollablePromoComponentClick = ({
component: SCROLLABLE_PROMO,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
diff --git a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/socialEmbed.ts b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/socialEmbed.ts
index 26a308e566e..e8f3882c612 100644
--- a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/socialEmbed.ts
+++ b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/socialEmbed.ts
@@ -11,7 +11,6 @@ const { SOCIAL_EMBED } = COMPONENTS;
export const assertSocialEmbedComponentView = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -32,7 +31,6 @@ export const assertSocialEmbedComponentView = ({
component: SOCIAL_EMBED,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
@@ -42,7 +40,6 @@ export const assertSocialEmbedComponentView = ({
export const assertSocialEmbedComponentClick = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -62,7 +59,6 @@ export const assertSocialEmbedComponentClick = ({
component: SOCIAL_EMBED,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
diff --git a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/topBarOjs.ts b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/topBarOjs.ts
index 5ee6c57376a..777c896b868 100644
--- a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/topBarOjs.ts
+++ b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/topBarOjs.ts
@@ -12,6 +12,7 @@ export const assertTopBarOJComponentView = ({
pageIdentifier,
contentType,
path,
+ applicationType,
siteId,
}: AtiAssertionFnProps) => {
it('should send a view event for the Top Bar OJ component', () => {
@@ -27,6 +28,7 @@ export const assertTopBarOJComponentView = ({
component: TOP_BAR_OJ,
pageIdentifier,
contentType,
+ applicationType,
siteId,
});
});
@@ -36,6 +38,7 @@ export const assertTopBarOJComponentClick = ({
pageIdentifier,
contentType,
path,
+ applicationType,
siteId,
}: AtiAssertionFnProps) => {
it('should send a click event for the Top Bar OJ component', () => {
@@ -53,6 +56,7 @@ export const assertTopBarOJComponentClick = ({
component: TOP_BAR_OJ,
pageIdentifier,
contentType,
+ applicationType,
siteId,
});
});
diff --git a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/topStories.ts b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/topStories.ts
index ebeac4ca5fb..49e903992c3 100644
--- a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/topStories.ts
+++ b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/topStories.ts
@@ -11,7 +11,6 @@ const { TOP_STORIES } = COMPONENTS;
export const assertTopStoriesComponentView = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -28,7 +27,6 @@ export const assertTopStoriesComponentView = ({
component: TOP_STORIES,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
@@ -38,7 +36,6 @@ export const assertTopStoriesComponentView = ({
export const assertTopStoriesComponentClick = ({
pageIdentifier,
contentType,
- useReverb,
path,
applicationType,
siteId,
@@ -58,7 +55,6 @@ export const assertTopStoriesComponentClick = ({
component: TOP_STORIES,
pageIdentifier,
contentType,
- useReverb,
applicationType,
siteId,
});
diff --git a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/type.ts b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/type.ts
index d4f8231b357..19117203b53 100644
--- a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/type.ts
+++ b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/type.ts
@@ -3,7 +3,6 @@ import { Services } from '#app/models/types/global';
export type AtiAssertionFnProps = {
pageIdentifier: string;
contentType: string;
- useReverb: boolean;
path: string;
applicationType: string;
siteId: string;
diff --git a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/index.cy.ts b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/index.cy.ts
index 97528437185..d9e08d5991a 100644
--- a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/index.cy.ts
+++ b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/index.cy.ts
@@ -47,7 +47,6 @@ const canonicalTestSuites = [
applicationType: 'responsive',
contentType: 'live-coverage',
componentTrackingContentType: LIVE_PAGE,
- useReverb: true,
tests: [
assertPageView,
assertScrollableNavigationComponentView,
@@ -63,7 +62,6 @@ const canonicalTestSuites = [
applicationType: 'responsive',
contentType: 'live-coverage',
componentTrackingContentType: LIVE_PAGE,
- useReverb: true,
tests: [
assertPageView,
assertScrollableNavigationComponentView,
@@ -79,7 +77,6 @@ const canonicalTestSuites = [
// siteId: 52,
// applicationType: 'responsive',
// contentType: 'article',
- // useReverb: true,
// tests: [
// assertPageView,
// assertTopStoriesComponentView,
@@ -113,7 +110,6 @@ const ampTestSuites = canonicalTestSuites.filter(supportsAmp).map(testSuite => {
return {
...testSuite,
path: getPathWithSuffix({ path: testSuite.path, suffix: '.amp' }),
- useReverb: true,
applicationType: 'amp',
tests: [assertPageView],
};
@@ -149,7 +145,6 @@ const liteTestSuites = canonicalTestSuites
...testSuite,
path: getPathWithSuffix({ path: testSuite.path, suffix: '.lite' }),
applicationType: 'lite',
- useReverb: true,
tests: [...liteSiteTests],
};
});
diff --git a/ws-nextjs-app/cypress/e2e/storyPage/index.cy.ts b/ws-nextjs-app/cypress/e2e/storyPage/index.cy.ts
index dfc7bbce215..404aa0705f6 100644
--- a/ws-nextjs-app/cypress/e2e/storyPage/index.cy.ts
+++ b/ws-nextjs-app/cypress/e2e/storyPage/index.cy.ts
@@ -222,7 +222,6 @@ const atiAnalyticsTestSuites = [
siteId: 51,
applicationType: 'responsive',
contentType: 'article',
- useReverb: true,
tests: [...atiAnalyticsTests],
},
{
@@ -233,7 +232,6 @@ const atiAnalyticsTestSuites = [
siteId: 62,
applicationType: 'responsive',
contentType: 'article',
- useReverb: true,
tests: [...atiAnalyticsTests],
},
{
@@ -244,7 +242,6 @@ const atiAnalyticsTestSuites = [
siteId: 75,
applicationType: 'responsive',
contentType: 'article',
- useReverb: true,
tests: [...atiAnalyticsTests],
},
{
@@ -255,7 +252,6 @@ const atiAnalyticsTestSuites = [
siteId: 90,
applicationType: 'responsive',
contentType: 'article',
- useReverb: true,
tests: [...atiAnalyticsTests],
},
] as unknown as TestDataType[];
diff --git a/ws-nextjs-app/cypress/support/helpers/runTestsForPage.ts b/ws-nextjs-app/cypress/support/helpers/runTestsForPage.ts
index 4b5b3ffc8f9..c8b4f04d160 100644
--- a/ws-nextjs-app/cypress/support/helpers/runTestsForPage.ts
+++ b/ws-nextjs-app/cypress/support/helpers/runTestsForPage.ts
@@ -11,7 +11,6 @@ export type TestDataType = {
tests: TestType[];
runforEnv: string[];
service: string;
- useReverb?: boolean;
contentType?: string;
applicationType?: string;
siteId?: string;