From 0180969ccdfd3d4aa2ac2ff86ef42140ef7f151f Mon Sep 17 00:00:00 2001 From: Waheed Ahmed Date: Fri, 25 Jun 2021 11:24:52 +0500 Subject: [PATCH] temp: send total register time to Optimizely (#370) Added for the launch experiment to calculate the average time per user per variation. --- src/legacy/register/RegistrationPage.jsx | 13 +++++++++++-- src/redesign/register/RegistrationPage.jsx | 13 +++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/legacy/register/RegistrationPage.jsx b/src/legacy/register/RegistrationPage.jsx index 84ba06df..64013231 100644 --- a/src/legacy/register/RegistrationPage.jsx +++ b/src/legacy/register/RegistrationPage.jsx @@ -76,6 +76,7 @@ class RegistrationPage extends React.Component { updateAlertErrors: false, registrationErrorsUpdated: false, optimizelyExperimentName: '', + totalRegistrationTime: 0, }; } @@ -164,7 +165,8 @@ class RegistrationPage extends React.Component { handleSubmit = (e) => { e.preventDefault(); - const totalRegistrationTime = (Date.now() - this.state.startTime) / 1000; + const { startTime } = this.state; + const totalRegistrationTime = (Date.now() - startTime) / 1000; let payload = { name: this.state.name, username: this.state.username, @@ -199,7 +201,11 @@ class RegistrationPage extends React.Component { }); if (finalValidation) { payload.totalRegistrationTime = totalRegistrationTime; - this.props.registerNewUser(payload); + this.setState({ + totalRegistrationTime, + }, () => { + this.props.registerNewUser(payload); + }); } } @@ -452,6 +458,9 @@ class RegistrationPage extends React.Component { window.optimizely.push({ type: 'event', eventName: 'authn-register-conversion', + tags: { + value: this.state.totalRegistrationTime, + }, }); if (this.state.optimizelyExperimentName !== 'progressiveProfilingConcept1') { diff --git a/src/redesign/register/RegistrationPage.jsx b/src/redesign/register/RegistrationPage.jsx index a11f4946..8a484af8 100644 --- a/src/redesign/register/RegistrationPage.jsx +++ b/src/redesign/register/RegistrationPage.jsx @@ -77,6 +77,7 @@ class RegistrationPage extends React.Component { showOptionalField: false, startTime: Date.now(), optimizelyExperimentName: '', + totalRegistrationTime: 0, }; } @@ -170,7 +171,8 @@ class RegistrationPage extends React.Component { handleSubmit = (e) => { e.preventDefault(); - const totalRegistrationTime = (Date.now() - this.state.startTime) / 1000; + const { startTime } = this.state; + const totalRegistrationTime = (Date.now() - startTime) / 1000; let payload = { name: this.state.name, username: this.state.username, @@ -209,7 +211,11 @@ class RegistrationPage extends React.Component { }); payload.totalRegistrationTime = totalRegistrationTime; - this.props.registerNewUser(payload); + this.setState({ + totalRegistrationTime, + }, () => { + this.props.registerNewUser(payload); + }); } handleOnBlur = (e) => { @@ -468,6 +474,9 @@ class RegistrationPage extends React.Component { window.optimizely.push({ type: 'event', eventName: 'authn-register-conversion', + tags: { + value: this.state.totalRegistrationTime, + }, }); if (window.optimizelyExperimentName !== 'VAN-504-PP-Exp') {