Skip to content

Commit 6a46e1d

Browse files
committed
Remove personalised highlights test
1 parent 599d5c8 commit 6a46e1d

File tree

8 files changed

+4
-615
lines changed

8 files changed

+4
-615
lines changed

dotcom-rendering/src/components/Card/components/CardLink.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,16 @@ type Props = {
2121
headlineText: string;
2222
dataLinkName?: string;
2323
isExternalLink: boolean;
24-
trackCardClick?: () => void;
2524
};
2625

2726
const InternalLink = ({
2827
linkTo,
2928
headlineText,
3029
dataLinkName,
31-
trackCardClick,
3230
}: {
3331
linkTo: string;
3432
headlineText: string;
3533
dataLinkName?: string;
36-
trackCardClick?: () => void;
3734
}) => {
3835
return (
3936
// eslint-disable-next-line jsx-a11y/anchor-has-content -- we have an aria-label attribute describing the content
@@ -42,7 +39,6 @@ const InternalLink = ({
4239
css={fauxLinkStyles}
4340
data-link-name={dataLinkName}
4441
aria-label={headlineText}
45-
onClick={trackCardClick}
4642
/>
4743
);
4844
};
@@ -77,7 +73,6 @@ export const CardLink = ({
7773
headlineText,
7874
dataLinkName = 'article', //this makes sense if the link is to an article, but should this say something like "external" if it's an external link? are there any other uses/alternatives?
7975
isExternalLink,
80-
trackCardClick,
8176
}: Props) => {
8277
return (
8378
<>
@@ -86,15 +81,13 @@ export const CardLink = ({
8681
linkTo={linkTo}
8782
headlineText={headlineText}
8883
dataLinkName={dataLinkName}
89-
trackCardClick={trackCardClick}
9084
/>
9185
)}
9286
{!isExternalLink && (
9387
<InternalLink
9488
linkTo={linkTo}
9589
headlineText={headlineText}
9690
dataLinkName={dataLinkName}
97-
trackCardClick={trackCardClick}
9891
/>
9992
)}
10093
</>

dotcom-rendering/src/components/DecideContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ export const DecideContainer = ({
235235
return <NavList trails={trails} showImage={true} />;
236236
case 'scrollable/highlights':
237237
return (
238-
<Island priority="critical">
238+
<Island priority="critical" defer={{ until: 'visible' }}>
239239
<ScrollableHighlights trails={trails} frontId={frontId} />
240240
</Island>
241241
);

dotcom-rendering/src/components/Masthead/HighlightsCard.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export type HighlightsCardProps = {
3232
byline?: string;
3333
isExternalLink: boolean;
3434
starRating?: Rating;
35-
trackCardClick: () => void;
3635
};
3736

3837
const container = css`
@@ -134,7 +133,6 @@ export const HighlightsCard = ({
134133
byline,
135134
isExternalLink,
136135
starRating,
137-
trackCardClick,
138136
}: HighlightsCardProps) => {
139137
const isMediaCard = isMedia(format);
140138

@@ -146,7 +144,6 @@ export const HighlightsCard = ({
146144
headlineText={headlineText}
147145
dataLinkName={dataLinkName}
148146
isExternalLink={isExternalLink}
149-
trackCardClick={trackCardClick}
150147
/>
151148

152149
<div css={content}>

dotcom-rendering/src/components/ScrollableHighlights.importable.tsx

Lines changed: 2 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { css } from '@emotion/react';
2-
import type { ABTestAPI as ABTestAPIType } from '@guardian/ab-core';
32
import { from, space } from '@guardian/source/foundations';
43
import {
54
Button,
@@ -8,16 +7,8 @@ import {
87
SvgChevronRightSingle,
98
} from '@guardian/source/react-components';
109
import { useEffect, useRef, useState } from 'react';
11-
import { submitComponentEvent } from '../client/ophan/ophan';
1210
import { getZIndex } from '../lib/getZIndex';
1311
import { ophanComponentId } from '../lib/ophan-helpers';
14-
import {
15-
clearHighlightsState,
16-
getOrderedHighlights,
17-
onHighlightEvent,
18-
resetHighlightsState,
19-
} from '../lib/personaliseHighlights';
20-
import { useAB } from '../lib/useAB';
2112
import { palette } from '../palette';
2213
import type { DCRFrontCard } from '../types/front';
2314
import { HighlightsCard } from './Masthead/HighlightsCard';
@@ -86,10 +77,6 @@ const carouselStyles = css`
8677
position: relative;
8778
`;
8879

89-
const scrollSnapStyles = css`
90-
scroll-snap-type: x mandatory;
91-
`;
92-
9380
const itemStyles = css`
9481
scroll-snap-align: start;
9582
grid-area: span 1;
@@ -219,55 +206,12 @@ const getOphanInfo = (frontId?: string) => {
219206
};
220207
};
221208

222-
const isEqual = (
223-
historicalHighlights: DCRFrontCard[],
224-
currentHighlights: DCRFrontCard[],
225-
) => {
226-
const c = currentHighlights.map((v) => v.url);
227-
const h = historicalHighlights.map((v) => v.url);
228-
return c.every((v) => {
229-
return h.includes(v);
230-
});
231-
};
232209
export const ScrollableHighlights = ({ trails, frontId }: Props) => {
233210
const carouselRef = useRef<HTMLOListElement | null>(null);
234211
const carouselLength = trails.length;
235212
const imageLoading = 'eager';
236213
const [showPreviousButton, setShowPreviousButton] = useState(false);
237214
const [showNextButton, setShowNextButton] = useState(true);
238-
const [shouldShowHighlights, setShouldShowHighlights] = useState(false);
239-
const [orderedTrails, setOrderedTrails] = useState<DCRFrontCard[]>(trails);
240-
241-
const ABTestAPI = useAB()?.api;
242-
243-
type Attr =
244-
| 'click-tracking'
245-
| 'view-tracking'
246-
| 'click-and-view-tracking'
247-
| 'not-in-test'
248-
| undefined;
249-
250-
const getUserABAttr = (api?: ABTestAPIType): Attr => {
251-
if (!api) return undefined;
252-
253-
if (api.isUserInVariant('PersonalisedHighlights', 'click-tracking')) {
254-
return 'click-tracking';
255-
}
256-
if (api.isUserInVariant('PersonalisedHighlights', 'view-tracking')) {
257-
return 'view-tracking';
258-
}
259-
if (
260-
api.isUserInVariant(
261-
'PersonalisedHighlights',
262-
'click-and-view-tracking',
263-
)
264-
) {
265-
return 'click-and-view-tracking';
266-
}
267-
return 'not-in-test';
268-
};
269-
270-
const abTestPersonalisedHighlightAttr = getUserABAttr(ABTestAPI);
271215

272216
const scrollTo = (direction: 'left' | 'right') => {
273217
if (!carouselRef.current) return;
@@ -302,15 +246,6 @@ export const ScrollableHighlights = ({ trails, frontId }: Props) => {
302246
setShowNextButton(scrollLeft < maxScrollLeft);
303247
};
304248

305-
useEffect(() => {
306-
if (
307-
abTestPersonalisedHighlightAttr === 'view-tracking' ||
308-
abTestPersonalisedHighlightAttr === 'click-and-view-tracking'
309-
) {
310-
onHighlightEvent('VIEW');
311-
}
312-
}, [abTestPersonalisedHighlightAttr]);
313-
314249
useEffect(() => {
315250
const carouselElement = carouselRef.current;
316251
if (!carouselElement) return;
@@ -328,57 +263,11 @@ export const ScrollableHighlights = ({ trails, frontId }: Props) => {
328263
};
329264
}, []);
330265

331-
useEffect(() => {
332-
if (abTestPersonalisedHighlightAttr === undefined) {
333-
return;
334-
}
335-
336-
if (abTestPersonalisedHighlightAttr === 'not-in-test') {
337-
clearHighlightsState();
338-
setOrderedTrails(trails);
339-
setShouldShowHighlights(true);
340-
return;
341-
}
342-
343-
const personalisedHighlights = getOrderedHighlights(trails);
344-
if (
345-
personalisedHighlights.length === 0 ||
346-
personalisedHighlights.length !== trails.length ||
347-
!isEqual(personalisedHighlights, trails)
348-
) {
349-
/* Reset to editorial order */
350-
resetHighlightsState(trails);
351-
setOrderedTrails(trails);
352-
setShouldShowHighlights(true);
353-
return;
354-
}
355-
/* Otherwise, use personalised order from local storage */
356-
setOrderedTrails(personalisedHighlights);
357-
setShouldShowHighlights(true);
358-
/* Fire a view event only if the container has been personalised */
359-
void submitComponentEvent(
360-
{
361-
component: {
362-
componentType: 'CONTAINER',
363-
id: `reordered-highlights-container`,
364-
},
365-
action: 'VIEW',
366-
},
367-
'Web',
368-
);
369-
}, [trails, abTestPersonalisedHighlightAttr]);
370-
371266
const { ophanComponentLink, ophanComponentName, ophanFrontName } =
372267
getOphanInfo(frontId);
373268

374269
return (
375-
<div
376-
css={[
377-
containerStyles,
378-
{ visibility: shouldShowHighlights ? 'visible' : 'hidden' },
379-
]}
380-
data-link-name={ophanFrontName}
381-
>
270+
<div css={containerStyles} data-link-name={ophanFrontName}>
382271
<ol
383272
data-link-name={ophanComponentLink}
384273
data-component={ophanComponentName}
@@ -387,16 +276,10 @@ export const ScrollableHighlights = ({ trails, frontId }: Props) => {
387276
css={[
388277
carouselStyles,
389278
generateCarouselColumnStyles(carouselLength),
390-
/*
391-
* Enable scroll-snap only when visible to prevent browser scroll anchoring.
392-
* When items reorder, browsers try to keep previously visible items in view,
393-
* causing unwanted scrolling. Enabling snap after reordering forces position 0.
394-
// */
395-
shouldShowHighlights && scrollSnapStyles,
396279
]}
397280
data-heatphan-type="carousel"
398281
>
399-
{orderedTrails.map((trail) => {
282+
{trails.map((trail) => {
400283
return (
401284
<li
402285
key={trail.url}
@@ -416,16 +299,6 @@ export const ScrollableHighlights = ({ trails, frontId }: Props) => {
416299
showQuotedHeadline={trail.showQuotedHeadline}
417300
mainMedia={trail.mainMedia}
418301
starRating={trail.starRating}
419-
trackCardClick={() => {
420-
if (
421-
abTestPersonalisedHighlightAttr ===
422-
'click-tracking' ||
423-
abTestPersonalisedHighlightAttr ===
424-
'click-and-view-tracking'
425-
) {
426-
onHighlightEvent('CLICK', trail);
427-
}
428-
}}
429302
/>
430303
</li>
431304
);
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
import type { ABTest } from '@guardian/ab-core';
22
import { abTestTest } from './tests/ab-test-test';
33
import { noAuxiaSignInGate } from './tests/no-auxia-sign-in-gate';
4-
import { personalisedHighlights } from './tests/personalised-highlights';
54
import { userBenefitsApi } from './tests/user-benefits-api';
65

76
// keep in sync with ab-tests in frontend
87
// https://github.com/guardian/frontend/tree/main/static/src/javascripts/projects/common/modules/experiments/ab-tests.ts
9-
export const tests: ABTest[] = [
10-
abTestTest,
11-
userBenefitsApi,
12-
personalisedHighlights,
13-
noAuxiaSignInGate,
14-
];
8+
export const tests: ABTest[] = [abTestTest, userBenefitsApi, noAuxiaSignInGate];

dotcom-rendering/src/experiments/tests/personalised-highlights.ts

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)