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