@@ -340,7 +340,9 @@ def _get_feature_variable_for_type(
340340 user_context = OptimizelyUserContext (self , self .logger , user_id , attributes , False )
341341
342342 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+
344346 if decision .variation :
345347
346348 feature_enabled = decision .variation .featureEnabled
@@ -386,6 +388,8 @@ def _get_feature_variable_for_type(
386388 'variable_value' : actual_value ,
387389 'variable_type' : variable_type ,
388390 'source_info' : source_info ,
391+ 'experiment_id' : experiment_id ,
392+ 'variation_id' : variation_id
389393 },
390394 )
391395 return actual_value
@@ -427,7 +431,9 @@ def _get_all_feature_variables_for_type(
427431 user_context = OptimizelyUserContext (self , self .logger , user_id , attributes , False )
428432
429433 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+
431437 if decision .variation :
432438
433439 feature_enabled = decision .variation .featureEnabled
@@ -480,6 +486,8 @@ def _get_all_feature_variables_for_type(
480486 'variable_values' : all_variables ,
481487 'source' : decision .source ,
482488 'source_info' : source_info ,
489+ 'experiment_id' : experiment_id ,
490+ 'variation_id' : variation_id
483491 },
484492 )
485493 return all_variables
@@ -646,13 +654,21 @@ def get_variation(
646654 decision_notification_type = enums .DecisionNotificationTypes .FEATURE_TEST
647655 else :
648656 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+
650661 self .notification_center .send_notifications (
651662 enums .NotificationTypes .DECISION ,
652663 decision_notification_type ,
653664 user_id ,
654665 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+ },
656672 )
657673
658674 return variation_key
@@ -738,6 +754,8 @@ def is_feature_enabled(self, feature_key: str, user_id: str, attributes: Optiona
738754 'feature_enabled' : feature_enabled ,
739755 'source' : decision .source ,
740756 'source_info' : source_info ,
757+ 'experiment_id' : decision .experiment .id ,
758+ 'variation_id' : decision .variation .id
741759 },
742760 )
743761
@@ -1202,6 +1220,15 @@ def _create_optimizely_decision(
12021220 if flag_decision is not None and flag_decision .variation is not None
12031221 else None
12041222 )
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+
12051232 # Send notification
12061233 self .notification_center .send_notifications (
12071234 enums .NotificationTypes .DECISION ,
@@ -1215,7 +1242,9 @@ def _create_optimizely_decision(
12151242 'variation_key' : variation_key ,
12161243 'rule_key' : rule_key ,
12171244 '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
12191248
12201249 },
12211250 )
0 commit comments