Skip to content

Commit be81979

Browse files
committed
[AI-FSSDK] [FSSDK-12262] Exclude CMAB from UserProfileService
1 parent 4829b04 commit be81979

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

lib/optimizely/decision_service.rb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,15 @@ def get_variation(project_config, experiment_id, user_context, user_profile_trac
9999
return VariationResult.new(nil, false, decide_reasons, whitelisted_variation_id) if whitelisted_variation_id
100100

101101
should_ignore_user_profile_service = decide_options.include? Optimizely::Decide::OptimizelyDecideOption::IGNORE_USER_PROFILE_SERVICE
102-
# Check for saved bucketing decisions if decide_options do not include ignoreUserProfileService
103-
unless should_ignore_user_profile_service && user_profile_tracker
102+
# CMAB experiments are excluded from UPS (sticky bucketing) because CMAB decisions
103+
# are dynamic and should not be persisted across the experiment lifetime.
104+
is_cmab_experiment = experiment.key?('cmab') && !experiment['cmab'].nil?
105+
if is_cmab_experiment
106+
message = "Skipping UPS lookup and save for CMAB experiment '#{experiment_key}'."
107+
@logger.log(Logger::INFO, message)
108+
decide_reasons.push(message)
109+
elsif !(should_ignore_user_profile_service && user_profile_tracker)
110+
# Check for saved bucketing decisions if decide_options do not include ignoreUserProfileService
104111
saved_variation_id, reasons_received = get_saved_variation_id(project_config, experiment_id, user_profile_tracker.user_profile)
105112
decide_reasons.push(*reasons_received)
106113
if saved_variation_id
@@ -155,7 +162,8 @@ def get_variation(project_config, experiment_id, user_context, user_profile_trac
155162
decide_reasons.push(message) if message
156163

157164
# Persist bucketing decision
158-
user_profile_tracker.update_user_profile(experiment_id, variation_id) unless should_ignore_user_profile_service && user_profile_tracker
165+
# Skip UPS save for CMAB experiments since their decisions are dynamic
166+
user_profile_tracker.update_user_profile(experiment_id, variation_id) unless (should_ignore_user_profile_service && user_profile_tracker) || is_cmab_experiment
159167
VariationResult.new(cmab_uuid, false, decide_reasons, variation_id)
160168
end
161169

0 commit comments

Comments
 (0)