@@ -632,35 +632,46 @@ Optimizely.prototype._getFeatureVariableForType = function(featureKey, variableK
632
632
return null ;
633
633
}
634
634
635
- var decision = this . decisionService . getVariationForFeature ( this . configObj , featureFlag , userId , attributes ) ;
636
635
var variableValue ;
636
+ var featureEnabled = false ;
637
+ var decision = this . decisionService . getVariationForFeature ( this . configObj , featureFlag , userId , attributes ) ;
638
+
637
639
if ( decision . variation !== null ) {
638
- variableValue = projectConfig . getVariableValueForVariation (
639
- this . configObj ,
640
- variable ,
641
- decision . variation ,
642
- this . logger
643
- ) ;
644
- this . logger . log (
645
- LOG_LEVEL . INFO ,
646
- sprintf (
647
- LOG_MESSAGES . USER_RECEIVED_VARIABLE_VALUE ,
648
- MODULE_NAME ,
649
- variableKey ,
650
- featureFlag . key ,
651
- variableValue ,
652
- userId
653
- )
654
- ) ;
640
+ featureEnabled = decision . variation . featureEnabled ;
641
+ variableValue = projectConfig . getVariableValueForVariation ( this . configObj , variable , decision . variation , this . logger ) ;
642
+ this . logger . log ( LOG_LEVEL . INFO , sprintf ( LOG_MESSAGES . USER_RECEIVED_VARIABLE_VALUE , MODULE_NAME , variableKey , featureFlag . key , variableValue , userId ) ) ;
655
643
} else {
656
644
variableValue = variable . defaultValue ;
657
- this . logger . log (
658
- LOG_LEVEL . INFO ,
659
- sprintf ( LOG_MESSAGES . USER_RECEIVED_DEFAULT_VARIABLE_VALUE , MODULE_NAME , userId , variableKey , featureFlag . key )
660
- ) ;
645
+ this . logger . log ( LOG_LEVEL . INFO , sprintf ( LOG_MESSAGES . USER_RECEIVED_DEFAULT_VARIABLE_VALUE , MODULE_NAME , userId , variableKey , featureFlag . key ) ) ;
661
646
}
662
647
663
- return projectConfig . getTypeCastValue ( variableValue , variableType , this . logger ) ;
648
+ var experimentKey = null ;
649
+ var variationKey = null ;
650
+ if ( decision . decisionSource === DECISION_SOURCES . EXPERIMENT ) {
651
+ experimentKey = decision . experiment . key ;
652
+ variationKey = decision . variation . key ;
653
+ }
654
+
655
+ var typeCastedValue = projectConfig . getTypeCastValue ( variableValue , variableType , this . logger ) ;
656
+ this . notificationCenter . sendNotifications (
657
+ enums . NOTIFICATION_TYPES . DECISION ,
658
+ {
659
+ type : DECISION_INFO_TYPES . FEATURE_VARIABLE ,
660
+ userId : userId ,
661
+ attributes : attributes || { } ,
662
+ decisionInfo : {
663
+ featureKey : featureKey ,
664
+ featureEnabled : featureEnabled ,
665
+ variableKey : variableKey ,
666
+ variableValue : typeCastedValue ,
667
+ variableType : variableType ,
668
+ source : decision . decisionSource ,
669
+ sourceExperimentKey : experimentKey ,
670
+ sourceVariationKey : variationKey
671
+ }
672
+ }
673
+ ) ;
674
+ return typeCastedValue ;
664
675
} ;
665
676
666
677
/**
0 commit comments