Skip to content

Commit

Permalink
Track total time it takes users to register (#205)
Browse files Browse the repository at this point in the history
Added a new param to payload in registration page. This tracks
the total time it took user to register.

VAN-413
  • Loading branch information
zainab-amir authored Mar 18, 2021
1 parent b5816c1 commit d861fac
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/register/RegistrationPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class RegistrationPage extends React.Component {
},
institutionLogin: false,
formValid: false,
startTime: Date.now(),
updateFieldErrors: false,
updateAlertErrors: false,
registrationErrorsUpdated: false,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -188,6 +190,7 @@ class RegistrationPage extends React.Component {
}
});
if (finalValidation) {
payload.totalRegistrationTime = totalRegistrationTime;
this.props.registerNewUser(payload);
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/register/data/actions.js
Original file line number Diff line number Diff line change
@@ -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 },
Expand Down
5 changes: 5 additions & 0 deletions src/register/tests/RegistrationPage.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -355,6 +357,7 @@ describe('RegistrationPageTests', () => {
country: 'Pakistan',
gender: 'm',
honor_code: true,
totalRegistrationTime: 0,
};

store.dispatch = jest.fn(store.dispatch);
Expand All @@ -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: {
Expand All @@ -381,6 +385,7 @@ describe('RegistrationPageTests', () => {
country: 'Pakistan',
honor_code: true,
social_auth_provider: appleProvider.name,
totalRegistrationTime: 0,
};

store.dispatch = jest.fn(store.dispatch);
Expand Down

0 comments on commit d861fac

Please sign in to comment.