Skip to content
Open
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
12 changes: 4 additions & 8 deletions lib/odp/odp_manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ describe('DefaultOdpManager', () => {
expect(identifiers).toEqual(new Map([['fs_user_id', 'user'], ['vuid', 'vuid_a']]));
});

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

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

odpManager.identifyUser('user');
expect(mockSendEvents).toHaveBeenCalledOnce();
const { identifiers } = mockSendEvents.mock.calls[0][0];
expect(identifiers).toEqual(new Map([['fs_user_id', 'user']]));
expect(mockSendEvents).not.toHaveBeenCalled();
});

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

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

odpManager.identifyUser('vuid_a');
expect(mockSendEvents).toHaveBeenCalledOnce();
const { identifiers } = mockSendEvents.mock.calls[0][0];
expect(identifiers).toEqual(new Map([['vuid', 'vuid_a']]));
expect(mockSendEvents).not.toHaveBeenCalled();
});

it('should reject onRunning() if stopped in new state', async () => {
Expand Down
9 changes: 7 additions & 2 deletions lib/odp/odp_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import { v4 as uuidV4} from 'uuid';
import { LoggerFacade } from '../logging/logger';
import { LoggerFacade, LogLevel } from '../logging/logger';

import { OdpIntegrationConfig, odpIntegrationsAreEqual } from './odp_config';
import { OdpEventManager } from './event_manager/odp_event_manager';
Expand Down Expand Up @@ -212,7 +212,7 @@

identifyUser(userId: string, vuid?: string): void {
const identifiers = new Map<string, string>();

let finalUserId: Maybe<string> = userId;
let finalVuid: Maybe<string> = vuid;

Expand All @@ -229,6 +229,11 @@
identifiers.set(ODP_USER_KEY.FS_USER_ID, finalUserId);
}

if (identifiers.size < 2) {
this.logger.log(LogLevel.Debug, 'ODP identify event is not dispatched (only one identifier provided).');

Check failure on line 233 in lib/odp/odp_manager.ts

View workflow job for this annotation

GitHub Actions / typescript_test

Property 'log' does not exist on type 'LoggerFacade'.

Check failure on line 233 in lib/odp/odp_manager.ts

View workflow job for this annotation

GitHub Actions / typescript_test

Object is possibly 'undefined'.

Check failure on line 233 in lib/odp/odp_manager.ts

View workflow job for this annotation

GitHub Actions / unit_tests (20)

Property 'log' does not exist on type 'LoggerFacade'.

Check failure on line 233 in lib/odp/odp_manager.ts

View workflow job for this annotation

GitHub Actions / unit_tests (20)

Object is possibly 'undefined'.

Check failure on line 233 in lib/odp/odp_manager.ts

View workflow job for this annotation

GitHub Actions / browser_tests (edge)

Property 'log' does not exist on type 'LoggerFacade'.

Check failure on line 233 in lib/odp/odp_manager.ts

View workflow job for this annotation

GitHub Actions / browser_tests (edge)

Object is possibly 'undefined'.

Check failure on line 233 in lib/odp/odp_manager.ts

View workflow job for this annotation

GitHub Actions / unit_tests (22)

Property 'log' does not exist on type 'LoggerFacade'.

Check failure on line 233 in lib/odp/odp_manager.ts

View workflow job for this annotation

GitHub Actions / unit_tests (22)

Object is possibly 'undefined'.

Check failure on line 233 in lib/odp/odp_manager.ts

View workflow job for this annotation

GitHub Actions / browser_tests (chrome)

Property 'log' does not exist on type 'LoggerFacade'.

Check failure on line 233 in lib/odp/odp_manager.ts

View workflow job for this annotation

GitHub Actions / browser_tests (chrome)

Object is possibly 'undefined'.

Check failure on line 233 in lib/odp/odp_manager.ts

View workflow job for this annotation

GitHub Actions / unit_tests (18)

Property 'log' does not exist on type 'LoggerFacade'.

Check failure on line 233 in lib/odp/odp_manager.ts

View workflow job for this annotation

GitHub Actions / unit_tests (18)

Object is possibly 'undefined'.

Check failure on line 233 in lib/odp/odp_manager.ts

View workflow job for this annotation

GitHub Actions / lint

Property 'log' does not exist on type 'LoggerFacade'.

Check failure on line 233 in lib/odp/odp_manager.ts

View workflow job for this annotation

GitHub Actions / lint

Object is possibly 'undefined'.

Check failure on line 233 in lib/odp/odp_manager.ts

View workflow job for this annotation

GitHub Actions / unit_tests (24)

Property 'log' does not exist on type 'LoggerFacade'.

Check failure on line 233 in lib/odp/odp_manager.ts

View workflow job for this annotation

GitHub Actions / unit_tests (24)

Object is possibly 'undefined'.

Check failure on line 233 in lib/odp/odp_manager.ts

View workflow job for this annotation

GitHub Actions / browser_tests (safari)

Property 'log' does not exist on type 'LoggerFacade'.

Check failure on line 233 in lib/odp/odp_manager.ts

View workflow job for this annotation

GitHub Actions / browser_tests (safari)

Object is possibly 'undefined'.
return;
}

const event = new OdpEvent(ODP_DEFAULT_EVENT_TYPE, ODP_EVENT_ACTION.IDENTIFIED, identifiers);
this.sendEvent(event);
}
Expand Down
Loading