class Optimizely::BaseEventBuilder
Constants
- CUSTOM_ATTRIBUTE_FEATURE_TYPE
Public Class Methods
new(logger)
click to toggle source
# File lib/optimizely/event_builder.rb, line 51 def initialize(logger) @logger = logger end
Private Instance Methods
get_common_params(project_config, user_id, attributes)
click to toggle source
# File lib/optimizely/event_builder.rb, line 57 def get_common_params(project_config, user_id, attributes) # Get params which are used in both conversion and impression events. # # project_config - +Object+ Instance of ProjectConfig # user_id - +String+ ID for user # attributes - +Hash+ representing user attributes and values which need to be recorded. # # Returns +Hash+ Common event params visitor_attributes = [] attributes&.keys&.each do |attribute_key| # Omit attribute values that are not supported by the log endpoint. attribute_value = attributes[attribute_key] if Helpers::Validator.attribute_valid?(attribute_key, attribute_value) attribute_id = project_config.get_attribute_id attribute_key if attribute_id visitor_attributes.push( entity_id: attribute_id, key: attribute_key, type: CUSTOM_ATTRIBUTE_FEATURE_TYPE, value: attribute_value ) end end end # Append Bot Filtering Attribute if project_config.bot_filtering == true || project_config.bot_filtering == false visitor_attributes.push( entity_id: Optimizely::Helpers::Constants::CONTROL_ATTRIBUTES['BOT_FILTERING'], key: Optimizely::Helpers::Constants::CONTROL_ATTRIBUTES['BOT_FILTERING'], type: CUSTOM_ATTRIBUTE_FEATURE_TYPE, value: project_config.bot_filtering ) end common_params = { account_id: project_config.account_id, project_id: project_config.project_id, visitors: [ { attributes: visitor_attributes, snapshots: [], visitor_id: user_id } ], anonymize_ip: project_config.anonymize_ip, revision: project_config.revision, client_name: CLIENT_ENGINE, enrich_decisions: true, client_version: VERSION } common_params end