Skip to content

Commit f58713f

Browse files
fetching experiment_id and variation_id from flag_decision
1 parent 120a408 commit f58713f

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

optimizely/optimizely.py

+24-9
Original file line numberDiff line numberDiff line change
@@ -1203,17 +1203,32 @@ def _create_optimizely_decision(
12031203
else None
12041204
)
12051205

1206-
rollout_id = None
1207-
if decision_source == DecisionSources.ROLLOUT and feature_flag is not None:
1208-
rollout_id = feature_flag.rolloutId
1206+
# rollout_id = None
1207+
# if decision_source == DecisionSources.ROLLOUT and feature_flag is not None:
1208+
# rollout_id = feature_flag.rolloutId
1209+
# experiment_id = None
1210+
# if rule_key is not None:
1211+
# experiment_id = project_config.get_experiment_id_by_key_or_rollout_id(rule_key, rollout_id)
1212+
# variation_id = None
1213+
# if experiment_id and variation_key:
1214+
# variation = project_config.get_variation_from_key_by_experiment_id(experiment_id, variation_key)
1215+
# if variation:
1216+
# variation_id = variation.id
1217+
12091218
experiment_id = None
1210-
if rule_key is not None:
1211-
experiment_id = project_config.get_experiment_id_by_key_or_rollout_id(rule_key, rollout_id)
12121219
variation_id = None
1213-
if experiment_id and variation_key:
1214-
variation = project_config.get_variation_from_key_by_experiment_id(experiment_id, variation_key)
1215-
if variation:
1216-
variation_id = variation.id
1220+
1221+
try:
1222+
if flag_decision.experiment is not None:
1223+
experiment_id = flag_decision.experiment.id
1224+
except AttributeError:
1225+
self.logger.warning("flag_decision.experiment has no attribute 'id'")
1226+
1227+
try:
1228+
if flag_decision.variation is not None:
1229+
variation_id = flag_decision.variation.id
1230+
except AttributeError:
1231+
self.logger.warning("flag_decision.variation has no attribute 'id'")
12171232

12181233
# Send notification
12191234
self.notification_center.send_notifications(

0 commit comments

Comments
 (0)