Skip to content

Commit

Permalink
fix: Click events are not the same, updating event structure
Browse files Browse the repository at this point in the history
  • Loading branch information
julianajlk committed Nov 6, 2024
1 parent 25a7891 commit d463f22
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
3 changes: 1 addition & 2 deletions src/payment/checkout/Checkout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ class Checkout extends React.Component {
title: PaymentTitle,
url: window.location.href,
pageType: 'checkout',
elementType: ElementType.Button,
timestamp: Date.now(),
productList: this.getProductList(),
};
Expand Down Expand Up @@ -170,7 +169,7 @@ class Checkout extends React.Component {
if (products || products.length !== 0) {
products.forEach(product => {
productList.push({
variant: BaseTagularVariant.Courses,
variant: BaseTagularVariant.Courses, // TODO: all are 'courses' now, use translateVariant() in the future
brand: this.getPartnerName(product), // School or Partner name
name: product.title, // Course(s) title
});
Expand Down
30 changes: 21 additions & 9 deletions src/payment/data/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,30 @@ export const TRACK_PAYMENT_BUTTON_CLICK = 'TRACK_PAYMENT_BUTTON_CLICK';

export const trackPaymentButtonClick = tagularElement => {
// Ideally this would happen in a middleware saga for separation of concerns
// but due to deadlines/payment MFE will go away, adding a call here
const conversionEvent = {
correlation: {
id: getCorrelationID(),
},
metadata: tagularElement,
};
tagularEvent('ConversionTracked', conversionEvent);
// but due to deadlines/payment MFE will go away, adding a call here.
// Note: Click events on the PayPal button and Place Order button differ in the type of event data it's treated as.
let payload;
if (tagularElement.name === 'paypal') {
payload = {
correlation: {
id: getCorrelationID(),
},
webElement: tagularElement,
};
tagularEvent('ElementClicked', payload);
} else {
payload = {
correlation: {
id: getCorrelationID(),
},
metadata: tagularElement,
};
tagularEvent('ConversionTracked', payload);
}

return {
type: TRACK_PAYMENT_BUTTON_CLICK,
payload: conversionEvent,
payload,
};
};

Expand Down

0 comments on commit d463f22

Please sign in to comment.