Skip to content

Commit

Permalink
feat: add invalid form submit click event: (openedx#1190)
Browse files Browse the repository at this point in the history
  • Loading branch information
syedsajjadkazmii authored Mar 5, 2024
1 parent 488644f commit 5f93278
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/register/RegistrationPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
} from './data/optimizelyExperiment/helper';
import {
trackSimplifyRegistrationContinueBtnClicked,
trackSimplifyRegistrationInvalidFormSubmitBtnClicked,
trackSimplifyRegistrationSecondStepViewed,
trackSimplifyRegistrationValidatedSubmitBtnClicked,
} from './data/optimizelyExperiment/track';
Expand Down Expand Up @@ -275,6 +276,10 @@ const RegistrationPage = (props) => {

// returning if not valid
if (!isValid) {
if (simplifyRegistrationExpVariation === SIMPLIFIED_REGISTRATION_VARIATION
|| simplifyRegistrationExpVariation === DEFAULT_VARIATION) {
trackSimplifyRegistrationInvalidFormSubmitBtnClicked(simplifyRegistrationExpVariation, fieldErrors);
}
setErrorCode(prevState => ({ type: FORM_SUBMISSION_ERROR, count: prevState.count + 1 }));
return;
}
Expand Down Expand Up @@ -316,6 +321,10 @@ const RegistrationPage = (props) => {
}));
// returning if not valid
if (!isValid) {
trackSimplifyRegistrationInvalidFormSubmitBtnClicked(simplifyRegistrationExpVariation, {
...errors,
...fieldErrors,
});
setErrorCode(prevState => ({ type: FORM_SUBMISSION_ERROR, count: prevState.count + 1 }));
} else {
setErrorCode({ type: '', count: 0 });
Expand Down
8 changes: 8 additions & 0 deletions src/register/data/optimizelyExperiment/track.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const eventNames = {
simplifyRegistrationSecondStepViewed: 'edx.bi.user.simplifyregistration.step2.viewed',
simplifyRegistrationContinueBtnClicked: 'edx.bi.user.registration.submit.click',
simplifyRegistrationValidatedSubmitBtnClicked: 'edx.bi.user.registration.validated.submit.click',
simplifyRegistrationInvalidFormSubmitBtnClicked: 'edx.bi.user.registration.invalid.form.submit.click',
};

export const trackSimplifyRegistrationFirstStepViewed = (expVariation) => {
Expand All @@ -30,3 +31,10 @@ export const trackSimplifyRegistrationValidatedSubmitBtnClicked = (expVariation)
variation: expVariation,
});
};

export const trackSimplifyRegistrationInvalidFormSubmitBtnClicked = (expVariation, formErrors) => {
sendTrackEvent(eventNames.simplifyRegistrationInvalidFormSubmitBtnClicked, {
variation: expVariation,
...formErrors,
});
};

0 comments on commit 5f93278

Please sign in to comment.