Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: user id not passing in registration success event #121

Merged
merged 2 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
});
});
Loading