Skip to content

Commit

Permalink
Merge pull request #121 from edx/sajjad/VAN-2018
Browse files Browse the repository at this point in the history
fix: user id not passing in registration success event
  • Loading branch information
syedsajjadkazmii authored Jul 22, 2024
2 parents 2128ac2 + 7e20d4d commit 91c28a8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
2 changes: 0 additions & 2 deletions src/forms/progressive-profiling-popup/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -90,7 +89,6 @@ const ProgressiveProfilingForm = () => {
dispatch(setCurrentOpenedForm(LOGIN_FORM));
}
if (authenticatedUser?.userId) {
identifyAuthenticatedUser(authenticatedUser?.userId);
configureAuth(AxiosJwtAuthService, { loggingService: getLoggingService(), config: getConfig() });
trackProgressiveProfilingPageViewed();
}
Expand Down
8 changes: 0 additions & 8 deletions src/forms/progressive-profiling-popup/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -84,13 +83,6 @@ describe('ProgressiveProfilingForm Test', () => {
jest.clearAllMocks();
});

it('should make identify call to segment on progressive profiling page', () => {
render(reduxWrapper(<IntlProgressiveProfilingForm />));

expect(identifyAuthenticatedUser).toHaveBeenCalledWith(1);
expect(identifyAuthenticatedUser).toHaveBeenCalled();
});

it('should render progressive profiling form', () => {
render(reduxWrapper(<IntlProgressiveProfilingForm />));

Expand Down
3 changes: 3 additions & 0 deletions src/forms/registration-popup/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -183,6 +184,8 @@ const RegistrationForm = () => {

useEffect(() => {
if (registrationResult.success) {
identifyAuthenticatedUser(registrationResult?.authenticatedUser?.userId);

removeCookie('ssoPipelineRedirectionDone');
removeCookie('marketingEmailsOptIn');

Expand Down
22 changes: 22 additions & 0 deletions src/forms/registration-popup/tests/RegistrationPopup.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -457,4 +458,25 @@ describe('RegistrationForm Test', () => {
render(reduxWrapper(<IntlRegistrationForm />));
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(<IntlRegistrationForm />));

expect(identifyAuthenticatedUser).toHaveBeenCalledWith(1);
expect(identifyAuthenticatedUser).toHaveBeenCalled();
});
});

0 comments on commit 91c28a8

Please sign in to comment.