@@ -4802,7 +4802,7 @@ def running?; end
4802
4802
project = Optimizely ::Project . new ( nil , nil , spy_logger , error_handler , false , nil , 'sdk-key' , nil , nil , nil , [ ] , { } , sdk_settings )
4803
4803
event_manager = project . odp_manager . instance_variable_get ( '@event_manager' )
4804
4804
expect ( event_manager ) . to be_a CustomEventManager
4805
- project . send_odp_event ( action : 'test' )
4805
+ project . send_odp_event ( action : 'test' , identifiers : { wow : 'great' } )
4806
4806
project . close
4807
4807
4808
4808
expect ( spy_logger ) . not_to have_received ( :log ) . with ( Logger ::ERROR , anything )
@@ -4830,7 +4830,7 @@ class InvalidEventManager; end # rubocop:disable Lint/ConstantDefinitionInBlock
4830
4830
expect ( spy_logger ) . to receive ( :log ) . once . with ( Logger ::DEBUG , 'ODP event queue: flushing batch size 1.' )
4831
4831
expect ( spy_logger ) . not_to receive ( :log ) . with ( Logger ::ERROR , anything )
4832
4832
project = Optimizely ::Project . new ( config_body_integrations_JSON , nil , spy_logger )
4833
- project . send_odp_event ( type : 'wow' , action : 'great' , identifiers : { } , data : { } )
4833
+ project . send_odp_event ( type : 'wow' , action : 'great' , identifiers : { amazing : 'fantastic' } , data : { } )
4834
4834
project . close
4835
4835
end
4836
4836
@@ -4847,22 +4847,22 @@ class InvalidEventManager; end # rubocop:disable Lint/ConstantDefinitionInBlock
4847
4847
project . send ( :project_config )
4848
4848
sleep 0.1 until project . odp_manager . instance_variable_get ( '@event_manager' ) . instance_variable_get ( '@event_queue' ) . empty?
4849
4849
4850
- project . send_odp_event ( type : 'wow' , action : 'great' , identifiers : { } , data : { } )
4850
+ project . send_odp_event ( type : 'wow' , action : 'great' , identifiers : { amazing : 'fantastic' } , data : { } )
4851
4851
project . close
4852
4852
end
4853
4853
4854
4854
it 'should log error when odp disabled' do
4855
4855
expect ( spy_logger ) . to receive ( :log ) . once . with ( Logger ::ERROR , 'ODP is not enabled.' )
4856
4856
sdk_settings = Optimizely ::Helpers ::OptimizelySdkSettings . new ( disable_odp : true )
4857
4857
custom_project_instance = Optimizely ::Project . new ( config_body_integrations_JSON , nil , spy_logger , error_handler , false , nil , nil , nil , nil , nil , [ ] , { } , sdk_settings )
4858
- custom_project_instance . send_odp_event ( type : 'wow' , action : 'great' , identifiers : { } , data : { } )
4858
+ custom_project_instance . send_odp_event ( type : 'wow' , action : 'great' , identifiers : { amazing : 'fantastic' } , data : { } )
4859
4859
custom_project_instance . close
4860
4860
end
4861
4861
4862
4862
it 'should log debug if datafile not ready' do
4863
4863
expect ( spy_logger ) . to receive ( :log ) . once . with ( Logger ::DEBUG , 'ODP event queue: cannot send before config has been set.' )
4864
4864
project = Optimizely ::Project . new ( nil , nil , spy_logger , nil , false , nil , sdk_key )
4865
- project . send_odp_event ( type : 'wow' , action : 'great' , identifiers : { } , data : { } )
4865
+ project . send_odp_event ( type : 'wow' , action : 'great' , identifiers : { amazing : 'fantastic' } , data : { } )
4866
4866
project . close
4867
4867
end
4868
4868
@@ -4873,17 +4873,31 @@ class InvalidEventManager; end # rubocop:disable Lint/ConstantDefinitionInBlock
4873
4873
sdk_settings = Optimizely ::Helpers ::OptimizelySdkSettings . new ( disable_odp : true )
4874
4874
project = Optimizely ::Project . new ( nil , nil , spy_logger , error_handler , false , nil , sdk_key , nil , nil , nil , [ ] , { } , sdk_settings )
4875
4875
sleep 0.1 until project . config_manager . ready?
4876
- project . send_odp_event ( type : 'wow' , action : 'great' , identifiers : { } , data : { } )
4876
+ project . send_odp_event ( type : 'wow' , action : 'great' , identifiers : { amazing : 'fantastic' } , data : { } )
4877
4877
project . close
4878
4878
end
4879
4879
4880
4880
it 'should log error with invalid data' do
4881
4881
expect ( spy_logger ) . to receive ( :log ) . once . with ( Logger ::ERROR , 'ODP data is not valid.' )
4882
4882
project = Optimizely ::Project . new ( config_body_integrations_JSON , nil , spy_logger )
4883
+ project . send_odp_event ( type : 'wow' , action : 'great' , identifiers : { amazing : 'fantastic' } , data : { 'wow' : { } } )
4884
+ project . close
4885
+ end
4886
+
4887
+ it 'should log error with empty identifiers' do
4888
+ expect ( spy_logger ) . to receive ( :log ) . once . with ( Logger ::ERROR , 'ODP events must have at least one key-value pair in identifiers.' )
4889
+ project = Optimizely ::Project . new ( config_body_integrations_JSON , nil , spy_logger )
4883
4890
project . send_odp_event ( type : 'wow' , action : 'great' , identifiers : { } , data : { 'wow' : { } } )
4884
4891
project . close
4885
4892
end
4886
4893
4894
+ it 'should log error with nil identifiers' do
4895
+ expect ( spy_logger ) . to receive ( :log ) . once . with ( Logger ::ERROR , 'ODP events must have at least one key-value pair in identifiers.' )
4896
+ project = Optimizely ::Project . new ( config_body_integrations_JSON , nil , spy_logger )
4897
+ project . send_odp_event ( type : 'wow' , action : 'great' , identifiers : nil , data : { 'wow' : { } } )
4898
+ project . close
4899
+ end
4900
+
4887
4901
it 'should not send odp events with legacy apis' do
4888
4902
experiment_key = 'experiment-segment'
4889
4903
feature_key = 'flag-segment'
0 commit comments