Sha256: 6a86fbba60c83d39e67763b45d22ee4499c0c51a02206eb009d33b7ee17190f1
Contents?: true
Size: 1.37 KB
Versions: 11
Compression:
Stored size: 1.37 KB
Contents
# frozen_string_literal: true module OptimizelyServerSide module Support # Enables for us to wrap experiments # Usage: # experiment('sign_up_test') do |config| # # config.variation_one('variation_one_key') do # # Code related to variation one # end # # config.variation_two('variation_two_key') do # # Code related to variation two # end # # config.variation_default('variation_default_key', primary: true) do # # We still want to keep our default experience # end # # end def experiment(experiment_key, options = {}, &blk) # Merge any other options to user attributes OptimizelyServerSide.configuration.user_attributes.merge!(options.stringify_keys) variation_key = optimizely_sdk_project_instance(experiment_key) OptimizelyServerSide::Experiment.new(experiment_key, variation_key).start(&blk) end alias_method :feature_flip, :experiment def optimizely_sdk_project_instance(experiment_key) OptimizelyServerSide::OptimizelySdk .project_instance(event_dispatcher: OptimizelyServerSide.configuration.event_dispatcher) .activate(experiment_key, OptimizelyServerSide.configuration.user_attributes['visitor_id'], OptimizelyServerSide.configuration.user_attributes.reject { |k,v| k == 'visitor_id'}) end end end
Version data entries
11 entries across 11 versions & 1 rubygems