Skip to content

Commit

Permalink
feat: abtest setup routing to generic checkout
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-daniel-dempsey committed Jan 30, 2025
1 parent 0450b01 commit 47605d8
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 3 deletions.
21 changes: 21 additions & 0 deletions support-frontend/assets/helpers/abTests/abtestDefinitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,25 @@ export const tests: Tests = {
targetPage: pageUrlRegexes.contributions.allLandingPagesAndThankyouPages,
excludeContributionsOnlyCountries: true,
},
digitalEditionCheckout: {
variants: [
{
id: 'control',
},
{
id: 'variant',
},
],
audiences: {
ALL: {
offset: 0,
size: 1,
},
},
isActive: false,
referrerControlled: false, // ab-test name not needed to be in paramURL
seed: 2,
targetPage: pageUrlRegexes.contributions.allLandingPagesAndThankyouPages,
excludeContributionsOnlyCountries: false,
},
};
2 changes: 1 addition & 1 deletion support-frontend/assets/helpers/urls/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function digitalSubscriptionLanding(
billingPeriod?: BillingPeriod,
) {
const routeDigitalSubscription = billingPeriod
? routes.checkout
? `${routes.checkout}?product=DigitalSubscription&ratePlan=${billingPeriod}`
: routes.digitalSubscriptionLanding;
return `${getOrigin()}/${countryPath(
countryGroupId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function getGuardianWeeklyOfferCopy(discountCopy: string) {
return '';
}

const digital = (
const digitalEdition = (
countryGroupId: CountryGroupId,
priceCopy: PriceCopy,
): ProductCopy => ({
Expand All @@ -87,6 +87,37 @@ const digital = (
offer: priceCopy.discountCopy,
});

export function digitalCheckout(
countryGroupId: CountryGroupId,
priceCopy: PriceCopy,
): ProductCopy {
return {
...digitalEdition(countryGroupId, priceCopy),
buttons: [
{
ctaButtonText: 'Subscribe Monthly',
link: digitalSubscriptionLanding(countryGroupId, 'Monthly'),
analyticsTracking: sendTrackingEventsOnClick({
id: 'digipack_monthly_cta',
product: 'DigitalPack',
componentType: 'ACQUISITIONS_BUTTON',
}),
modifierClasses: 'digital',
},
{
ctaButtonText: 'Subscribe Annually',
link: digitalSubscriptionLanding(countryGroupId, 'Annual'),
analyticsTracking: sendTrackingEventsOnClick({
id: 'digipack_annual_cta',
product: 'DigitalPack',
componentType: 'ACQUISITIONS_BUTTON',
}),
modifierClasses: 'digital',
},
],
};
}

const guardianWeekly = (
countryGroupId: CountryGroupId,
priceCopy: PriceCopy,
Expand Down Expand Up @@ -152,13 +183,20 @@ const getSubscriptionCopy = (
pricingCopy: PricingCopy,
participations: Participations,
): ProductCopy[] => {
const inDigitalEditionCheckout =
participations.digitalEditionCheckout === 'variant';

const productcopy: ProductCopy[] = [
guardianWeekly(countryGroupId, pricingCopy[GuardianWeekly], participations),
];
if (countryGroupId === GBPCountries) {
productcopy.push(paper(countryGroupId, pricingCopy[Paper]));
}
productcopy.push(digital(countryGroupId, pricingCopy[DigitalPack]));
productcopy.push(
inDigitalEditionCheckout
? digitalCheckout(countryGroupId, pricingCopy[DigitalPack])
: digitalEdition(countryGroupId, pricingCopy[DigitalPack]),
);
return productcopy;
};

Expand Down

0 comments on commit 47605d8

Please sign in to comment.