Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Restructure data cohesion API can accept
Browse files Browse the repository at this point in the history
julianajlk committed Nov 7, 2024
1 parent 52504dc commit c5723f4
Showing 7 changed files with 10 additions and 27 deletions.
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@
writeKey: '<%= htmlWebpackPlugin?.options?.cohesionConfig?.tagularWriteKey %>',
sourceKey: '<%= htmlWebpackPlugin?.options?.cohesionConfig?.tagularSourceKey %>',
cookieDomain: '<%= htmlWebpackPlugin?.options?.cohesionConfig?.tagularCookieDomain %>',
domainWhitelist: `<%= htmlWebpackPlugin?.options?.cohesionConfig?.tagularDomainWhitelist %>`,
domainWhitelist: <%= htmlWebpackPlugin?.options?.cohesionConfig?.tagularDomainWhitelist %>,
apiVersion: 'v2/t',
multiparty: true,
taggy: { enabled: true },
5 changes: 1 addition & 4 deletions src/feedback/AlertMessage.jsx
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import PropTypes from 'prop-types';
import { Alert } from '@openedx/paragon';
import { ALERT_TYPES, MESSAGE_TYPES } from './data/constants';
import { trackElementIntersection } from '../payment/data/actions';
import { ElementType, PageData, IS_FULLY_SHOWN_THRESHOLD_OR_MARGIN } from '../cohesion/constants';
import { ElementType, IS_FULLY_SHOWN_THRESHOLD_OR_MARGIN } from '../cohesion/constants';

// Put in a message type, get an alert type.
const severityMap = {
@@ -31,9 +31,6 @@ const AlertMessage = (props) => {
entries.forEach(entry => {
if (entry.isIntersecting && entry.target?.innerText.includes('added to basket')) {
const tagularElement = {
title: PageData.PaymentTitle,
url: entry.target?.baseURI,
pageType: PageData.PageType,
elementType: ElementType.Button,
name: 'promotional-code',
text: 'Apply',
8 changes: 1 addition & 7 deletions src/payment/checkout/Checkout.jsx
Original file line number Diff line number Diff line change
@@ -73,9 +73,6 @@ class Checkout extends React.Component {

// Red Ventures Cohesion Tagular Event Tracking for PayPal
const tagularElement = {
title: PageData.PaymentTitle,
url: window.location.href,
pageType: PageData.PageType,
elementType: ElementType.Button,
text: paymentMethod,
name: paymentMethod.toLowerCase(),
@@ -131,10 +128,7 @@ class Checkout extends React.Component {
handleSubmitStripe = (formData) => {
// Red Ventures Cohesion Tagular Event Tracking for Stripe
const tagularElement = {
title: PageData.PaymentTitle,
url: window.location.href,
pageType: PageData.PageType,
timestamp: Date.now(),
timestamp: Date.now().toString(),
productList: this.getProductList(),
};

5 changes: 1 addition & 4 deletions src/payment/checkout/payment-form/PlaceOrderButton.jsx
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
import { injectIntl, FormattedMessage } from '@edx/frontend-platform/i18n';
import { StatefulButton } from '@openedx/paragon';
import { trackElementIntersection } from '../../data/actions';
import { ElementType, PageData, IS_FULLY_SHOWN_THRESHOLD_OR_MARGIN } from '../../../cohesion/constants';
import { ElementType, IS_FULLY_SHOWN_THRESHOLD_OR_MARGIN } from '../../../cohesion/constants';

const PlaceOrderButton = ({
showLoadingButton, onSubmitButtonClick, stripeSelectedPaymentMethod, disabled, isProcessing,
@@ -24,9 +24,6 @@ const PlaceOrderButton = ({
entries.forEach(entry => {
if (entry.isIntersecting) {
const tagularElement = {
title: PageData.PaymentTitle,
url: window.location.href,
pageType: PageData.PageType,
elementType: ElementType.Button,
position: 'placeOrderButton',
name: 'stripe',
4 changes: 1 addition & 3 deletions src/payment/data/actions.js
Original file line number Diff line number Diff line change
@@ -115,9 +115,7 @@ export const trackElementIntersection = tagularElement => {
// Note: For the coupon code banner, we're using an elementViewed as a click event
// ('BUTTON' on coupon Apply click, but it's when the banner is viewed).
const viewedEvent = {
correlation: {
id: getCorrelationID(),
},
correlationId: getCorrelationID(),
webElement: tagularElement,
};
tagularEvent('ElementViewed', viewedEvent);
8 changes: 4 additions & 4 deletions src/payment/data/sagas.js
Original file line number Diff line number Diff line change
@@ -241,8 +241,8 @@ export function* handleSubmitPayment({ payload }) {
// Metada for conversion_category and conversion_action:
// Sucessful payment = 'Order' and 'Completed'
// Failed payment = 'Enrollment' and 'Declined'
tagularElement.conversion_category = 'Order';
tagularElement.conversion_action = 'Completed';
tagularElement.category = 'Order';
tagularElement.action = 'Completed';
yield put(trackPaymentButtonClick(tagularElement));
}
} catch (error) {
@@ -255,8 +255,8 @@ export function* handleSubmitPayment({ payload }) {
} else {
// RV tracking for failed Stripe Payment
if (method === 'stripe') {
tagularElement.conversion_category = 'Enrollment';
tagularElement.conversion_action = 'Declined';
tagularElement.category = 'Enrollment';
tagularElement.action = 'Declined';
yield put(trackPaymentButtonClick(tagularElement));
}
yield call(handleErrors, error, true);
5 changes: 1 addition & 4 deletions src/payment/payment-methods/paypal/PayPalButton.jsx
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import { useDispatch } from 'react-redux';
import PropTypes from 'prop-types';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import { trackElementIntersection } from '../../data/actions';
import { ElementType, PageData, IS_FULLY_SHOWN_THRESHOLD_OR_MARGIN } from '../../../cohesion/constants';
import { ElementType, IS_FULLY_SHOWN_THRESHOLD_OR_MARGIN } from '../../../cohesion/constants';

import PayPalLogo from './assets/paypal-logo.png';
import messages from './PayPalButton.messages';
@@ -19,9 +19,6 @@ const PayPalButton = ({ intl, isProcessing, ...props }) => {
if (entry.isIntersecting) {
const elementId = entry.target?.id;
const tagularElement = {
title: PageData.PaymentTitle,
url: window.location.href,
pageType: PageData.PageType,
elementType: ElementType.Button,
position: elementId,
name: 'paypal',

0 comments on commit c5723f4

Please sign in to comment.