From c5caaeba60b0184ba034c54ac321b2c970c6b756 Mon Sep 17 00:00:00 2001 From: Zainab Amir Date: Tue, 29 Aug 2023 15:22:07 +0500 Subject: [PATCH] feat: add registration conversion event (#1049) --- src/register/RegistrationPage.jsx | 4 +++- src/register/tests/RegistrationPage.test.jsx | 20 +++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/register/RegistrationPage.jsx b/src/register/RegistrationPage.jsx index aa4aaebe..0fe7c8db 100644 --- a/src/register/RegistrationPage.jsx +++ b/src/register/RegistrationPage.jsx @@ -4,7 +4,7 @@ import React, { import { connect } from 'react-redux'; import { getConfig, snakeCaseObject } from '@edx/frontend-platform'; -import { sendPageEvent } from '@edx/frontend-platform/analytics'; +import { sendPageEvent, sendTrackEvent } from '@edx/frontend-platform/analytics'; import { getCountryList, getLocale, useIntl, } from '@edx/frontend-platform/i18n'; @@ -228,6 +228,8 @@ const RegistrationPage = (props) => { useEffect(() => { if (registrationResult.success) { + sendTrackEvent('edx.bi.user.account.registered.client', {}); + // Optimizely registration conversion event window.optimizely = window.optimizely || []; window.optimizely.push({ diff --git a/src/register/tests/RegistrationPage.test.jsx b/src/register/tests/RegistrationPage.test.jsx index 435f73eb..06da54f6 100644 --- a/src/register/tests/RegistrationPage.test.jsx +++ b/src/register/tests/RegistrationPage.test.jsx @@ -2,7 +2,7 @@ import React from 'react'; import { Provider } from 'react-redux'; import { getConfig, mergeConfig } from '@edx/frontend-platform'; -import { sendPageEvent } from '@edx/frontend-platform/analytics'; +import { sendPageEvent, sendTrackEvent } from '@edx/frontend-platform/analytics'; import { configure, getLocale, injectIntl, IntlProvider, } from '@edx/frontend-platform/i18n'; @@ -1022,6 +1022,24 @@ describe('RegistrationPage', () => { expect(sendPageEvent).toHaveBeenCalledWith('login_and_registration', 'register'); }); + it('should send track event when user has successfully registered', () => { + store = mockStore({ + ...initialState, + register: { + ...initialState.register, + registrationResult: { + success: true, + redirectUrl: 'https://test.com/testing-dashboard/', + }, + }, + }); + + delete window.location; + window.location = { href: getConfig().BASE_URL }; + renderer.create(routerWrapper(reduxWrapper())); + expect(sendTrackEvent).toHaveBeenCalledWith('edx.bi.user.account.registered.client', {}); + }); + it('should populate form with pipeline user details', () => { store = mockStore({ ...initialState,