diff --git a/.env b/.env index 42af6184..fdb32f77 100644 --- a/.env +++ b/.env @@ -22,3 +22,4 @@ COOKIE_DOMAIN=null WELCOME_PAGE_SUPPORT_LINK=null INFO_EMAIL='' DISABLE_ENTERPRISE_LOGIN='' +REGISTER_CONVERSION_COOKIE_NAME=null diff --git a/.env.development b/.env.development index 6123dbde..6c19e73c 100644 --- a/.env.development +++ b/.env.development @@ -30,3 +30,4 @@ WELCOME_PAGE_SUPPORT_LINK='http://localhost:1999/welcome' INFO_EMAIL='info@edx.org' DISABLE_ENTERPRISE_LOGIN='' DEFAULT_DESIGN='legacy' +REGISTER_CONVERSION_COOKIE_NAME='openedx-user-register-conversion' diff --git a/.env.test b/.env.test index 6974dcca..a1728d2f 100644 --- a/.env.test +++ b/.env.test @@ -21,3 +21,4 @@ LOGIN_ISSUE_SUPPORT_LINK='https://login-issue-support-url.com' USER_SURVEY_COOKIE_NAME='openedx-user-survey-type' WELCOME_PAGE_SUPPORT_LINK='http://localhost:1999/welcome' DISABLE_ENTERPRISE_LOGIN='' +REGISTER_CONVERSION_COOKIE_NAME='openedx-user-register-conversion' diff --git a/src/index.jsx b/src/index.jsx index b062dd64..f59cab48 100755 --- a/src/index.jsx +++ b/src/index.jsx @@ -55,6 +55,7 @@ initialize({ WELCOME_PAGE_SUPPORT_LINK: process.env.WELCOME_PAGE_SUPPORT_LINK || null, DISABLE_ENTERPRISE_LOGIN: process.env.DISABLE_ENTERPRISE_LOGIN || '', INFO_EMAIL: process.env.INFO_EMAIL || '', + REGISTER_CONVERSION_COOKIE_NAME: process.env.REGISTER_CONVERSION_COOKIE_NAME || null, }); }, }, diff --git a/src/legacy/register/RegistrationPage.jsx b/src/legacy/register/RegistrationPage.jsx index 64013231..677c004f 100644 --- a/src/legacy/register/RegistrationPage.jsx +++ b/src/legacy/register/RegistrationPage.jsx @@ -32,7 +32,7 @@ import { DEFAULT_STATE, LOGIN_PAGE, PENDING_STATE, REGISTER_PAGE, VALID_EMAIL_REGEX, } from '../data/constants'; import { - getTpaProvider, getTpaHint, updatePathWithQueryParams, getAllPossibleQueryParam, setSurveyCookie, + getTpaProvider, getTpaHint, updatePathWithQueryParams, getAllPossibleQueryParam, setSurveyCookie, setCookie, } from '../data/utils'; class RegistrationPage extends React.Component { @@ -452,6 +452,7 @@ class RegistrationPage extends React.Component { if (this.props.registrationResult.success) { setSurveyCookie('register'); + setCookie(getConfig().REGISTER_CONVERSION_COOKIE_NAME, true); // Fire optimizely events window.optimizely = window.optimizely || []; diff --git a/src/legacy/register/tests/RegistrationPage.test.jsx b/src/legacy/register/tests/RegistrationPage.test.jsx index d6961d6f..5875f67d 100644 --- a/src/legacy/register/tests/RegistrationPage.test.jsx +++ b/src/legacy/register/tests/RegistrationPage.test.jsx @@ -30,6 +30,7 @@ describe('RegistrationPageTests', () => { REGISTRATION_OPTIONAL_FIELDS: 'gender,goals,level_of_education,year_of_birth', TOS_AND_HONOR_CODE: 'http://tos-and-honot-code.com', USER_SURVEY_COOKIE_NAME: process.env.USER_SURVEY_COOKIE_NAME, + REGISTER_CONVERSION_COOKIE_NAME: process.env.REGISTER_CONVERSION_COOKIE_NAME, }); const initialState = { @@ -577,6 +578,7 @@ describe('RegistrationPageTests', () => { renderer.create(reduxWrapper()); expect(document.cookie).toMatch(`${getConfig().USER_SURVEY_COOKIE_NAME}=register`); + expect(document.cookie).toMatch(`${getConfig().REGISTER_CONVERSION_COOKIE_NAME}=true`); }); it('should display institution register button', () => { diff --git a/src/redesign/register/RegistrationPage.jsx b/src/redesign/register/RegistrationPage.jsx index f6838a63..92eb3b76 100644 --- a/src/redesign/register/RegistrationPage.jsx +++ b/src/redesign/register/RegistrationPage.jsx @@ -41,7 +41,7 @@ import { DEFAULT_STATE, PENDING_STATE, REGISTER_PAGE, VALID_EMAIL_REGEX, LETTER_REGEX, NUMBER_REGEX, } from '../data/constants'; import { - getTpaProvider, getTpaHint, getAllPossibleQueryParam, setSurveyCookie, + getTpaProvider, getTpaHint, getAllPossibleQueryParam, setSurveyCookie, setCookie, } from '../data/utils'; import CountryDropdown from './CountryDropdown'; import getLevenshteinSuggestion from './utils'; @@ -476,9 +476,10 @@ class RegistrationPage extends React.Component { if (this.props.registrationResult.success) { setSurveyCookie('register'); - window.optimizely = window.optimizely || []; + setCookie(getConfig().REGISTER_CONVERSION_COOKIE_NAME, true); // Fire optimizely events + window.optimizely = window.optimizely || []; window.optimizely.push({ type: 'event', eventName: 'authn-register-conversion', diff --git a/src/redesign/register/tests/RegistrationPage.test.jsx b/src/redesign/register/tests/RegistrationPage.test.jsx index 0967a5c2..f82a332f 100644 --- a/src/redesign/register/tests/RegistrationPage.test.jsx +++ b/src/redesign/register/tests/RegistrationPage.test.jsx @@ -37,6 +37,7 @@ describe('RegistrationPage', () => { REGISTRATION_OPTIONAL_FIELDS: 'gender,goals,levelOfEducation,yearOfBirth', TOS_AND_HONOR_CODE: 'http://tos-and-honot-code.com', USER_SURVEY_COOKIE_NAME: process.env.USER_SURVEY_COOKIE_NAME, + REGISTER_CONVERSION_COOKIE_NAME: process.env.REGISTER_CONVERSION_COOKIE_NAME, }); let props = {}; @@ -486,6 +487,7 @@ describe('RegistrationPage', () => { renderer.create(reduxWrapper()); expect(document.cookie).toMatch(`${getConfig().USER_SURVEY_COOKIE_NAME}=register`); + expect(document.cookie).toMatch(`${getConfig().REGISTER_CONVERSION_COOKIE_NAME}=true`); }); it('should show username suggestions in case of conflict with an existing username', () => {