@@ -594,10 +594,6 @@ describe('RoktManager', () => {
594594 mapped_key : 'test_value' , // This key should be mapped
595595 other_attr : 'other_value' // This key should remain unchanged
596596 } ,
597- initialAttributes : {
598- original_key : 'test_value' ,
599- other_attr : 'other_value'
600- }
601597 } ;
602598
603599 expect ( kit . selectPlacements ) . toHaveBeenCalledWith ( expectedMappedOptions ) ;
@@ -664,7 +660,6 @@ describe('RoktManager', () => {
664660 roktManager . selectPlacements ( options ) ;
665661 expect ( kit . selectPlacements ) . toHaveBeenCalledWith ( {
666662 attributes : { } ,
667- initialAttributes : { }
668663 } ) ;
669664 } ) ;
670665
@@ -705,13 +700,6 @@ describe('RoktManager', () => {
705700 isActive : false ,
706701 interests : 'sports,music,books'
707702 } ,
708- initialAttributes : {
709- age : 25 ,
710- score : 100.5 ,
711- isSubscribed : true ,
712- isActive : false ,
713- interests : 'sports,music,books'
714- }
715703 } ) ;
716704 } ) ;
717705
@@ -776,7 +764,6 @@ describe('RoktManager', () => {
776764 expect ( roktManager [ 'messageQueue' ] . size ) . toBe ( 0 ) ;
777765 expect ( kit . selectPlacements ) . toHaveBeenCalledWith ( {
778766 attributes : { } ,
779- initialAttributes : { }
780767 } ) ;
781768 expect ( result ) . toEqual ( expectedResult ) ;
782769 } ) ;
@@ -825,13 +812,6 @@ describe('RoktManager', () => {
825812 isActive : false ,
826813 interests : 'sports,music,books'
827814 } ,
828- initialAttributes : {
829- age : 25 ,
830- score : 100.5 ,
831- isSubscribed : true ,
832- isActive : false ,
833- interests : 'sports,music,books'
834- }
835815 } ;
836816
837817 roktManager . selectPlacements ( options ) ;
@@ -872,10 +852,6 @@ describe('RoktManager', () => {
872852 sandbox : true
873853 } ,
874854 identifier : 'test-identifier' ,
875- initialAttributes : {
876- customAttr : 'value' ,
877- sandbox : true
878- }
879855 } ) ;
880856 } ) ;
881857
@@ -913,10 +889,6 @@ describe('RoktManager', () => {
913889 customAttr : 'value' ,
914890 sandbox : false
915891 } ,
916- initialAttributes : {
917- customAttr : 'value' ,
918- sandbox : false
919- }
920892 } ) ;
921893 } ) ;
922894
@@ -954,10 +926,6 @@ describe('RoktManager', () => {
954926 sandbox : true
955927 } ,
956928 identifier : 'test-identifier' ,
957- initialAttributes : {
958- customAttr : 'value' ,
959- sandbox : true
960- }
961929 } ) ;
962930 } ) ;
963931
@@ -1004,11 +972,6 @@ describe('RoktManager', () => {
1004972 lastname : 'Doe' ,
1005973 score : 42 ,
1006974 } ,
1007- initialAttributes : {
1008- 'f.name' : 'John' ,
1009- 'last_name' : 'Doe' ,
1010- 'score' : 42 ,
1011- }
1012975 } ;
1013976
1014977 roktManager . selectPlacements ( options ) ;
@@ -1048,57 +1011,64 @@ describe('RoktManager', () => {
10481011 'score' : 42 ,
10491012 'age' : 25 ,
10501013 } ,
1051- initialAttributes : {
1052- 'f.name' : 'John' ,
1053- 'last_name' : 'Doe' ,
1054- 'score' : 42 ,
1055- 'age' : 25 ,
1056- }
10571014 } ) ;
10581015 } ) ;
10591016
1060- it ( 'should pass initialAttributes to kit for event logging' , ( ) => {
1017+ it ( 'should log developer passed attributes via verbose logger' , async ( ) => {
10611018 const kit : Partial < IRoktKit > = {
10621019 launcher : {
10631020 selectPlacements : jest . fn ( ) ,
10641021 hashAttributes : jest . fn ( ) ,
10651022 use : jest . fn ( ) ,
10661023 } ,
10671024 hashAttributes : jest . fn ( ) ,
1068- selectPlacements : jest . fn ( ) ,
1025+ selectPlacements : jest . fn ( ) . mockResolvedValue ( { } ) ,
10691026 setExtensionData : jest . fn ( ) ,
10701027 use : jest . fn ( ) ,
10711028 } ;
10721029
10731030 roktManager . kit = kit as IRoktKit ;
10741031 roktManager [ 'placementAttributesMapping' ] = [ ] ;
10751032
1033+ const mockIdentity = {
1034+ getCurrentUser : jest . fn ( ) . mockReturnValue ( {
1035+ getUserIdentities : ( ) => ( {
1036+ userIdentities : { }
1037+ } ) ,
1038+ setUserAttributes : jest . fn ( )
1039+ } ) ,
1040+ identify : jest . fn ( )
1041+ } as unknown as SDKIdentityApi ;
1042+
1043+ roktManager [ 'identityService' ] = mockIdentity ;
1044+
10761045 const options : IRoktSelectPlacementsOptions = {
10771046 attributes : {
10781047 'customAttr' : 'value' ,
10791048 }
10801049 } ;
10811050
1082- roktManager . selectPlacements ( options ) ;
1051+ await roktManager . selectPlacements ( options ) ;
10831052
1084- expect ( kit . selectPlacements ) . toHaveBeenCalledWith (
1085- expect . objectContaining ( {
1086- initialAttributes : {
1087- 'customAttr' : 'value' ,
1088- }
1089- } )
1053+ expect ( mockMPInstance . Logger . verbose ) . toHaveBeenCalledWith (
1054+ 'MParticle.Rokt selectPlacements called with attributes: {"customAttr":"value"}'
10901055 ) ;
1056+ expect ( kit . selectPlacements ) . toHaveBeenCalledWith ( {
1057+ attributes : {
1058+ 'customAttr' : 'value' ,
1059+ }
1060+ } ) ;
10911061 } ) ;
10921062
1093- it ( 'should include original attributes in initialAttributes even after mapping' , ( ) => {
1063+ it ( 'should log original attributes even after mapping' , async ( ) => {
10941064 const kit : Partial < IRoktKit > = {
10951065 launcher : {
10961066 selectPlacements : jest . fn ( ) ,
10971067 hashAttributes : jest . fn ( ) ,
10981068 use : jest . fn ( ) ,
10991069 } ,
11001070 hashAttributes : jest . fn ( ) ,
1101- selectPlacements : jest . fn ( ) ,
1071+ selectPlacements : jest . fn ( ) . mockResolvedValue ( { } ) ,
11021072 setExtensionData : jest . fn ( ) ,
11031073 use : jest . fn ( ) ,
11041074 } ;
@@ -1113,29 +1083,38 @@ describe('RoktManager', () => {
11131083 }
11141084 ] ;
11151085
1086+ const mockIdentity = {
1087+ getCurrentUser : jest . fn ( ) . mockReturnValue ( {
1088+ getUserIdentities : ( ) => ( {
1089+ userIdentities : { }
1090+ } ) ,
1091+ setUserAttributes : jest . fn ( )
1092+ } ) ,
1093+ identify : jest . fn ( )
1094+ } as unknown as SDKIdentityApi ;
1095+
1096+ roktManager [ 'identityService' ] = mockIdentity ;
1097+
11161098 const options : IRoktSelectPlacementsOptions = {
11171099 attributes : {
11181100 'f.name' : 'John' ,
11191101 'userId' : 'user123' ,
11201102 }
11211103 } ;
11221104
1123- roktManager . selectPlacements ( options ) ;
1105+ await roktManager . selectPlacements ( options ) ;
11241106
1125- // initialAttributes should contain the ORIGINAL unmapped attributes
1126- expect ( kit . selectPlacements ) . toHaveBeenCalledWith (
1127- expect . objectContaining ( {
1128- initialAttributes : {
1129- 'f.name' : 'John' ,
1130- 'userId' : 'user123' ,
1131- } ,
1132- // attributes should be mapped
1133- attributes : {
1134- 'firstname' : 'John' ,
1135- 'userId' : 'user123' ,
1136- }
1137- } )
1107+
1108+ expect ( mockMPInstance . Logger . verbose ) . toHaveBeenCalledWith (
1109+ 'MParticle.Rokt selectPlacements called with attributes: {"f.name":"John","userId":"user123"}'
11381110 ) ;
1111+
1112+ expect ( kit . selectPlacements ) . toHaveBeenCalledWith ( {
1113+ attributes : {
1114+ 'firstname' : 'John' ,
1115+ 'userId' : 'user123' ,
1116+ }
1117+ } ) ;
11391118 } ) ;
11401119
11411120 it ( 'should set the mapped attributes on the current user via setUserAttributes' , async ( ) => {
@@ -1230,10 +1209,6 @@ describe('RoktManager', () => {
12301209 'email' : 'test@example.com' ,
12311210 'sandbox' : true
12321211 } ,
1233- initialAttributes : {
1234- 'email' : 'test@example.com' ,
1235- 'sandbox' : true ,
1236- }
12371212 } ) ;
12381213
12391214 expect ( setUserAttributesSpy ) . not . toHaveBeenCalledWith ( {
0 commit comments