diff --git a/src/forms/progressive-profiling-popup/index.jsx b/src/forms/progressive-profiling-popup/index.jsx index d1999634..0d43fcc4 100644 --- a/src/forms/progressive-profiling-popup/index.jsx +++ b/src/forms/progressive-profiling-popup/index.jsx @@ -3,7 +3,6 @@ import React, { } from 'react'; import { getConfig, snakeCaseObject } from '@edx/frontend-platform'; -import { identifyAuthenticatedUser } from '@edx/frontend-platform/analytics'; import { AxiosJwtAuthService, configure as configureAuth, @@ -90,7 +89,6 @@ const ProgressiveProfilingForm = () => { dispatch(setCurrentOpenedForm(LOGIN_FORM)); } if (authenticatedUser?.userId) { - identifyAuthenticatedUser(authenticatedUser?.userId); configureAuth(AxiosJwtAuthService, { loggingService: getLoggingService(), config: getConfig() }); trackProgressiveProfilingPageViewed(); } diff --git a/src/forms/progressive-profiling-popup/index.test.jsx b/src/forms/progressive-profiling-popup/index.test.jsx index 1a84f5bd..60cb2892 100644 --- a/src/forms/progressive-profiling-popup/index.test.jsx +++ b/src/forms/progressive-profiling-popup/index.test.jsx @@ -2,7 +2,6 @@ import React from 'react'; import { Provider } from 'react-redux'; import { getConfig } from '@edx/frontend-platform'; -import { identifyAuthenticatedUser } from '@edx/frontend-platform/analytics'; import { getAuthenticatedUser } from '@edx/frontend-platform/auth'; import { getLocale, injectIntl, IntlProvider } from '@edx/frontend-platform/i18n'; import { fireEvent, render, screen } from '@testing-library/react'; @@ -84,13 +83,6 @@ describe('ProgressiveProfilingForm Test', () => { jest.clearAllMocks(); }); - it('should make identify call to segment on progressive profiling page', () => { - render(reduxWrapper()); - - expect(identifyAuthenticatedUser).toHaveBeenCalledWith(1); - expect(identifyAuthenticatedUser).toHaveBeenCalled(); - }); - it('should render progressive profiling form', () => { render(reduxWrapper()); diff --git a/src/forms/registration-popup/index.jsx b/src/forms/registration-popup/index.jsx index da159eb4..fb3fdb8d 100644 --- a/src/forms/registration-popup/index.jsx +++ b/src/forms/registration-popup/index.jsx @@ -3,6 +3,7 @@ import React, { } from 'react'; import { getConfig, snakeCaseObject } from '@edx/frontend-platform'; +import { identifyAuthenticatedUser } from '@edx/frontend-platform/analytics'; import { useIntl } from '@edx/frontend-platform/i18n'; import { breakpoints, Container, Form, Spinner, StatefulButton, useMediaQuery, @@ -183,6 +184,8 @@ const RegistrationForm = () => { useEffect(() => { if (registrationResult.success) { + identifyAuthenticatedUser(registrationResult?.authenticatedUser?.userId); + removeCookie('ssoPipelineRedirectionDone'); removeCookie('marketingEmailsOptIn'); diff --git a/src/forms/registration-popup/tests/RegistrationPopup.test.jsx b/src/forms/registration-popup/tests/RegistrationPopup.test.jsx index 5ee5a8c0..66fa00c2 100644 --- a/src/forms/registration-popup/tests/RegistrationPopup.test.jsx +++ b/src/forms/registration-popup/tests/RegistrationPopup.test.jsx @@ -2,6 +2,7 @@ import React from 'react'; import { Provider } from 'react-redux'; import { getConfig, mergeConfig } from '@edx/frontend-platform'; +import { identifyAuthenticatedUser } from '@edx/frontend-platform/analytics'; import { injectIntl, IntlProvider } from '@edx/frontend-platform/i18n'; import { fireEvent, render, waitFor } from '@testing-library/react'; import { act } from 'react-dom/test-utils'; @@ -457,4 +458,25 @@ describe('RegistrationForm Test', () => { render(reduxWrapper()); expect(document.cookie).toMatch(`${getConfig().USER_RETENTION_COOKIE_NAME}=true`); }); + + it('should make identify call to segment on registration success', () => { + store = mockStore({ + ...initialState, + register: { + ...initialState.register, + registrationResult: { + success: true, + authenticatedUser: { + username: 'john_doe', + userId: 1, + }, + }, + }, + }); + + render(reduxWrapper()); + + expect(identifyAuthenticatedUser).toHaveBeenCalledWith(1); + expect(identifyAuthenticatedUser).toHaveBeenCalled(); + }); });