Skip to content

Commit 1a7bd94

Browse files
add xcust component id
1 parent d0003a9 commit 1a7bd94

File tree

9 files changed

+34
-6
lines changed

9 files changed

+34
-6
lines changed

dotcom-rendering/src/components/Button/ProductLinkButton.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ type ProductLinkButtonProps = {
1818
priority?: ButtonPriority;
1919
minimisePadding?: boolean;
2020
dataComponent?: string;
21+
xCustComponentId?: string;
2122
};
2223

2324
const fullWidthStyle = css`
@@ -53,6 +54,7 @@ export const ProductLinkButton = ({
5354
fullWidthText = false,
5455
priority = 'primary',
5556
dataComponent,
57+
xCustComponentId,
5658
}: ProductLinkButtonProps) => {
5759
const cssOverrides: SerializedStyles[] = [
5860
heightAutoStyle,
@@ -73,6 +75,7 @@ export const ProductLinkButton = ({
7375
data-spacefinder-role="inline"
7476
size={size}
7577
cssOverrides={cssOverrides}
78+
data-x-cust-component-id={xCustComponentId}
7679
>
7780
<span
7881
style={fullWidthText ? { width: '100%' } : {}}

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,15 @@ export const EnhanceAffiliateLinks = () => {
8686
: new URL(document.referrer).hostname;
8787

8888
const skimlinksAccountId = getSkimlinksAccountId(link.href);
89-
89+
const xcustComponentId = link.getAttribute(
90+
'data-x-cust-component-id',
91+
);
9092
// Skimlinks treats xcust as one long string, so we use | to separate values
9193
const xcustValue = `referrer|${referrerDomain}|accountId|${skimlinksAccountId}${
9294
abTestString ? `|abTestParticipations|${abTestString}` : ''
93-
}${utmParamsString ? `|${utmParamsString}` : ''}`;
94-
95+
}${utmParamsString ? `|${utmParamsString}` : ''}${
96+
xcustComponentId ? `|component-id|${xcustComponentId}` : ''
97+
}`;
9598
link.href = `${link.href}&xcust=${encodeURIComponent(
9699
xcustValue,
97100
)}`;

dotcom-rendering/src/components/HorizontalSummaryProductCard.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export const HorizontalSummaryProductCard = ({
9191
<div css={horizontalCard}>
9292
<div css={imageContainer}>
9393
<ProductCardImage
94+
xCustComponentId={'horizontal-summary-card'}
9495
format={format}
9596
image={product.image}
9697
url={cardCta.url}
@@ -114,6 +115,7 @@ export const HorizontalSummaryProductCard = ({
114115
<div css={buttonContainer}>
115116
<ProductLinkButton
116117
size="small"
118+
xCustComponentId="horizontal-summary-card"
117119
fullwidth={true}
118120
minimisePadding={true}
119121
label={'Buy at ' + cardCta.retailer}

dotcom-rendering/src/components/LinkBlockComponent.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export const LinkBlockComponent = ({
4545
case 'ProductButton': {
4646
return (
4747
<ProductLinkButton
48+
xCustComponentId={'product-link-block'}
4849
priority={buttonPriority}
4950
label={label}
5051
url={url}

dotcom-rendering/src/components/ProductCardButtons.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@ const getLabel = (cta: ProductCta): string => {
88

99
export const ProductCardButtons = ({
1010
productCtas,
11+
xCustComponentId,
1112
}: {
1213
productCtas: ProductCta[];
14+
xCustComponentId?: string;
1315
}) => (
1416
<>
1517
{productCtas.map((productCta, index) => {
1618
const label = getLabel(productCta);
1719
return (
1820
<ProductLinkButton
21+
xCustComponentId={xCustComponentId}
1922
key={label}
2023
label={label}
2124
url={productCta.url}

dotcom-rendering/src/components/ProductCardImage.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ interface ProductCardImageProps extends HTMLAttributes<HTMLDivElement> {
99
format: ArticleFormat;
1010
image?: ProductImage;
1111
url?: string;
12+
xCustComponentId?: string;
1213
}
1314

1415
export const ProductCardImage = ({
1516
format,
1617
image,
1718
url,
19+
xCustComponentId,
1820
}: ProductCardImageProps) => {
1921
if (!image) {
2022
return null;
@@ -40,6 +42,7 @@ export const ProductCardImage = ({
4042
target="_blank"
4143
rel="noopener noreferrer"
4244
data-link-name="product image link"
45+
data-x-cust-component-id={xCustComponentId}
4346
// this is needed to override global style
4447
// html:not(.src-focus-disabled) *:focus
4548
// it has specificity(0, 2, 1) so we need (0, 3, 0)

dotcom-rendering/src/components/ProductCardInline.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ export const ProductCardInline = ({
196196
format={format}
197197
image={image}
198198
url={productCtas[0]?.url}
199+
xCustComponentId={'inline-image'}
199200
/>
200201
</div>
201202
<div css={productInfoContainer}>
@@ -214,7 +215,10 @@ export const ProductCardInline = ({
214215
)}
215216
</div>
216217
<div css={buttonWrapper}>
217-
<ProductCardButtons productCtas={productCtas} />
218+
<ProductCardButtons
219+
xCustComponentId={'inline'}
220+
productCtas={productCtas}
221+
/>
218222
</div>
219223
{hasCustomAttributes && (
220224
<div css={customAttributesContainer}>

dotcom-rendering/src/components/ProductCardLeftCol.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ export const ProductCardLeftCol = ({
102102
format={format}
103103
image={image}
104104
url={productCtas[0]?.url}
105+
xCustComponentId={'left-col-image'}
105106
/>
106107
<div css={productInfoContainer}>
107108
<div css={brandNameFont}>{brandName}</div>
@@ -119,7 +120,10 @@ export const ProductCardLeftCol = ({
119120
)}
120121
</div>
121122
<div css={buttonContainer}>
122-
<ProductCardButtons productCtas={productCtas} />
123+
<ProductCardButtons
124+
xCustComponentId={'left-col'}
125+
productCtas={productCtas}
126+
/>
123127
</div>
124128
{customAttributes.length > 0 && (
125129
<div css={customAttributesContainer}>

dotcom-rendering/src/components/ProductCarouselCard.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,11 @@ export const ProductCarouselCard = ({
118118
)}
119119
</div>
120120
<div css={imageArea}>
121-
<ProductCardImage format={format} image={product.image} />
121+
<ProductCardImage
122+
format={format}
123+
image={product.image}
124+
xCustComponentId={'carousel-card-image'}
125+
/>
122126
</div>
123127
<div css={belowImageArea}>
124128
{!hasHeading && (
@@ -132,6 +136,7 @@ export const ProductCarouselCard = ({
132136
<div css={priceStyle}>{firstCta.price}</div>
133137
<div css={buttonWrapper}>
134138
<ProductLinkButton
139+
xCustComponentId={'carousel-card'}
135140
label={`Buy at ${firstCta.retailer}`}
136141
url={firstCta.url}
137142
fullwidth={true}

0 commit comments

Comments
 (0)