Skip to content

Commit cca3512

Browse files
authored
Merge branch 'latest' into WS-2080-fetch-config-function
2 parents 36d2f76 + 7240cb4 commit cca3512

File tree

25 files changed

+2595
-586
lines changed

25 files changed

+2595
-586
lines changed

src/app/components/MostRead/index.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ interface MostReadProps {
3333
headingBackgroundColour?: string;
3434
className?: string;
3535
eventTrackingData?: EventTrackingData;
36+
experimentProps?: {
37+
sendOptimizelyEvents: boolean;
38+
experimentName: string;
39+
experimentVariant: string;
40+
};
3641
}
3742

3843
// We render amp on ONLY STY, CSP and ARTICLE pages using amp-list.
@@ -104,6 +109,7 @@ const MostRead = ({
104109
mobileDivider = false,
105110
headingBackgroundColour = WHITE,
106111
className = '',
112+
experimentProps,
107113
eventTrackingData,
108114
}: MostReadProps) => {
109115
const { isAmp, pageType, variant } = use(RequestContext);
@@ -129,6 +135,14 @@ const MostRead = ({
129135
variant,
130136
isBff,
131137
});
138+
// Use the eventTrackingData prop if provided, otherwise construct a minimal default
139+
// this is because most read is used on both the article page and the home page
140+
// on the home page, we have an object containing more information passed in
141+
// on the article page we don't have all of these pieces of data (do we need it?), but we do need the optimizely props
142+
const trackingData = eventTrackingData || {
143+
componentName: 'most-read',
144+
...(experimentProps && experimentProps),
145+
};
132146

133147
return isAmp ? (
134148
<AmpMostRead
@@ -147,7 +161,7 @@ const MostRead = ({
147161
headingBackgroundColour={headingBackgroundColour}
148162
columnLayout={columnLayout}
149163
size={size}
150-
eventTrackingData={eventTrackingData}
164+
eventTrackingData={trackingData}
151165
/>
152166
);
153167
};

src/app/components/Recommendations/RecommendationsItem/index.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@ import { use } from 'react';
33
import { RequestContext } from '#contexts/RequestContext';
44
import useClickTrackerHandler from '#app/hooks/useClickTrackerHandler';
55
import { Recommendation } from '#app/models/types/onwardJourney';
6+
import { EventTrackingData } from '#app/lib/analyticsUtils/types';
67
import RecommendationsImage from '../RecommendationsPromoImage';
78
import styles from './index.styles';
89

9-
const eventTrackingData = {
10-
componentName: 'midarticle-mostread',
11-
};
12-
1310
const RecommendationsItem = ({
1411
recommendation,
12+
eventTrackingData,
1513
}: {
1614
recommendation: Recommendation | null;
15+
eventTrackingData?: EventTrackingData;
1716
}) => {
1817
const { isLite } = use(RequestContext);
1918

0 commit comments

Comments
 (0)