@@ -292,11 +292,10 @@ open class OptimizelyManager: NSObject {
292
292
throw OptimizelyError . experimentUnknown
293
293
}
294
294
295
- var args : Array < Any ? > = ( self . notificationCenter as! DefaultNotificationCenter ) . getArgumentsForDecisionListener ( notificationType: Constants . DecisionTypeKeys. experiment, userId: userId, attributes: attributes)
295
+ let decisionType = config. isFeatureExperiment ( id: experiment. id) ? Constants . DecisionTypeKeys. featureTest : Constants . DecisionTypeKeys. abTest
296
+ var args : Array < Any ? > = ( self . notificationCenter as! DefaultNotificationCenter ) . getArgumentsForDecisionListener ( notificationType: decisionType, userId: userId, attributes: attributes)
296
297
297
298
var decisionInfo = [ String: Any] ( )
298
- decisionInfo [ Constants . NotificationKeys. experiment] = nil
299
- decisionInfo [ Constants . NotificationKeys. variation] = nil
300
299
301
300
// fix DecisionService to throw error
302
301
guard let variation = decisionService. getVariation ( config: config, userId: userId, experiment: experiment, attributes: attributes ?? OptimizelyAttributes ( ) ) else {
@@ -305,8 +304,11 @@ open class OptimizelyManager: NSObject {
305
304
throw OptimizelyError . variationUnknown
306
305
}
307
306
308
- decisionInfo [ Constants . NotificationKeys. experiment] = experimentKey
309
- decisionInfo [ Constants . NotificationKeys. variation] = variation. key
307
+ var sourceInfo = [ String: Any] ( )
308
+ sourceInfo [ Constants . ExperimentDecisionInfoKeys. experiment] = experiment. key
309
+ sourceInfo [ Constants . ExperimentDecisionInfoKeys. variation] = variation. key
310
+ decisionInfo = sourceInfo
311
+
310
312
args. append ( decisionInfo)
311
313
self . notificationCenter. sendNotifications ( type: NotificationType . Decision. rawValue, args: args)
312
314
@@ -378,12 +380,13 @@ open class OptimizelyManager: NSObject {
378
380
// fix DecisionService to throw error
379
381
let pair = decisionService. getVariationForFeature ( config: config, featureFlag: featureFlag, userId: userId, attributes: attributes ?? OptimizelyAttributes ( ) )
380
382
381
- var args : Array < Any ? > = ( self . notificationCenter as! DefaultNotificationCenter ) . getArgumentsForDecisionListener ( notificationType: Constants . DecisionTypeKeys. isFeatureEnabled , userId: userId, attributes: attributes)
383
+ var args : Array < Any ? > = ( self . notificationCenter as! DefaultNotificationCenter ) . getArgumentsForDecisionListener ( notificationType: Constants . DecisionTypeKeys. feature , userId: userId, attributes: attributes)
382
384
383
385
var decisionInfo = [ String: Any] ( )
384
386
decisionInfo [ Constants . DecisionInfoKeys. feature] = featureKey
385
387
decisionInfo [ Constants . DecisionInfoKeys. source] = Constants . DecisionSource. Rollout
386
388
decisionInfo [ Constants . DecisionInfoKeys. featureEnabled] = false
389
+ decisionInfo [ Constants . DecisionInfoKeys. sourceInfo] = [ : ]
387
390
388
391
guard let variation = pair? . variation else {
389
392
args. append ( decisionInfo)
@@ -396,8 +399,10 @@ open class OptimizelyManager: NSObject {
396
399
// we came from an experiment if experiment is not nil
397
400
if let experiment = pair? . experiment {
398
401
399
- decisionInfo [ Constants . DecisionInfoKeys. sourceExperiment] = experiment. key
400
- decisionInfo [ Constants . DecisionInfoKeys. sourceVariation] = variation. key
402
+ var sourceInfo = [ String: Any] ( )
403
+ sourceInfo [ Constants . ExperimentDecisionInfoKeys. experiment] = experiment. key
404
+ sourceInfo [ Constants . ExperimentDecisionInfoKeys. variation] = variation. key
405
+ decisionInfo [ Constants . DecisionInfoKeys. sourceInfo] = sourceInfo
401
406
402
407
// TODO: fix to throw errors
403
408
guard let body = BatchEventBuilder . createImpressionEvent ( config: config,
@@ -427,7 +432,7 @@ open class OptimizelyManager: NSObject {
427
432
}
428
433
429
434
decisionInfo [ Constants . DecisionInfoKeys. featureEnabled] = featureEnabled
430
- decisionInfo [ Constants . DecisionInfoKeys. source] = ( pair? . experiment != nil ? Constants . DecisionSource. Experiment : Constants . DecisionSource. Rollout)
435
+ decisionInfo [ Constants . DecisionInfoKeys. source] = ( pair? . experiment != nil ? Constants . DecisionSource. FeatureTest : Constants . DecisionSource. Rollout)
431
436
args. append ( decisionInfo)
432
437
self . notificationCenter. sendNotifications ( type: NotificationType . Decision. rawValue, args: args)
433
438
@@ -531,8 +536,7 @@ open class OptimizelyManager: NSObject {
531
536
}
532
537
533
538
var decisionInfo = [ String: Any] ( )
534
- decisionInfo [ Constants . DecisionInfoKeys. sourceExperiment] = nil
535
- decisionInfo [ Constants . DecisionInfoKeys. sourceVariation] = nil
539
+ decisionInfo [ Constants . DecisionInfoKeys. sourceInfo] = [ : ]
536
540
537
541
// TODO: [Jae] optional? fallback to empty string is OK?
538
542
var featureValue = variable. defaultValue ?? " "
@@ -544,8 +548,10 @@ open class OptimizelyManager: NSObject {
544
548
let decision = self . decisionService. getVariationForFeature ( config: config, featureFlag: featureFlag, userId: userId, attributes: _attributes)
545
549
if let decision = decision {
546
550
if let experiment = decision. experiment {
547
- decisionInfo [ Constants . DecisionInfoKeys. sourceExperiment] = experiment. key
548
- decisionInfo [ Constants . DecisionInfoKeys. sourceVariation] = decision. variation? . key
551
+ var sourceInfo = [ String: Any] ( )
552
+ sourceInfo [ Constants . ExperimentDecisionInfoKeys. experiment] = experiment. key
553
+ sourceInfo [ Constants . ExperimentDecisionInfoKeys. variation] = decision. variation? . key
554
+ decisionInfo [ Constants . DecisionInfoKeys. sourceInfo] = sourceInfo
549
555
}
550
556
if let featureVariable = decision. variation? . variables? . filter ( { $0. id == variable. id} ) . first {
551
557
if let featureEnabled = decision. variation? . featureEnabled, featureEnabled {
@@ -589,7 +595,7 @@ open class OptimizelyManager: NSObject {
589
595
decisionInfo [ Constants . DecisionInfoKeys. variable] = variableKey
590
596
decisionInfo [ Constants . DecisionInfoKeys. variableType] = typeName
591
597
decisionInfo [ Constants . DecisionInfoKeys. variableValue] = value
592
- decisionInfo [ Constants . DecisionInfoKeys. source] = ( decision? . experiment != nil ? Constants . DecisionSource. Experiment : Constants . DecisionSource. Rollout)
598
+ decisionInfo [ Constants . DecisionInfoKeys. source] = ( decision? . experiment != nil ? Constants . DecisionSource. FeatureTest : Constants . DecisionSource. Rollout)
593
599
args. append ( decisionInfo)
594
600
595
601
self . notificationCenter. sendNotifications ( type: NotificationType . Decision. rawValue, args: args)
0 commit comments