@@ -36,7 +36,7 @@ var LOG_MESSAGES = enums.LOG_MESSAGES;
36
36
var MODULE_NAME = 'OPTIMIZELY' ;
37
37
var DECISION_SOURCES = enums . DECISION_SOURCES ;
38
38
var 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 ;
40
40
var NOTIFICATION_TYPES = enums . NOTIFICATION_TYPES ;
41
41
42
42
var DEFAULT_EVENT_MAX_QUEUE_SIZE = 1 ;
@@ -343,10 +343,13 @@ Optimizely.prototype.getVariation = function(experimentKey, userId, attributes)
343
343
}
344
344
345
345
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
+
346
349
this . notificationCenter . sendNotifications (
347
350
NOTIFICATION_TYPES . DECISION ,
348
351
{
349
- type : DECISION_INFO_TYPES . EXPERIMENT ,
352
+ type : decisionNotificationType ,
350
353
userId : userId ,
351
354
attributes : attributes || { } ,
352
355
decisionInfo : {
@@ -501,16 +504,17 @@ Optimizely.prototype.isFeatureEnabled = function(featureKey, userId, attributes)
501
504
}
502
505
503
506
var featureEnabled = false ;
504
- var experimentKey = null ;
505
- var variationKey = null ;
506
507
var decision = this . decisionService . getVariationForFeature ( this . configObj , feature , userId , attributes ) ;
507
508
var variation = decision . variation ;
508
-
509
+ var sourceInfo = { } ;
510
+
509
511
if ( ! ! variation ) {
510
512
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
+ }
514
518
// got a variation from the exp, so we track the impression
515
519
this . _sendImpressionEvent ( decision . experiment . key , decision . variation . key , userId , attributes ) ;
516
520
}
@@ -523,19 +527,20 @@ Optimizely.prototype.isFeatureEnabled = function(featureKey, userId, attributes)
523
527
featureEnabled = false ;
524
528
}
525
529
530
+ var featureInfo = {
531
+ featureKey : featureKey ,
532
+ featureEnabled : featureEnabled ,
533
+ source : decision . decisionSource ,
534
+ sourceInfo : sourceInfo
535
+ } ;
536
+
526
537
this . notificationCenter . sendNotifications (
527
- enums . NOTIFICATION_TYPES . DECISION ,
538
+ NOTIFICATION_TYPES . DECISION ,
528
539
{
529
- type : DECISION_INFO_TYPES . FEATURE ,
540
+ type : DECISION_NOTIFICATION_TYPES . FEATURE ,
530
541
userId : userId ,
531
542
attributes : attributes || { } ,
532
- decisionInfo : {
533
- featureKey : featureKey ,
534
- featureEnabled : featureEnabled ,
535
- source : decision . decisionSource ,
536
- sourceExperimentKey : experimentKey ,
537
- sourceVariationKey : variationKey ,
538
- }
543
+ decisionInfo : featureInfo ,
539
544
}
540
545
) ;
541
546
@@ -655,29 +660,29 @@ Optimizely.prototype._getFeatureVariableForType = function(featureKey, variableK
655
660
variableKey , featureFlag . key ) ) ;
656
661
}
657
662
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
+ }
663
669
}
664
670
665
671
var typeCastedValue = projectConfig . getTypeCastValue ( variableValue , variableType , this . logger ) ;
666
672
this . notificationCenter . sendNotifications (
667
- enums . NOTIFICATION_TYPES . DECISION ,
673
+ NOTIFICATION_TYPES . DECISION ,
668
674
{
669
- type : DECISION_INFO_TYPES . FEATURE_VARIABLE ,
675
+ type : DECISION_NOTIFICATION_TYPES . FEATURE_VARIABLE ,
670
676
userId : userId ,
671
677
attributes : attributes || { } ,
672
678
decisionInfo : {
673
679
featureKey : featureKey ,
674
680
featureEnabled : featureEnabled ,
681
+ source : decision . decisionSource ,
675
682
variableKey : variableKey ,
676
683
variableValue : typeCastedValue ,
677
684
variableType : variableType ,
678
- source : decision . decisionSource ,
679
- sourceExperimentKey : experimentKey ,
680
- sourceVariationKey : variationKey
685
+ sourceInfo : sourceInfo ,
681
686
}
682
687
}
683
688
) ;
0 commit comments