@@ -111,8 +111,8 @@ class DefaultDecisionService: OPTDecisionService {
111111 }
112112
113113 /// Load variation from tracker
114- if let _userId = userProfileTracker? . userId ,
115- let variationId = getVariationIdFromProfile ( userId : _userId , experimentId: experimentId) ,
114+ if let profile = userProfileTracker? . userProfile ,
115+ let variationId = getVariationIdFromProfile ( profile : profile , experimentId: experimentId) ,
116116 let variation = experiment. getVariation ( id: variationId) {
117117
118118 let info = LogMessage . gotVariationFromUserProfile ( variation. key, experiment. key, userId)
@@ -226,35 +226,6 @@ class DefaultDecisionService: OPTDecisionService {
226226 }
227227
228228 return response!
229-
230-
231-
232- // // Evaluate in this order:
233- //
234- // // 1. Attempt to bucket user into experiment using feature flag.
235- // // Check if the feature flag is under an experiment and the the user is bucketed into one of these experiments
236- // var decisionResponse = getVariationForFeatureExperiment(config: config,
237- // featureFlag: featureFlag,
238- // user: user,
239- // userProfileTracker: nil,
240- // options: options)
241- // reasons.merge(decisionResponse.reasons)
242- // if let decision = decisionResponse.result {
243- // return DecisionResponse(result: decision, reasons: reasons)
244- // }
245- //
246- // // 2. Attempt to bucket user into rollout using the feature flag.
247- // // Check if the feature flag has rollout and the user is bucketed into one of it's rules
248- // decisionResponse = getVariationForFeatureRollout(config: config,
249- // featureFlag: featureFlag,
250- // user: user,
251- // options: options)
252- // reasons.merge(decisionResponse.reasons)
253- // if let decision = decisionResponse.result {
254- // return DecisionResponse(result: decision, reasons: reasons)
255- // }
256- //
257- // return DecisionResponse(result: nil, reasons: reasons)
258229 }
259230
260231 func getVariationForFeatureList( config: ProjectConfig ,
@@ -544,6 +515,18 @@ extension DefaultDecisionService {
544515 }
545516 }
546517
518+ func getVariationIdFromProfile( profile: UserProfile ? ,
519+ experimentId: String ) -> String ? {
520+ if let _profile = profile,
521+ let bucketMap = _profile [ UserProfileKeys . kBucketMap] as? OPTUserProfileService . UPBucketMap ,
522+ let experimentMap = bucketMap [ experimentId] ,
523+ let variationId = experimentMap [ UserProfileKeys . kVariationId] {
524+ return variationId
525+ } else {
526+ return nil
527+ }
528+ }
529+
547530 func saveProfile( userId: String ,
548531 experimentId: String ,
549532 variationId: String ) {
0 commit comments