Skip to content

Commit

Permalink
fix: triggered login event on success
Browse files Browse the repository at this point in the history
  • Loading branch information
awais-ansari committed Oct 18, 2024
1 parent b69ed6e commit 501bd91
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
6 changes: 6 additions & 0 deletions src/common-components/RedirectLogistration.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { useSelector } from 'react-redux';

import { getConfig } from '@edx/frontend-platform';
import PropTypes from 'prop-types';
import { Navigate } from 'react-router-dom';

import trackCohesionEvent from '../cohesion/trackers';
import {
AUTHN_PROGRESSIVE_PROFILING, RECOMMENDATIONS, REDIRECT,
} from '../data/constants';
Expand All @@ -21,9 +24,12 @@ const RedirectLogistration = (props) => {
registrationEmbedded,
host,
} = props;
const cohesionEventData = useSelector(state => state.cohesion.eventData);
let finalRedirectUrl = '';

if (success) {
// This event is used by cohestion upon successful login
trackCohesionEvent(cohesionEventData);
// If we're in a third party auth pipeline, we must complete the pipeline
// once user has successfully logged in. Otherwise, redirect to the specified redirect url.
// Note: For multiple enterprise use case, we need to make sure that user first visits the
Expand Down
9 changes: 2 additions & 7 deletions src/login/LoginPage.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useMemo, useState } from 'react';
import { connect, useDispatch, useSelector } from 'react-redux';
import { connect, useDispatch } from 'react-redux';

import { getConfig } from '@edx/frontend-platform';
import { injectIntl, useIntl } from '@edx/frontend-platform/i18n';
Expand All @@ -24,7 +24,6 @@ import {
ELEMENT_NAME, ELEMENT_TEXT, ELEMENT_TYPES, PAGE_TYPES,
} from '../cohesion/constants';
import { setCohesionEventStates } from '../cohesion/data/actions';
import trackCohesionEvent from '../cohesion/trackers';
import {
FormGroup,
InstitutionLogistration,
Expand Down Expand Up @@ -78,7 +77,6 @@ const LoginPage = (props) => {
const dispatch = useDispatch();
const activationMsgType = getActivationStatus();
const queryParams = useMemo(() => getAllPossibleQueryParams(), []);
const cohesionEventData = useSelector(state => state.cohesion.eventData);

const [formFields, setFormFields] = useState({ ...backedUpFormData.formFields });
const [errorCode, setErrorCode] = useState({ type: '', count: 0, context: {} });
Expand All @@ -92,13 +90,10 @@ const LoginPage = (props) => {
useEffect(() => {
if (loginResult.success) {
trackLoginSuccess();
// This event is used by cohestion upon successful login
trackCohesionEvent(cohesionEventData);

// Remove this cookie that was set to capture marketingEmailsOptIn for the onboarding component
removeCookie('ssoPipelineRedirectionDone');
}
}, [loginResult, cohesionEventData]);
}, [loginResult]);

useEffect(() => {
const payload = { ...queryParams };
Expand Down

0 comments on commit 501bd91

Please sign in to comment.