@@ -39,20 +39,20 @@ class DefaultDecisionService: OPTDecisionService {
3939 return nil
4040 }
4141
42- // ---- check for whitelisted variation registered at runtime ----
42+ // ---- check if the user is forced into a variation ----
4343 if let variationId = config. getForcedVariation ( experimentKey: experiment. key, userId: userId) ? . id,
4444 let variation = experiment. getVariation ( id: variationId) {
4545 return variation
4646 }
4747
48- // ---- check if the experiment has forced variation ----
48+ // ---- check to see if user is white-listed for a certain variation ----
4949 if let variationKey = experiment. forcedVariations [ userId] {
5050 if let variation = experiment. getVariation ( key: variationKey) {
5151 logger. i ( . forcedVariationFound( variationKey, userId) )
5252 return variation
5353 }
5454
55- // mapped to invalid variation - ignore and continue for other deciesions
55+ // mapped to invalid variation - ignore and continue for other decisions
5656 logger. e ( . forcedVariationFoundButInvalid( variationKey, userId) )
5757 }
5858
@@ -65,22 +65,26 @@ class DefaultDecisionService: OPTDecisionService {
6565
6666 var bucketedVariation : Variation ?
6767 // ---- check if the user passes audience targeting before bucketing ----
68- if isInExperiment ( config: config, experiment: experiment, userId: userId, attributes: attributes) {
68+ if doesMeetAudienceConditions ( config: config, experiment: experiment, userId: userId, attributes: attributes) {
6969 // bucket user into a variation
7070 bucketedVariation = bucketer. bucketExperiment ( config: config, experiment: experiment, bucketingId: bucketingId)
7171
7272 if let bucketedVariation = bucketedVariation {
73+ logger. i ( . userBucketedIntoVariationInExperiment( userId, experiment. key, bucketedVariation. key) )
7374 // save to user profile
7475 self . saveProfile ( userId: userId, experimentId: experimentId, variationId: bucketedVariation. id)
76+ } else {
77+ logger. i ( . userNotBucketedIntoVariation( userId) )
7578 }
79+
7680 } else {
7781 logger. i ( . userNotInExperiment( userId, experiment. key) )
7882 }
7983
8084 return bucketedVariation
8185 }
8286
83- func isInExperiment ( config: ProjectConfig , experiment: Experiment , userId: String , attributes: OptimizelyAttributes , logType: Constants . EvaluationLogType = . experiment, loggingKey: String ? = nil ) -> Bool {
87+ func doesMeetAudienceConditions ( config: ProjectConfig , experiment: Experiment , userId: String , attributes: OptimizelyAttributes , logType: Constants . EvaluationLogType = . experiment, loggingKey: String ? = nil ) -> Bool {
8488
8589 var result = true // success as default (no condition, etc)
8690 let evType = logType. rawValue
@@ -133,19 +137,13 @@ class DefaultDecisionService: OPTDecisionService {
133137 //1. Attempt to bucket user into experiment using feature flag.
134138 // Check if the feature flag is under an experiment and the the user is bucketed into one of these experiments
135139 if let pair = getVariationForFeatureExperiment ( config: config, featureFlag: featureFlag, userId: userId, attributes: attributes) {
136- logger. d ( . userInFeatureExperiment( userId, pair. variation? . key ?? " unknown " , pair. experiment? . key ?? " unknown " , featureFlag. key) )
137140 return pair
138- } else {
139- logger. d ( . userNotInFeatureExperiment( userId, featureFlag. key) )
140141 }
141142
142143 //2. Attempt to bucket user into rollout using the feature flag.
143144 // Check if the feature flag has rollout and the user is bucketed into one of it's rules
144145 if let variation = getVariationForFeatureRollout ( config: config, featureFlag: featureFlag, userId: userId, attributes: attributes) {
145- logger. d ( . userInRollout( userId, featureFlag. key) )
146146 return ( nil , variation)
147- } else {
148- logger. d ( . userNotInRollout( userId, featureFlag. key) )
149147 }
150148
151149 return nil
@@ -202,7 +200,7 @@ class DefaultDecisionService: OPTDecisionService {
202200 for index in 0 ..< rolloutRules. count. advanced ( by: - 1 ) {
203201 let loggingKey = index + 1
204202 let experiment = rolloutRules [ index]
205- if isInExperiment ( config: config, experiment: experiment, userId: userId, attributes: attributes, logType: . rolloutRule, loggingKey: " \( loggingKey) " ) {
203+ if doesMeetAudienceConditions ( config: config, experiment: experiment, userId: userId, attributes: attributes, logType: . rolloutRule, loggingKey: " \( loggingKey) " ) {
206204 logger. d ( . userMeetsConditionsForTargetingRule( userId, loggingKey) )
207205 if let variation = bucketer. bucketExperiment ( config: config, experiment: experiment, bucketingId: bucketingId) {
208206 logger. d ( . userBucketedIntoTargetingRule( userId, loggingKey) )
@@ -217,7 +215,7 @@ class DefaultDecisionService: OPTDecisionService {
217215 // Evaluate fall back rule / last rule now
218216 let experiment = rolloutRules [ rolloutRules. count - 1 ]
219217
220- if isInExperiment ( config: config, experiment: experiment, userId: userId, attributes: attributes, logType: . rolloutRule, loggingKey: " Everyone Else " ) {
218+ if doesMeetAudienceConditions ( config: config, experiment: experiment, userId: userId, attributes: attributes, logType: . rolloutRule, loggingKey: " Everyone Else " ) {
221219 if let variation = bucketer. bucketExperiment ( config: config, experiment: experiment, bucketingId: bucketingId) {
222220 logger. d ( . userBucketedIntoEveryoneTargetingRule( userId) )
223221
0 commit comments