1616
1717import {
1818 CLIENT_VERSION ,
19- ERROR_MESSAGES ,
2019 JAVASCRIPT_CLIENT_ENGINE ,
21- ODP_USER_KEY ,
2220 REQUEST_TIMEOUT_ODP_SEGMENTS_MS ,
2321 REQUEST_TIMEOUT_ODP_EVENTS_MS ,
2422} from '../../utils/enums' ;
2523import { getLogger , LogHandler } from '../../modules/logging' ;
2624
2725import { BrowserRequestHandler } from './../../utils/http_request_handler/browser_request_handler' ;
2826
29- import BrowserAsyncStorageCache from '../key_value_cache/browserAsyncStorageCache' ;
3027import { BrowserLRUCache } from '../../utils/lru_cache' ;
3128
3229import { VuidManager } from './../vuid_manager/index' ;
3330
3431import { OdpManager } from '../../core/odp/odp_manager' ;
35- import { OdpEvent } from '../../core/odp/odp_event' ;
36- import { IOdpEventManager , OdpOptions , VuidManagerOptions } from '../../shared_types' ;
32+ import { IOdpEventManager , OdpOptions } from '../../shared_types' ;
3733import { BrowserOdpEventApiManager } from '../odp/event_api_manager/index.browser' ;
3834import { BrowserOdpEventManager } from '../odp/event_manager/index.browser' ;
3935import { IOdpSegmentManager , OdpSegmentManager } from '../../core/odp/odp_segment_manager' ;
@@ -46,26 +42,21 @@ interface BrowserOdpManagerConfig {
4642 logger ?: LogHandler ;
4743 odpOptions ?: OdpOptions ;
4844 odpIntegrationConfig ?: OdpIntegrationConfig ;
49- vuidManagerOptions ?: VuidManagerOptions ;
5045}
5146
5247// Client-side Browser Plugin for ODP Manager
5348export class BrowserOdpManager extends OdpManager {
54- static cache = new BrowserAsyncStorageCache ( ) ;
55- vuid ?: string ;
56-
5749 constructor ( options : {
5850 odpIntegrationConfig ?: OdpIntegrationConfig ;
5951 segmentManager : IOdpSegmentManager ;
6052 eventManager : IOdpEventManager ;
6153 logger : LogHandler ;
62- vuidManagerOptions ?: VuidManagerOptions ;
6354 } ) {
6455 super ( options ) ;
6556 }
6657
6758 static createInstance ( {
68- logger, odpOptions, odpIntegrationConfig, clientEngine, clientVersion, vuidManagerOptions ,
59+ logger, odpOptions, odpIntegrationConfig, clientEngine, clientVersion,
6960 } : BrowserOdpManagerConfig ) : BrowserOdpManager {
7061 logger = logger || getLogger ( ) ;
7162
@@ -135,19 +126,9 @@ export class BrowserOdpManager extends OdpManager {
135126 segmentManager,
136127 eventManager,
137128 logger,
138- vuidManagerOptions,
139129 } ) ;
140130 }
141131
142- /**
143- * @override
144- * accesses or creates new VUID from Browser cache
145- */
146- protected async initializeVuid ( ) : Promise < void > {
147- const vuidManager = await VuidManager . instance ( BrowserOdpManager . cache , this . vuidManagerOptions ) ;
148- this . vuid = vuidManager . vuid ;
149- }
150-
151132 /**
152133 * @override
153134 * - Still identifies a user via the ODP Event Manager
@@ -165,35 +146,6 @@ export class BrowserOdpManager extends OdpManager {
165146 return ;
166147 }
167148
168- super . identifyUser ( fsUserId , vuid || this . vuid ) ;
169- }
170-
171- /**
172- * @override
173- * - Sends an event to the ODP Server via the ODP Events API
174- * - Intercepts identifiers and injects VUID before sending event
175- * - Identifiers must contain at least one key-value pair
176- * @param {OdpEvent } odpEvent > ODP Event to send to event manager
177- */
178- sendEvent ( { type, action, identifiers, data } : OdpEvent ) : void {
179- const identifiersWithVuid = new Map < string , string > ( identifiers ) ;
180-
181- if ( ! identifiers . has ( ODP_USER_KEY . VUID ) ) {
182- if ( this . vuid ) {
183- identifiersWithVuid . set ( ODP_USER_KEY . VUID , this . vuid ) ;
184- } else {
185- throw new Error ( ERROR_MESSAGES . ODP_SEND_EVENT_FAILED_VUID_MISSING ) ;
186- }
187- }
188-
189- super . sendEvent ( { type, action, identifiers : identifiersWithVuid , data } ) ;
190- }
191-
192- isVuidEnabled ( ) : boolean {
193- return this . vuidManagerOptions ?. enableVuid || false ;
194- }
195-
196- getVuid ( ) : string | undefined {
197- return this . vuid ;
149+ super . identifyUser ( fsUserId , vuid ) ;
198150 }
199151}
0 commit comments