|
29 | 29 | from .decision.optimizely_decide_option import OptimizelyDecideOption |
30 | 30 | from .decision.optimizely_decision import OptimizelyDecision |
31 | 31 | from .decision.optimizely_decision_message import OptimizelyDecisionMessage |
32 | | -from .decision_service import Decision, VariationResult |
| 32 | +from .decision_service import Decision |
33 | 33 | from .error_handler import NoOpErrorHandler, BaseErrorHandler |
34 | 34 | from .event import event_factory, user_event_factory |
35 | 35 | from .event.event_processor import BatchEventProcessor, BaseEventProcessor |
@@ -535,10 +535,8 @@ def activate(self, experiment_key: str, user_id: str, attributes: Optional[UserA |
535 | 535 | self.logger.error(enums.Errors.INVALID_PROJECT_CONFIG.format('activate')) |
536 | 536 | return None |
537 | 537 |
|
538 | | - variation_result = self.get_variation(experiment_key, user_id, attributes) |
539 | | - variation_key = None |
540 | | - if variation_result: |
541 | | - variation_key = variation_result['variation'].key |
| 538 | + variation_key = self.get_variation(experiment_key, user_id, attributes) |
| 539 | + |
542 | 540 | if not variation_key: |
543 | 541 | self.logger.info(f'Not activating user "{user_id}".') |
544 | 542 | return None |
@@ -614,18 +612,17 @@ def track( |
614 | 612 |
|
615 | 613 | def get_variation( |
616 | 614 | self, experiment_key: str, user_id: str, attributes: Optional[UserAttributes] = None |
617 | | - ) -> Optional[VariationResult]: |
618 | | - """ |
619 | | - Returns the variation result for the given user in the specified experiment. |
| 615 | + ) -> Optional[str]: |
| 616 | + """ Gets variation where user will be bucketed. |
620 | 617 |
|
621 | 618 | Args: |
622 | | - experiment_key: The key identifying the experiment. |
623 | | - user_id: The user ID. |
624 | | - attributes: Optional dictionary of user attributes. |
| 619 | + experiment_key: Experiment for which user variation needs to be determined. |
| 620 | + user_id: ID for user. |
| 621 | + attributes: Dict representing user attributes. |
625 | 622 |
|
626 | 623 | Returns: |
627 | | - A VariationResult object containing the variation assigned to the user, or None if the user is not |
628 | | - bucketed into any variation or the experiment is not running. |
| 624 | + Variation key representing the variation the user will be bucketed in. |
| 625 | + None if user is not in experiment or if experiment is not Running. |
629 | 626 | """ |
630 | 627 |
|
631 | 628 | if not self.is_valid: |
@@ -678,7 +675,7 @@ def get_variation( |
678 | 675 | {'experiment_key': experiment_key, 'variation_key': variation_key}, |
679 | 676 | ) |
680 | 677 |
|
681 | | - return variation_result |
| 678 | + return variation_key |
682 | 679 |
|
683 | 680 | def is_feature_enabled(self, feature_key: str, user_id: str, attributes: Optional[UserAttributes] = None) -> bool: |
684 | 681 | """ Returns true if the feature is enabled for the given user. |
|
0 commit comments