Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QM Generic Checkout Updates : Payment Method Selected #6406

Merged
merged 4 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
trackComponentClick,
trackComponentInsert,
} from 'helpers/tracking/behaviour';
import { sendEventContributionPaymentMethod } from 'helpers/tracking/quantumMetric';
import { sendEventPaymentMethodSelected } from 'helpers/tracking/quantumMetric';
import type { PaymentMethodSelectorProps } from './paymentMethodSelector';

type PaymentMethodSelectorContainerProps = {
Expand Down Expand Up @@ -64,7 +64,7 @@ function PaymentMethodSelectorContainer({

if (event === 'select') {
trackComponentClick(trackingId);
sendEventContributionPaymentMethod(paymentMethod);
sendEventPaymentMethodSelected(paymentMethod);
dispatch(setPaymentMethod({ paymentMethod }));
} else {
trackComponentInsert(trackingId);
Expand Down
6 changes: 3 additions & 3 deletions support-frontend/assets/helpers/tracking/quantumMetric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ function sendEventContributionCartValue(
});
}

function sendEventContributionPaymentMethod(
paymentMethod: PaymentMethod | null,
function sendEventPaymentMethodSelected(
paymentMethod: PaymentMethod | 'StripeExpressCheckoutElement' | null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PaymentMethod type is starting to feel like a code smell, maybe it will become clearer once we remove the old checkouts

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah agreed, this was copy & paste of a work around applied on the generic checkout, but certainly we could do with revisiting this when we start removing the old checkouts.

): void {
if (paymentMethod) {
void ifQmPermitted(() => {
Expand Down Expand Up @@ -446,7 +446,7 @@ export {
sendEventSubscriptionCheckoutConversion,
sendEventContributionCheckoutConversion,
sendEventContributionCartValue,
sendEventContributionPaymentMethod,
sendEventPaymentMethodSelected,
sendEventConversionPaymentMethod,
sendEventAcquisitionDataFromQueryParamEvent,
};
10 changes: 10 additions & 0 deletions support-frontend/assets/pages/[countryGroupId]/checkout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ import {
getSupportAbTests,
} from 'helpers/tracking/acquisitions';
import { trackComponentClick } from 'helpers/tracking/behaviour';
import { sendEventPaymentMethodSelected } from 'helpers/tracking/quantumMetric';
import { isProd } from 'helpers/urls/url';
import { logException } from 'helpers/utilities/logger';
import type { GeoId } from 'pages/geoIdConfig';
Expand Down Expand Up @@ -1119,6 +1120,12 @@ function CheckoutComponent({
const options = {
emailRequired: true,
};

// Track payment method selection with QM
sendEventPaymentMethodSelected(
'StripeExpressCheckoutElement',
);

resolve(options);
}}
onConfirm={async (event) => {
Expand Down Expand Up @@ -1576,6 +1583,9 @@ function CheckoutComponent({
}
onChange={() => {
setPaymentMethod(validPaymentMethod);

// Track payment method selection with QM
sendEventPaymentMethodSelected(validPaymentMethod);
}}
/>
</PaymentMethodRadio>
Expand Down
10 changes: 10 additions & 0 deletions support-frontend/assets/pages/[countryGroupId]/oneTimeCheckout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import {
getReferrerAcquisitionData,
} from 'helpers/tracking/acquisitions';
import { trackComponentLoad } from 'helpers/tracking/behaviour';
import { sendEventPaymentMethodSelected } from 'helpers/tracking/quantumMetric';
import { payPalCancelUrl, payPalReturnUrl } from 'helpers/urls/routes';
import { logException } from 'helpers/utilities/logger';
import { type GeoId, getGeoIdConfig } from 'pages/geoIdConfig';
Expand Down Expand Up @@ -582,6 +583,12 @@ function OneTimeCheckoutComponent({
const options = {
emailRequired: true,
};

// Track payment method selection with QM
sendEventPaymentMethodSelected(
'StripeExpressCheckoutElement',
);

resolve(options);
}
}}
Expand Down Expand Up @@ -740,6 +747,9 @@ function OneTimeCheckoutComponent({
}
onChange={() => {
setPaymentMethod(validPaymentMethod);

// Track payment method selection with QM
sendEventPaymentMethodSelected(validPaymentMethod);
}}
/>
</PaymentMethodRadio>
Expand Down
Loading