2727use Optimizely \DecisionService \FeatureDecision ;
2828use Optimizely \Entity \Experiment ;
2929use Optimizely \Entity \FeatureVariable ;
30- use Optimizely \Enums \DecisionInfoTypes ;
30+ use Optimizely \Enums \DecisionNotificationTypes ;
3131use Optimizely \ErrorHandler \ErrorHandlerInterface ;
3232use Optimizely \ErrorHandler \NoOpErrorHandler ;
3333use Optimizely \Event \Builder \EventBuilder ;
@@ -408,11 +408,17 @@ public function getVariation($experimentKey, $userId, $attributes = null)
408408 $ variation = $ this ->_decisionService ->getVariation ($ experiment , $ userId , $ attributes );
409409 $ variationKey = ($ variation === null ) ? null : $ variation ->getKey ();
410410
411+ if ($ this ->_config ->isFeatureExperiment ($ experiment ->getId ())) {
412+ $ decisionNotificationType = DecisionNotificationTypes::FEATURE_TEST ;
413+ } else {
414+ $ decisionNotificationType = DecisionNotificationTypes::AB_TEST ;
415+ }
416+
411417 $ attributes = $ attributes ?: [];
412418 $ this ->notificationCenter ->sendNotifications (
413419 NotificationType::DECISION ,
414420 array (
415- DecisionInfoTypes:: EXPERIMENT ,
421+ $ decisionNotificationType ,
416422 $ userId ,
417423 $ attributes ,
418424 (object ) array (
@@ -519,9 +525,14 @@ public function isFeatureEnabled($featureFlagKey, $userId, $attributes = null)
519525 if ($ variation ) {
520526 $ experiment = $ decision ->getExperiment ();
521527 $ featureEnabled = $ variation ->getFeatureEnabled ();
522- if ($ decision ->getSource () == FeatureDecision::DECISION_SOURCE_EXPERIMENT ) {
528+ if ($ decision ->getSource () == FeatureDecision::DECISION_SOURCE_FEATURE_TEST ) {
523529 $ experimentKey = $ experiment ->getKey ();
524530 $ variationKey = $ variation ->getKey ();
531+ $ sourceInfo = (object ) array (
532+ 'experimentKey ' => $ experimentKey ,
533+ 'variationKey ' => $ variationKey
534+ );
535+
525536 $ this ->sendImpressionEvent ($ experimentKey , $ variationKey , $ userId , $ attributes );
526537 } else {
527538 $ this ->_logger ->log (Logger::INFO , "The user ' {$ userId }' is not being experimented on Feature Flag ' {$ featureFlagKey }'. " );
@@ -532,15 +543,14 @@ public function isFeatureEnabled($featureFlagKey, $userId, $attributes = null)
532543 $ this ->notificationCenter ->sendNotifications (
533544 NotificationType::DECISION ,
534545 array (
535- DecisionInfoTypes ::FEATURE ,
546+ DecisionNotificationTypes ::FEATURE ,
536547 $ userId ,
537548 $ attributes ,
538549 (object ) array (
539550 'featureKey ' =>$ featureFlagKey ,
540551 'featureEnabled ' => $ featureEnabled ,
541552 'source ' => $ decision ->getSource (),
542- 'sourceExperimentKey ' => isset ($ experimentKey ) ? $ experimentKey : null ,
543- 'sourceVariationKey ' => isset ($ variationKey ) ? $ variationKey : null
553+ 'sourceInfo ' => isset ($ sourceInfo ) ? $ sourceInfo : (object ) array ()
544554 )
545555 )
546556 );
@@ -654,9 +664,11 @@ public function getFeatureVariableValueForType(
654664 $ variation = $ decision ->getVariation ();
655665 $ featureEnabled = $ variation ->getFeatureEnabled ();
656666
657- if ($ decision ->getSource () == FeatureDecision::DECISION_SOURCE_EXPERIMENT ) {
658- $ experimentKey = $ experiment ->getKey ();
659- $ variationKey = $ variation ->getKey ();
667+ if ($ decision ->getSource () == FeatureDecision::DECISION_SOURCE_FEATURE_TEST ) {
668+ $ sourceInfo = (object ) array (
669+ 'experimentKey ' => $ experiment ->getKey (),
670+ 'variationKey ' => $ variation ->getKey ()
671+ );
660672 }
661673
662674 if ($ featureEnabled ) {
@@ -692,7 +704,7 @@ public function getFeatureVariableValueForType(
692704 $ this ->notificationCenter ->sendNotifications (
693705 NotificationType::DECISION ,
694706 array (
695- DecisionInfoTypes ::FEATURE_VARIABLE ,
707+ DecisionNotificationTypes ::FEATURE_VARIABLE ,
696708 $ userId ,
697709 $ attributes ,
698710 (object ) array (
@@ -702,8 +714,7 @@ public function getFeatureVariableValueForType(
702714 'variableType ' => $ variableType ,
703715 'variableValue ' => $ variableValue ,
704716 'source ' => $ decision ->getSource (),
705- 'sourceExperimentKey ' => isset ($ experimentKey ) ? $ experimentKey : null ,
706- 'sourceVariationKey ' => isset ($ variationKey ) ? $ variationKey : null
717+ 'sourceInfo ' => isset ($ sourceInfo ) ? $ sourceInfo : (object ) array ()
707718 )
708719 )
709720 );
0 commit comments