From f58f33ee3142b0855a2615a271c8aec77b7ec327 Mon Sep 17 00:00:00 2001 From: ayeshoali Date: Tue, 15 Oct 2024 16:48:16 +0500 Subject: [PATCH 1/4] feat: added cohesion events tracking --- public/index.html | 96 ++++++++++++++----- src/common-components/SocialAuthProviders.jsx | 15 ++- src/data/cohesion/utils.js | 37 +++++++ src/data/constants.js | 11 +++ src/login/LoginPage.jsx | 6 +- src/login/messages.jsx | 5 + src/register/RegistrationPage.jsx | 7 +- .../ConfigurableRegistrationForm.jsx | 8 ++ src/register/messages.jsx | 11 +++ src/tracking/trackers/login.js | 6 ++ src/tracking/trackers/register.js | 7 ++ 11 files changed, 179 insertions(+), 30 deletions(-) create mode 100644 src/data/cohesion/utils.js diff --git a/public/index.html b/public/index.html index 2c851c7b65..196e20e76b 100644 --- a/public/index.html +++ b/public/index.html @@ -1,26 +1,78 @@ - - <%= (process.env.SITE_NAME && process.env.SITE_NAME != 'null') ? 'Authentication | ' + process.env.SITE_NAME : 'Authentication' %> - - - - - <% if (process.env.OPTIMIZELY_URL) { %> - - <% } else if (process.env.OPTIMIZELY_PROJECT_ID) { %> - + + + + <%= (process.env.SITE_NAME && process.env.SITE_NAME !='null' ) ? 'Authentication | ' + process.env.SITE_NAME + : 'Authentication' %> + + + + + + + + + + + + <% if (process.env.OPTIMIZELY_URL) { %> + + <% } else if (process.env.OPTIMIZELY_PROJECT_ID) { %> + <% } %> - - -
- + + + + + +
+ + diff --git a/src/common-components/SocialAuthProviders.jsx b/src/common-components/SocialAuthProviders.jsx index f76e49684c..ae666ed3fe 100644 --- a/src/common-components/SocialAuthProviders.jsx +++ b/src/common-components/SocialAuthProviders.jsx @@ -9,16 +9,25 @@ import { Login } from '@openedx/paragon/icons'; import PropTypes from 'prop-types'; import messages from './messages'; -import { LOGIN_PAGE, REGISTER_PAGE, SUPPORTED_ICON_CLASSES } from '../data/constants'; +import { + ELEMENT_TYPES, LOGIN_PAGE, REGISTER_PAGE, SUPPORTED_ICON_CLASSES, +} from '../data/constants'; import { setCookie } from '../data/utils'; +import { trackSignIn } from '../tracking/trackers/login'; +import { trackAccountCreationEvents } from '../tracking/trackers/register'; const SocialAuthProviders = (props) => { const { formatMessage } = useIntl(); const { referrer, socialAuthProviders } = props; const registrationFields = useSelector(state => state.register.registrationFormData); - function handleSubmit(e) { + function handleSubmit(e, providerName) { e.preventDefault(); + if (referrer === LOGIN_PAGE) { + trackSignIn(ELEMENT_TYPES.BUTTON, providerName.toLowerCase(), providerName); + } else { + trackAccountCreationEvents(ELEMENT_TYPES.BUTTON, providerName.toLowerCase(), providerName); + } if (referrer === REGISTER_PAGE) { setCookie('marketingEmailsOptIn', registrationFields?.configurableFormFields?.marketingEmailsOptIn); @@ -34,7 +43,7 @@ const SocialAuthProviders = (props) => { type="button" className={`btn-social btn-${provider.id} ${index % 2 === 0 ? 'mr-3' : ''}`} data-provider-url={referrer === LOGIN_PAGE ? provider.loginUrl : provider.registerUrl} - onClick={handleSubmit} + onClick={(e) => handleSubmit(e, provider.name)} > {provider.iconImage ? (