@@ -200,7 +200,14 @@ const moduleId = 181;
200200const EVENT_NAME_SELECT_PLACEMENTS = 'selectPlacements' ;
201201const ADBLOCK_CONTROL_DOMAIN = 'apps.roktecommerce.com' ;
202202const INIT_LOG_SAMPLING_RATE = 0.1 ;
203- const MESSAGE_TYPE_PROFILE = 14 ; // mParticle MessageType.Profile
203+ const ROKT_IDENTITY_EVENT_TYPE = {
204+ LOGIN : 'login' ,
205+ LOGOUT : 'logout' ,
206+ MODIFY_USER : 'modify_user' ,
207+ IDENTIFY : 'identify' ,
208+ } as const ;
209+
210+ type RoktIdentityEventType = ( typeof ROKT_IDENTITY_EVENT_TYPE ) [ keyof typeof ROKT_IDENTITY_EVENT_TYPE ] ;
204211
205212// ============================================================
206213// Reporting service constants
@@ -759,25 +766,20 @@ class RoktKit implements KitInterface {
759766 mp ( ) . logEvent ( EVENT_NAME_SELECT_PLACEMENTS , EVENT_TYPE_OTHER , attributes as Record < string , unknown > ) ;
760767 }
761768
762- private buildIdentityEvent ( eventName : string , filteredUser : FilteredUser ) : BaseEvent {
769+ private buildIdentityEvent ( eventType : RoktIdentityEventType , filteredUser : FilteredUser ) : BaseEvent {
763770 const mpid = filteredUser . getMPID ( ) ;
764- const sessionId =
771+ const sessionUuid =
765772 mp ( ) && mp ( ) . sessionManager && typeof mp ( ) . sessionManager ! . getSession === 'function'
766773 ? mp ( ) . sessionManager ! . getSession ( )
767- : null ;
768- const userIdentities =
769- filteredUser . getUserIdentities && typeof filteredUser . getUserIdentities === 'function'
770- ? filteredUser . getUserIdentities ( ) . userIdentities
771- : null ;
774+ : undefined ;
772775
773776 return {
774- EventName : eventName ,
775- EventDataType : MESSAGE_TYPE_PROFILE ,
776- EventCategory : 0 ,
777- Timestamp : Date . now ( ) ,
778- MPID : mpid ,
779- SessionId : sessionId ,
780- UserIdentities : userIdentities ,
777+ event_type : eventType ,
778+ data : {
779+ timestamp_unixtime_ms : Date . now ( ) ,
780+ session_uuid : sessionUuid ?? undefined ,
781+ mpid,
782+ } ,
781783 } as unknown as BaseEvent ;
782784 }
783785
@@ -1106,28 +1108,28 @@ class RoktKit implements KitInterface {
11061108 const filteredUser = user as FilteredUser ;
11071109 this . filters . filteredUser = filteredUser ;
11081110 this . userAttributes = user . getAllUserAttributes ( ) ;
1109- this . pendingIdentityEvents . push ( this . buildIdentityEvent ( 'identify' , filteredUser ) ) ;
1111+ this . pendingIdentityEvents . push ( this . buildIdentityEvent ( ROKT_IDENTITY_EVENT_TYPE . IDENTIFY , filteredUser ) ) ;
11101112 return 'Successfully called onUserIdentified for forwarder: ' + name ;
11111113 }
11121114
11131115 public onLoginComplete ( user : IMParticleUser , _filteredIdentityRequest : unknown ) : string {
11141116 const filteredUser = user as FilteredUser ;
11151117 this . userAttributes = user . getAllUserAttributes ( ) ;
1116- this . pendingIdentityEvents . push ( this . buildIdentityEvent ( 'login' , filteredUser ) ) ;
1118+ this . pendingIdentityEvents . push ( this . buildIdentityEvent ( ROKT_IDENTITY_EVENT_TYPE . LOGIN , filteredUser ) ) ;
11171119 return 'Successfully called onLoginComplete for forwarder: ' + name ;
11181120 }
11191121
11201122 public onLogoutComplete ( user : IMParticleUser , _filteredIdentityRequest : unknown ) : string {
11211123 const filteredUser = user as FilteredUser ;
11221124 this . userAttributes = user . getAllUserAttributes ( ) ;
1123- this . pendingIdentityEvents . push ( this . buildIdentityEvent ( 'logout' , filteredUser ) ) ;
1125+ this . pendingIdentityEvents . push ( this . buildIdentityEvent ( ROKT_IDENTITY_EVENT_TYPE . LOGOUT , filteredUser ) ) ;
11241126 return 'Successfully called onLogoutComplete for forwarder: ' + name ;
11251127 }
11261128
11271129 public onModifyComplete ( user : IMParticleUser , _filteredIdentityRequest : unknown ) : string {
11281130 const filteredUser = user as FilteredUser ;
11291131 this . userAttributes = user . getAllUserAttributes ( ) ;
1130- this . pendingIdentityEvents . push ( this . buildIdentityEvent ( 'modify' , filteredUser ) ) ;
1132+ this . pendingIdentityEvents . push ( this . buildIdentityEvent ( ROKT_IDENTITY_EVENT_TYPE . MODIFY_USER , filteredUser ) ) ;
11311133 return 'Successfully called onModifyComplete for forwarder: ' + name ;
11321134 }
11331135
0 commit comments