From a7cd6af1fbd4472722d65579193238e2424262fb Mon Sep 17 00:00:00 2001 From: hotinglok Date: Mon, 21 Oct 2024 17:52:08 +0100 Subject: [PATCH] Pass down & use producerId --- src/app/pages/ArticlePage/ArticlePage.tsx | 7 ++++- .../experimentTopStories/helpers.test.tsx | 26 ++++++++++++------- .../experimentTopStories/helpers.tsx | 20 +++++++++++--- 3 files changed, 40 insertions(+), 13 deletions(-) diff --git a/src/app/pages/ArticlePage/ArticlePage.tsx b/src/app/pages/ArticlePage/ArticlePage.tsx index 885a292d159..9c0b68a5dfe 100644 --- a/src/app/pages/ArticlePage/ArticlePage.tsx +++ b/src/app/pages/ArticlePage/ArticlePage.tsx @@ -79,6 +79,7 @@ const ArticlePage = ({ pageData }: { pageData: Article }) => { isTrustProjectParticipant, showRelatedTopics, brandName, + atiAnalyticsProducerId, } = useContext(ServiceContext); const { enabled: preloadLeadImageToggle } = useToggle('preloadLeadImage'); @@ -231,7 +232,11 @@ const ArticlePage = ({ pageData }: { pageData: Article }) => { {shouldEnableExperimentTopStories && ( )} diff --git a/src/app/pages/ArticlePage/experimentTopStories/helpers.test.tsx b/src/app/pages/ArticlePage/experimentTopStories/helpers.test.tsx index 74cf7c2646e..fa375672c23 100644 --- a/src/app/pages/ArticlePage/experimentTopStories/helpers.test.tsx +++ b/src/app/pages/ArticlePage/experimentTopStories/helpers.test.tsx @@ -117,6 +117,7 @@ describe('AMP top stories experiment', () => { describe('getExperimentAnalyticsConfig()', () => { process.env.SIMORGH_ATI_BASE_URL = 'http://foobar.com?'; + const PS_NEWS_DESTINATION_ID = 598285; const PS_NEWS_TEST_DESTINATION_ID = 598286; const PS_NEWS_GNL_DESTINATION_ID = 598287; @@ -125,21 +126,28 @@ describe('AMP top stories experiment', () => { const PS_SPORT_TEST_DESTINATION_ID = 598311; const PS_SPORT_GNL_DESTINATION_ID = 598308; const PS_SPORT_GNL_TEST_DESTINATION_ID = 598309; + const NEWS_PRODUCER_ID = 64; + const SPORT_PRODUCER_ID = 85; + it.each` - service | env | destinationId | gnlId - ${'news'} | ${'live'} | ${PS_NEWS_DESTINATION_ID} | ${PS_NEWS_GNL_DESTINATION_ID} - ${'news'} | ${'test'} | ${PS_NEWS_TEST_DESTINATION_ID} | ${PS_NEWS_GNL_TEST_DESINTATION_ID} - ${'sport'} | ${'live'} | ${PS_SPORT_DESTINATION_ID} | ${PS_SPORT_GNL_DESTINATION_ID} - ${'sport'} | ${'test'} | ${PS_SPORT_TEST_DESTINATION_ID} | ${PS_SPORT_GNL_TEST_DESTINATION_ID} + service | env | destinationId | gnlId | producerId + ${'news'} | ${'live'} | ${PS_NEWS_DESTINATION_ID} | ${PS_NEWS_GNL_DESTINATION_ID} | ${NEWS_PRODUCER_ID} + ${'news'} | ${'test'} | ${PS_NEWS_TEST_DESTINATION_ID} | ${PS_NEWS_GNL_TEST_DESINTATION_ID} | ${NEWS_PRODUCER_ID} + ${'sport'} | ${'live'} | ${PS_SPORT_DESTINATION_ID} | ${PS_SPORT_GNL_DESTINATION_ID} | ${SPORT_PRODUCER_ID} + ${'sport'} | ${'test'} | ${PS_SPORT_TEST_DESTINATION_ID} | ${PS_SPORT_GNL_TEST_DESTINATION_ID} | ${SPORT_PRODUCER_ID} `( 'should create the analytics config with the correct parameters for $service on $env.', - ({ env, service, destinationId, gnlId }) => { - const analyticsConfig = getExperimentAnalyticsConfig({ env, service }); + ({ env, service, destinationId, gnlId, producerId }) => { + const analyticsConfig = getExperimentAnalyticsConfig({ + env, + service, + atiAnalyticsProducerId: producerId, + }); expect(analyticsConfig).toMatchInlineSnapshot(` { "requests": { - "topStoriesClick": "http://foobar.com?idclient=123-456-789&s=$IF($EQUALS($MATCH(\${ampGeo}, gbOrUnknown, 0), gbOrUnknown), ${destinationId}, ${gnlId})&s2=64&p=SOURCE_URL&r=\${screenWidth}x\${screenHeight}x\${screenColorDepth}&re=\${availableScreenWidth}x\${availableScreenHeight}&hl=\${timestamp}&lng=\${browserLanguage}&atc=PUB-[article]-[top-stories-promo]-[topStoriesExperiment:VARIANT(topStoriesExperiment)]-[]-[SOURCE_URL]-[]-[]-[]&type=AT", - "topStoriesView": "http://foobar.com?idclient=123-456-789&s=$IF($EQUALS($MATCH(\${ampGeo}, gbOrUnknown, 0), gbOrUnknown), ${destinationId}, ${gnlId})&s2=64&p=SOURCE_URL&r=\${screenWidth}x\${screenHeight}x\${screenColorDepth}&re=\${availableScreenWidth}x\${availableScreenHeight}&hl=\${timestamp}&lng=\${browserLanguage}&ati=PUB-[article]-[top-stories-section]-[topStoriesExperiment:VARIANT(topStoriesExperiment)]-[]-[SOURCE_URL]-[]-[]-[]&type=AT", + "topStoriesClick": "http://foobar.com?idclient=123-456-789&s=$IF($EQUALS($MATCH(\${ampGeo}, gbOrUnknown, 0), gbOrUnknown), ${destinationId}, ${gnlId})&s2=${producerId}&p=SOURCE_URL&r=\${screenWidth}x\${screenHeight}x\${screenColorDepth}&re=\${availableScreenWidth}x\${availableScreenHeight}&hl=\${timestamp}&lng=\${browserLanguage}&atc=PUB-[article]-[top-stories-promo]-[topStoriesExperiment:VARIANT(topStoriesExperiment)]-[]-[SOURCE_URL]-[]-[]-[]&type=AT", + "topStoriesView": "http://foobar.com?idclient=123-456-789&s=$IF($EQUALS($MATCH(\${ampGeo}, gbOrUnknown, 0), gbOrUnknown), ${destinationId}, ${gnlId})&s2=${producerId}&p=SOURCE_URL&r=\${screenWidth}x\${screenHeight}x\${screenColorDepth}&re=\${availableScreenWidth}x\${availableScreenHeight}&hl=\${timestamp}&lng=\${browserLanguage}&ati=PUB-[article]-[top-stories-section]-[topStoriesExperiment:VARIANT(topStoriesExperiment)]-[]-[SOURCE_URL]-[]-[]-[]&type=AT", }, "triggers": { "trackTopStoriesClick": { diff --git a/src/app/pages/ArticlePage/experimentTopStories/helpers.tsx b/src/app/pages/ArticlePage/experimentTopStories/helpers.tsx index 176d4b68315..1d1e0cc3f02 100644 --- a/src/app/pages/ArticlePage/experimentTopStories/helpers.tsx +++ b/src/app/pages/ArticlePage/experimentTopStories/helpers.tsx @@ -36,17 +36,19 @@ const buildTopStoriesEventUrl = ({ type, env, service, + atiAnalyticsProducerId, }: { type: 'view' | 'click'; env: Environments; service: Services; + atiAnalyticsProducerId: string; }) => { return buildATIEventTrackUrl({ campaignID: 'article', componentName: `${type === 'view' ? 'top-stories-section' : 'top-stories-promo'}`, pageIdentifier: 'SOURCE_URL', platform: 'amp', - producerId: '64', + producerId: atiAnalyticsProducerId, statsDestination: `${getStatsDestinationKey({ env, service })}`, variant: `${experimentName}:VARIANT(${experimentName})`, type, @@ -56,14 +58,26 @@ const buildTopStoriesEventUrl = ({ export const getExperimentAnalyticsConfig = ({ env, service, + atiAnalyticsProducerId, }: { env: Environments; service: Services; + atiAnalyticsProducerId: string; }) => { return { requests: { - topStoriesView: buildTopStoriesEventUrl({ type: 'view', env, service }), - topStoriesClick: buildTopStoriesEventUrl({ type: 'click', env, service }), + topStoriesView: buildTopStoriesEventUrl({ + type: 'view', + env, + service, + atiAnalyticsProducerId, + }), + topStoriesClick: buildTopStoriesEventUrl({ + type: 'click', + env, + service, + atiAnalyticsProducerId, + }), }, triggers: { trackTopStoriesView: {