@@ -325,7 +325,7 @@ open class OptimizelyManager: NSObject {
325
325
326
326
var args : Array < Any ? > = ( self . notificationCenter as! DefaultNotificationCenter ) . getArgumentsForDecisionListener ( notificationType: Constants . DecisionTypeKeys. experiment, userId: userId, attributes: attributes)
327
327
328
- var decisionInfo = Dictionary < String , Any > ( )
328
+ var decisionInfo = [ String: Any] ( )
329
329
decisionInfo [ Constants . NotificationKeys. experiment] = nil
330
330
decisionInfo [ Constants . NotificationKeys. variation] = nil
331
331
@@ -411,7 +411,7 @@ open class OptimizelyManager: NSObject {
411
411
412
412
var args : Array < Any ? > = ( self . notificationCenter as! DefaultNotificationCenter ) . getArgumentsForDecisionListener ( notificationType: Constants . DecisionTypeKeys. isFeatureEnabled, userId: userId, attributes: attributes)
413
413
414
- var decisionInfo = Dictionary < String , Any > ( )
414
+ var decisionInfo = [ String: Any] ( )
415
415
decisionInfo [ Constants . DecisionInfoKeys. feature] = featureKey
416
416
decisionInfo [ Constants . DecisionInfoKeys. source] = Constants . DecisionSource. Rollout
417
417
decisionInfo [ Constants . DecisionInfoKeys. featureEnabled] = false
@@ -561,18 +561,26 @@ open class OptimizelyManager: NSObject {
561
561
throw OptimizelyError . variableUnknown
562
562
}
563
563
564
+ var decisionInfo = [ String: Any] ( )
565
+ decisionInfo [ Constants . DecisionInfoKeys. sourceExperiment] = nil
566
+ decisionInfo [ Constants . DecisionInfoKeys. sourceVariation] = nil
567
+
568
+ // TODO: [Jae] optional? fallback to empty string is OK?
564
569
var featureValue = variable. defaultValue ?? " "
565
570
566
571
var _attributes = OptimizelyAttributes ( )
567
- if attributes != nil {
568
- _attributes = attributes!
572
+ if let attributes = attributes {
573
+ _attributes = attributes
569
574
}
570
- if let decision = self . decisionService. getVariationForFeature ( config: config, featureFlag: featureFlag, userId: userId, attributes: _attributes) {
571
- if let variation = decision. variation,
572
- let featureVariableUsage = variation. variables? . filter ( { $0. id == variable. id} ) . first
573
- {
574
- if let featureEnabled = variation. featureEnabled, featureEnabled {
575
- featureValue = featureVariableUsage. value
575
+ let decision = self . decisionService. getVariationForFeature ( config: config, featureFlag: featureFlag, userId: userId, attributes: _attributes)
576
+ if let decision = decision {
577
+ if let experiment = decision. experiment {
578
+ decisionInfo [ Constants . DecisionInfoKeys. sourceExperiment] = experiment. key
579
+ decisionInfo [ Constants . DecisionInfoKeys. sourceVariation] = decision. variation? . key
580
+ }
581
+ if let featureVariable = decision. variation? . variables? . filter ( { $0. id == variable. id} ) . first {
582
+ if let featureEnabled = decision. variation? . featureEnabled, featureEnabled {
583
+ featureValue = featureVariable. value
576
584
} else {
577
585
// add standard log message here
578
586
}
@@ -605,6 +613,18 @@ open class OptimizelyManager: NSObject {
605
613
throw OptimizelyError . variableValueInvalid ( variableKey)
606
614
}
607
615
616
+ var args : Array < Any ? > = ( self . notificationCenter as! DefaultNotificationCenter ) . getArgumentsForDecisionListener ( notificationType: Constants . DecisionTypeKeys. featureVariable, userId: userId, attributes: _attributes)
617
+
618
+ decisionInfo [ Constants . DecisionInfoKeys. feature] = featureKey
619
+ decisionInfo [ Constants . DecisionInfoKeys. featureEnabled] = decision? . variation? . featureEnabled ?? false
620
+ decisionInfo [ Constants . DecisionInfoKeys. variable] = variableKey
621
+ decisionInfo [ Constants . DecisionInfoKeys. variableType] = typeName
622
+ decisionInfo [ Constants . DecisionInfoKeys. variableValue] = value
623
+ decisionInfo [ Constants . DecisionInfoKeys. source] = ( decision? . experiment != nil ? Constants . DecisionSource. Experiment : Constants . DecisionSource. Rollout)
624
+ args. append ( decisionInfo)
625
+
626
+ self . notificationCenter. sendNotifications ( type: NotificationType . Decision. rawValue, args: args)
627
+
608
628
return value
609
629
}
610
630
0 commit comments