Skip to content

Commit 70c281e

Browse files
committed
[FSSDK-11572] Python: Update impression event handling and send notification for global holdout
1 parent 1225cfb commit 70c281e

File tree

4 files changed

+361
-17
lines changed

4 files changed

+361
-17
lines changed

optimizely/decision_service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ def get_variation_for_feature(
672672
- 'error': Boolean indicating if an error occurred during the decision process.
673673
- 'reasons': List of log messages representing decision making for the feature.
674674
"""
675-
holdouts = project_config.get_holdouts_for_flag(feature.key)
675+
holdouts = project_config.get_holdouts_for_flag(feature.id)
676676

677677
if holdouts:
678678
# Has holdouts - use get_decision_for_flag which checks holdouts first
@@ -708,7 +708,7 @@ def get_decision_for_flag(
708708
user_id = user_context.user_id
709709

710710
# Check holdouts
711-
holdouts = project_config.get_holdouts_for_flag(feature_flag.key)
711+
holdouts = project_config.get_holdouts_for_flag(feature_flag.id)
712712
for holdout in holdouts:
713713
holdout_decision = self.get_variation_for_holdout(holdout, user_context, project_config)
714714
reasons.extend(holdout_decision['reasons'])

optimizely/optimizely.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ def _get_feature_variable_for_type(
453453
f'Returning default value for variable "{variable_key}" of feature flag "{feature_key}".'
454454
)
455455

456-
if decision.source == enums.DecisionSources.FEATURE_TEST:
456+
if decision.source in (enums.DecisionSources.FEATURE_TEST, enums.DecisionSources.HOLDOUT):
457457
source_info = {
458458
'experiment_key': decision.experiment.key if decision.experiment else None,
459459
'variation_key': self._get_variation_key(decision.variation),

optimizely/project_config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -834,19 +834,19 @@ def get_flag_variation(
834834

835835
return None
836836

837-
def get_holdouts_for_flag(self, flag_key: str) -> list[HoldoutDict]:
837+
def get_holdouts_for_flag(self, flag_id: str) -> list[HoldoutDict]:
838838
""" Helper method to get holdouts from an applied feature flag.
839839
840840
Args:
841-
flag_key: Key of the feature flag.
841+
flag_id: (REQUIRED) ID of the feature flag.
842842
843843
Returns:
844844
The holdouts that apply for a specific flag.
845845
"""
846846
if not self.holdouts:
847847
return []
848848

849-
return self.flag_holdouts_map.get(flag_key, [])
849+
return self.flag_holdouts_map.get(flag_id, [])
850850

851851
def get_holdout(self, holdout_id: str) -> Optional[HoldoutDict]:
852852
""" Helper method to get holdout from holdout ID.

0 commit comments

Comments
 (0)