@@ -46,7 +46,7 @@ export interface IOdpManager {
4646
4747 sendEvent ( { type, action, identifiers, data } : OdpEvent ) : void ;
4848
49- registerVuid ( vuid : string ) : void ;
49+ setVuid ( vuid : string ) : void ;
5050}
5151
5252export enum Status {
@@ -94,6 +94,8 @@ export abstract class OdpManager implements IOdpManager {
9494 */
9595 protected odpIntegrationConfig ?: OdpIntegrationConfig ;
9696
97+ protected vuid ?: string ;
98+
9799 constructor ( {
98100 odpIntegrationConfig,
99101 segmentManager,
@@ -123,7 +125,24 @@ export abstract class OdpManager implements IOdpManager {
123125 }
124126 }
125127
126- abstract registerVuid ( vuid : string ) : void ;
128+ setVuid ( vuid : string ) : void {
129+ if ( ! this . odpIntegrationConfig ) {
130+ this . logger . log ( LogLevel . ERROR , ERROR_MESSAGES . ODP_CONFIG_NOT_AVAILABLE ) ;
131+ return ;
132+ }
133+
134+ if ( ! this . odpIntegrationConfig . integrated ) {
135+ this . logger . log ( LogLevel . INFO , ERROR_MESSAGES . ODP_NOT_INTEGRATED ) ;
136+ return ;
137+ }
138+
139+ try {
140+ this . vuid = vuid ;
141+ this . eventManager . sendInitializedEvent ( vuid ) ;
142+ } catch ( e ) {
143+ this . logger . log ( LogLevel . ERROR , ERROR_MESSAGES . ODP_VUID_REGISTRATION_FAILED ) ;
144+ }
145+ }
127146
128147 getStatus ( ) : Status {
129148 return this . status ;
@@ -271,6 +290,11 @@ export abstract class OdpManager implements IOdpManager {
271290 throw new Error ( 'ODP action is not valid (cannot be empty).' ) ;
272291 }
273292
293+ if ( this . vuid ) {
294+ identifiers = new Map ( identifiers ) ;
295+ identifiers . set ( ODP_USER_KEY . VUID , this . vuid ) ;
296+ }
297+
274298 this . eventManager . sendEvent ( new OdpEvent ( mType , action , identifiers , data ) ) ;
275299 }
276300}
0 commit comments