@@ -340,7 +340,9 @@ def _get_feature_variable_for_type(
340
340
user_context = OptimizelyUserContext (self , self .logger , user_id , attributes , False )
341
341
342
342
decision , _ = self .decision_service .get_variation_for_feature (project_config , feature_flag , user_context )
343
-
343
+ experiment_id = decision .experiment .id if decision .experiment else None
344
+ variation_id = decision .variation .id if decision .variation else None
345
+
344
346
if decision .variation :
345
347
346
348
feature_enabled = decision .variation .featureEnabled
@@ -386,6 +388,8 @@ def _get_feature_variable_for_type(
386
388
'variable_value' : actual_value ,
387
389
'variable_type' : variable_type ,
388
390
'source_info' : source_info ,
391
+ 'experiment_id' : experiment_id ,
392
+ 'variation_id' : variation_id
389
393
},
390
394
)
391
395
return actual_value
@@ -427,7 +431,9 @@ def _get_all_feature_variables_for_type(
427
431
user_context = OptimizelyUserContext (self , self .logger , user_id , attributes , False )
428
432
429
433
decision , _ = self .decision_service .get_variation_for_feature (project_config , feature_flag , user_context )
430
-
434
+ experiment_id = decision .experiment .id if decision .experiment else None
435
+ variation_id = decision .variation .id if decision .variation else None
436
+
431
437
if decision .variation :
432
438
433
439
feature_enabled = decision .variation .featureEnabled
@@ -480,6 +486,8 @@ def _get_all_feature_variables_for_type(
480
486
'variable_values' : all_variables ,
481
487
'source' : decision .source ,
482
488
'source_info' : source_info ,
489
+ 'experiment_id' : experiment_id ,
490
+ 'variation_id' : variation_id
483
491
},
484
492
)
485
493
return all_variables
@@ -646,13 +654,21 @@ def get_variation(
646
654
decision_notification_type = enums .DecisionNotificationTypes .FEATURE_TEST
647
655
else :
648
656
decision_notification_type = enums .DecisionNotificationTypes .AB_TEST
649
-
657
+
658
+ experiment_id = experiment .id if experiment else None
659
+ variation_id = variation .id if variation else None
660
+
650
661
self .notification_center .send_notifications (
651
662
enums .NotificationTypes .DECISION ,
652
663
decision_notification_type ,
653
664
user_id ,
654
665
attributes or {},
655
- {'experiment_key' : experiment_key , 'variation_key' : variation_key },
666
+ {
667
+ 'experiment_key' : experiment_key ,
668
+ 'variation_key' : variation_key ,
669
+ 'experiment_id' : experiment_id ,
670
+ 'variation_id' : variation_id
671
+ },
656
672
)
657
673
658
674
return variation_key
@@ -738,6 +754,8 @@ def is_feature_enabled(self, feature_key: str, user_id: str, attributes: Optiona
738
754
'feature_enabled' : feature_enabled ,
739
755
'source' : decision .source ,
740
756
'source_info' : source_info ,
757
+ 'experiment_id' : decision .experiment .id ,
758
+ 'variation_id' : decision .variation .id
741
759
},
742
760
)
743
761
@@ -1202,6 +1220,15 @@ def _create_optimizely_decision(
1202
1220
if flag_decision is not None and flag_decision .variation is not None
1203
1221
else None
1204
1222
)
1223
+
1224
+ rollout_id = feature_flag .rolloutId if decision_source == DecisionSources .ROLLOUT else None
1225
+ experiment_id = project_config .get_experiment_id_by_key_or_rollout_id (rule_key , rollout_id )
1226
+ variation_id = None
1227
+ if variation_key :
1228
+ variation = project_config .get_variation_from_key_by_experiment_id (experiment_id , variation_key )
1229
+ if variation :
1230
+ variation_id = variation .id
1231
+
1205
1232
# Send notification
1206
1233
self .notification_center .send_notifications (
1207
1234
enums .NotificationTypes .DECISION ,
@@ -1215,7 +1242,9 @@ def _create_optimizely_decision(
1215
1242
'variation_key' : variation_key ,
1216
1243
'rule_key' : rule_key ,
1217
1244
'reasons' : decision_reasons if should_include_reasons else [],
1218
- 'decision_event_dispatched' : decision_event_dispatched
1245
+ 'decision_event_dispatched' : decision_event_dispatched ,
1246
+ 'experiment_id' : experiment_id ,
1247
+ 'variation_id' : variation_id
1219
1248
1220
1249
},
1221
1250
)
0 commit comments