From 93dcd8f16e72f8a4eceed6404f850e53d09f1967 Mon Sep 17 00:00:00 2001 From: Shahbaz Shabbir <32649010+shahbaz-arbisoft@users.noreply.github.com> Date: Fri, 10 Mar 2023 18:05:02 +0500 Subject: [PATCH] fix: make identify call to pass missing user_id (#774) --- src/progressive-profiling/ProgressiveProfiling.jsx | 5 +++-- .../tests/ProgressiveProfiling.test.jsx | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/progressive-profiling/ProgressiveProfiling.jsx b/src/progressive-profiling/ProgressiveProfiling.jsx index 8fa31a88..28ff4a01 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, @@ -64,9 +64,10 @@ const ProgressiveProfiling = (props) => { if (registrationResponse) { setRegistrationResult(registrationResponse); + identifyAuthenticatedUser(authenticatedUser?.userId); sendPageEvent('login_and_registration', 'welcome'); } - }, [DASHBOARD_URL, registrationResponse]); + }, [authenticatedUser, DASHBOARD_URL, registrationResponse]); useEffect(() => { if (registrationResponse) { diff --git a/src/progressive-profiling/tests/ProgressiveProfiling.test.jsx b/src/progressive-profiling/tests/ProgressiveProfiling.test.jsx index f5c51096..70ed0505 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,11 @@ describe('ProgressiveProfilingTests', () => { expect(progressiveProfilingPage.find('#gender').exists()).toBeTruthy(); }); + it('should make identify call to segment on progressive profiling page', async () => { + await getProgressiveProfilingPage(); + expect(analytics.identifyAuthenticatedUser).toHaveBeenCalled(); + }); + it('should submit user profile details on form submission', async () => { auth.getAuthenticatedUser = jest.fn(() => ({ userId: 3, username: 'abc123' })); const formPayload = {