Track total time it takes users to register (#205)

Added a new param to payload in registration page. This tracks
the total time it took user to register.

VAN-413
This commit is contained in:
Zainab Amir
2021-03-18 12:37:37 +05:00
committed by GitHub
parent b5816c1f7b
commit d861facc3e
3 changed files with 8 additions and 2 deletions

View File

@@ -69,6 +69,7 @@ class RegistrationPage extends React.Component {
},
institutionLogin: false,
formValid: false,
startTime: Date.now(),
updateFieldErrors: false,
updateAlertErrors: false,
registrationErrorsUpdated: false,
@@ -155,6 +156,7 @@ class RegistrationPage extends React.Component {
handleSubmit = (e) => {
e.preventDefault();
const totalRegistrationTime = (Date.now() - this.state.startTime) / 1000;
let payload = {
name: this.state.name,
username: this.state.username,
@@ -188,6 +190,7 @@ class RegistrationPage extends React.Component {
}
});
if (finalValidation) {
payload.totalRegistrationTime = totalRegistrationTime;
this.props.registerNewUser(payload);
}
}

View File

@@ -1,11 +1,9 @@
import { AsyncActionType } from '../../data/utils';
export const REGISTER_NEW_USER = new AsyncActionType('REGISTRATION', 'REGISTER_NEW_USER');
export const REGISTER_FORM = new AsyncActionType('REGISTRATION', 'GET_FORM_FIELDS');
export const REGISTER_FORM_VALIDATIONS = new AsyncActionType('REGISTRATION', 'GET_FORM_VALIDATIONS');
// Register
export const registerNewUser = registrationInfo => ({
type: REGISTER_NEW_USER.BASE,
payload: { registrationInfo },

View File

@@ -347,6 +347,8 @@ describe('RegistrationPageTests', () => {
});
it('should submit form for valid input', () => {
jest.spyOn(global.Date, 'now').mockImplementation(() => 0);
const formPayload = {
name: 'John Doe',
username: 'john_doe',
@@ -355,6 +357,7 @@ describe('RegistrationPageTests', () => {
country: 'Pakistan',
gender: 'm',
honor_code: true,
totalRegistrationTime: 0,
};
store.dispatch = jest.fn(store.dispatch);
@@ -363,6 +366,7 @@ describe('RegistrationPageTests', () => {
});
it('should submit form with no password when current provider is present', () => {
jest.spyOn(global.Date, 'now').mockImplementation(() => 0);
store = mockStore({
...initialState,
commonComponents: {
@@ -381,6 +385,7 @@ describe('RegistrationPageTests', () => {
country: 'Pakistan',
honor_code: true,
social_auth_provider: appleProvider.name,
totalRegistrationTime: 0,
};
store.dispatch = jest.fn(store.dispatch);