@@ -36,7 +36,7 @@ var LOG_MESSAGES = enums.LOG_MESSAGES;
3636var MODULE_NAME = 'OPTIMIZELY' ;
3737var DECISION_SOURCES = enums . DECISION_SOURCES ;
3838var FEATURE_VARIABLE_TYPES = enums . FEATURE_VARIABLE_TYPES ;
39- var DECISION_INFO_TYPES = enums . DECISION_INFO_TYPES ;
39+ var DECISION_NOTIFICATION_TYPES = enums . DECISION_NOTIFICATION_TYPES ;
4040var NOTIFICATION_TYPES = enums . NOTIFICATION_TYPES ;
4141
4242var DEFAULT_EVENT_MAX_QUEUE_SIZE = 1 ;
@@ -343,10 +343,13 @@ Optimizely.prototype.getVariation = function(experimentKey, userId, attributes)
343343 }
344344
345345 var variationKey = this . decisionService . getVariation ( this . configObj , experimentKey , userId , attributes ) ;
346+ var decisionNotificationType = projectConfig . isFeatureExperiment ( this . configObj , experiment . id ) ? DECISION_NOTIFICATION_TYPES . FEATURE_TEST :
347+ DECISION_NOTIFICATION_TYPES . AB_TEST ;
348+
346349 this . notificationCenter . sendNotifications (
347350 NOTIFICATION_TYPES . DECISION ,
348351 {
349- type : DECISION_INFO_TYPES . EXPERIMENT ,
352+ type : decisionNotificationType ,
350353 userId : userId ,
351354 attributes : attributes || { } ,
352355 decisionInfo : {
@@ -501,16 +504,17 @@ Optimizely.prototype.isFeatureEnabled = function(featureKey, userId, attributes)
501504 }
502505
503506 var featureEnabled = false ;
504- var experimentKey = null ;
505- var variationKey = null ;
506507 var decision = this . decisionService . getVariationForFeature ( this . configObj , feature , userId , attributes ) ;
507508 var variation = decision . variation ;
508-
509+ var sourceInfo = { } ;
510+
509511 if ( ! ! variation ) {
510512 featureEnabled = variation . featureEnabled ;
511- if ( decision . decisionSource === DECISION_SOURCES . EXPERIMENT ) {
512- experimentKey = decision . experiment . key ;
513- variationKey = decision . variation . key ;
513+ if ( decision . decisionSource === DECISION_SOURCES . FEATURE_TEST ) {
514+ sourceInfo = {
515+ experimentKey : decision . experiment . key ,
516+ variationKey : decision . variation . key ,
517+ }
514518 // got a variation from the exp, so we track the impression
515519 this . _sendImpressionEvent ( decision . experiment . key , decision . variation . key , userId , attributes ) ;
516520 }
@@ -523,19 +527,20 @@ Optimizely.prototype.isFeatureEnabled = function(featureKey, userId, attributes)
523527 featureEnabled = false ;
524528 }
525529
530+ var featureInfo = {
531+ featureKey : featureKey ,
532+ featureEnabled : featureEnabled ,
533+ source : decision . decisionSource ,
534+ sourceInfo : sourceInfo
535+ } ;
536+
526537 this . notificationCenter . sendNotifications (
527- enums . NOTIFICATION_TYPES . DECISION ,
538+ NOTIFICATION_TYPES . DECISION ,
528539 {
529- type : DECISION_INFO_TYPES . FEATURE ,
540+ type : DECISION_NOTIFICATION_TYPES . FEATURE ,
530541 userId : userId ,
531542 attributes : attributes || { } ,
532- decisionInfo : {
533- featureKey : featureKey ,
534- featureEnabled : featureEnabled ,
535- source : decision . decisionSource ,
536- sourceExperimentKey : experimentKey ,
537- sourceVariationKey : variationKey ,
538- }
543+ decisionInfo : featureInfo ,
539544 }
540545 ) ;
541546
@@ -655,29 +660,29 @@ Optimizely.prototype._getFeatureVariableForType = function(featureKey, variableK
655660 variableKey , featureFlag . key ) ) ;
656661 }
657662
658- var experimentKey = null ;
659- var variationKey = null ;
660- if ( decision . decisionSource === DECISION_SOURCES . EXPERIMENT ) {
661- experimentKey = decision . experiment . key ;
662- variationKey = decision . variation . key ;
663+ var sourceInfo = { } ;
664+ if ( decision . decisionSource === DECISION_SOURCES . FEATURE_TEST ) {
665+ sourceInfo = {
666+ experimentKey : decision . experiment . key ,
667+ variationKey : decision . variation . key ,
668+ }
663669 }
664670
665671 var typeCastedValue = projectConfig . getTypeCastValue ( variableValue , variableType , this . logger ) ;
666672 this . notificationCenter . sendNotifications (
667- enums . NOTIFICATION_TYPES . DECISION ,
673+ NOTIFICATION_TYPES . DECISION ,
668674 {
669- type : DECISION_INFO_TYPES . FEATURE_VARIABLE ,
675+ type : DECISION_NOTIFICATION_TYPES . FEATURE_VARIABLE ,
670676 userId : userId ,
671677 attributes : attributes || { } ,
672678 decisionInfo : {
673679 featureKey : featureKey ,
674680 featureEnabled : featureEnabled ,
681+ source : decision . decisionSource ,
675682 variableKey : variableKey ,
676683 variableValue : typeCastedValue ,
677684 variableType : variableType ,
678- source : decision . decisionSource ,
679- sourceExperimentKey : experimentKey ,
680- sourceVariationKey : variationKey
685+ sourceInfo : sourceInfo ,
681686 }
682687 }
683688 ) ;
0 commit comments