diff --git a/src/progressive-profiling/ProgressiveProfiling.jsx b/src/progressive-profiling/ProgressiveProfiling.jsx index 8fa31a88..0fbd799d 100644 --- a/src/progressive-profiling/ProgressiveProfiling.jsx +++ b/src/progressive-profiling/ProgressiveProfiling.jsx @@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react'; import { connect } from 'react-redux'; import { getConfig, snakeCaseObject } from '@edx/frontend-platform'; -import { sendPageEvent, sendTrackEvent } from '@edx/frontend-platform/analytics'; +import { identifyAuthenticatedUser, sendPageEvent, sendTrackEvent } from '@edx/frontend-platform/analytics'; import { AxiosJwtAuthService, configure as configureAuth, @@ -68,6 +68,12 @@ const ProgressiveProfiling = (props) => { } }, [DASHBOARD_URL, registrationResponse]); + useEffect(() => { + if (registrationResponse && authenticatedUser?.userId) { + identifyAuthenticatedUser(authenticatedUser.userId); + } + }, [authenticatedUser, registrationResponse]); + useEffect(() => { if (registrationResponse) { const queryParams = getAllPossibleQueryParams(registrationResponse.redirectUrl); diff --git a/src/progressive-profiling/tests/ProgressiveProfiling.test.jsx b/src/progressive-profiling/tests/ProgressiveProfiling.test.jsx index f5c51096..248ca28d 100644 --- a/src/progressive-profiling/tests/ProgressiveProfiling.test.jsx +++ b/src/progressive-profiling/tests/ProgressiveProfiling.test.jsx @@ -27,6 +27,7 @@ jest.mock('@edx/frontend-platform/logging'); analytics.sendTrackEvent = jest.fn(); analytics.sendPageEvent = jest.fn(); +analytics.identifyAuthenticatedUser = jest.fn(); logging.getLoggingService = jest.fn(); auth.configure = jest.fn(); @@ -127,6 +128,13 @@ describe('ProgressiveProfilingTests', () => { expect(progressiveProfilingPage.find('#gender').exists()).toBeTruthy(); }); + it('should make identify call to segment on progressive profiling page', async () => { + auth.getAuthenticatedUser = jest.fn(() => ({ userId: 3, username: 'abc123' })); + await getProgressiveProfilingPage(); + expect(analytics.identifyAuthenticatedUser).toHaveBeenCalledWith(3); + expect(analytics.identifyAuthenticatedUser).toHaveBeenCalled(); + }); + it('should submit user profile details on form submission', async () => { auth.getAuthenticatedUser = jest.fn(() => ({ userId: 3, username: 'abc123' })); const formPayload = {