Skip to content

Commit 9f5b95a

Browse files
committed
[AI-FSSDK] [FSSDK-12670] Block ODP identify event for single identifier
1 parent 6c0a6e9 commit 9f5b95a

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

lib/odp/odp_manager.spec.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ describe('DefaultOdpManager', () => {
618618
expect(identifiers).toEqual(new Map([['fs_user_id', 'user'], ['vuid', 'vuid_a']]));
619619
});
620620

621-
it('sends identified event when called with just fs_user_id in first parameter', async () => {
621+
it('does not send identified event when called with just fs_user_id (single identifier)', async () => {
622622
const eventManager = getMockOdpEventManager();
623623
eventManager.onRunning.mockReturnValue(Promise.resolve());
624624

@@ -634,12 +634,10 @@ describe('DefaultOdpManager', () => {
634634
await odpManager.onRunning();
635635

636636
odpManager.identifyUser('user');
637-
expect(mockSendEvents).toHaveBeenCalledOnce();
638-
const { identifiers } = mockSendEvents.mock.calls[0][0];
639-
expect(identifiers).toEqual(new Map([['fs_user_id', 'user']]));
637+
expect(mockSendEvents).not.toHaveBeenCalled();
640638
});
641639

642-
it('sends identified event when called with just vuid in first parameter', async () => {
640+
it('does not send identified event when called with just vuid (single identifier)', async () => {
643641
const eventManager = getMockOdpEventManager();
644642
eventManager.onRunning.mockReturnValue(Promise.resolve());
645643

@@ -655,9 +653,7 @@ describe('DefaultOdpManager', () => {
655653
await odpManager.onRunning();
656654

657655
odpManager.identifyUser('vuid_a');
658-
expect(mockSendEvents).toHaveBeenCalledOnce();
659-
const { identifiers } = mockSendEvents.mock.calls[0][0];
660-
expect(identifiers).toEqual(new Map([['vuid', 'vuid_a']]));
656+
expect(mockSendEvents).not.toHaveBeenCalled();
661657
});
662658

663659
it('should reject onRunning() if stopped in new state', async () => {

lib/odp/odp_manager.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
import { v4 as uuidV4} from 'uuid';
18-
import { LoggerFacade } from '../logging/logger';
18+
import { LoggerFacade, LogLevel } from '../logging/logger';
1919

2020
import { OdpIntegrationConfig, odpIntegrationsAreEqual } from './odp_config';
2121
import { OdpEventManager } from './event_manager/odp_event_manager';
@@ -212,7 +212,7 @@ export class DefaultOdpManager extends BaseService implements OdpManager {
212212

213213
identifyUser(userId: string, vuid?: string): void {
214214
const identifiers = new Map<string, string>();
215-
215+
216216
let finalUserId: Maybe<string> = userId;
217217
let finalVuid: Maybe<string> = vuid;
218218

@@ -229,6 +229,11 @@ export class DefaultOdpManager extends BaseService implements OdpManager {
229229
identifiers.set(ODP_USER_KEY.FS_USER_ID, finalUserId);
230230
}
231231

232+
if (identifiers.size < 2) {
233+
this.logger.log(LogLevel.Debug, 'ODP identify event is not dispatched (only one identifier provided).');
234+
return;
235+
}
236+
232237
const event = new OdpEvent(ODP_DEFAULT_EVENT_TYPE, ODP_EVENT_ACTION.IDENTIFIED, identifiers);
233238
this.sendEvent(event);
234239
}

0 commit comments

Comments
 (0)