Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions lib/optimizely/decision_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,15 @@ def get_variation(project_config, experiment_id, user_context, user_profile_trac
return VariationResult.new(nil, false, decide_reasons, whitelisted_variation_id) if whitelisted_variation_id

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

# Persist bucketing decision
user_profile_tracker.update_user_profile(experiment_id, variation_id) unless should_ignore_user_profile_service && user_profile_tracker
# Skip UPS save for CMAB experiments since their decisions are dynamic
user_profile_tracker.update_user_profile(experiment_id, variation_id) unless (should_ignore_user_profile_service && user_profile_tracker) || is_cmab_experiment
VariationResult.new(cmab_uuid, false, decide_reasons, variation_id)
end

Expand Down
Loading