Class: Optimizely::EventBuilderV1
- Inherits:
-
BaseEventBuilder
- Object
- BaseEventBuilder
- Optimizely::EventBuilderV1
- Defined in:
- lib/optimizely/event_builder.rb
Constant Summary collapse
- ATTRIBUTE_PARAM_FORMAT =
Attribute mapping format
'%{segment_prefix}%{segment_id}'- EXPERIMENT_PARAM_FORMAT =
Experiment mapping format
'%{experiment_prefix}%{experiment_id}'- OFFLINE_API_PATH =
Event endpoint path
'https://%{project_id}.log.optimizely.com/event'
Instance Attribute Summary
Attributes inherited from BaseEventBuilder
Instance Method Summary collapse
- #create_conversion_event(event_key, user_id, attributes, event_value, experiment_keys) ⇒ Object
- #create_impression_event(experiment_key, variation_id, user_id, attributes) ⇒ Object
Methods inherited from BaseEventBuilder
Constructor Details
This class inherits a constructor from Optimizely::BaseEventBuilder
Instance Method Details
#create_conversion_event(event_key, user_id, attributes, event_value, experiment_keys) ⇒ Object
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/optimizely/event_builder.rb', line 229 def create_conversion_event(event_key, user_id, attributes, event_value, experiment_keys) # Create conversion Event to be sent to the logging endpoint. # # event_key - Goal key representing the event which needs to be recorded. # user_id - ID for user. # attributes - Hash representing user attributes and values which need to be recorded. # event_value - Value associated with the event. Can be used to represent revenue in cents. # experiment_keys - Array of valid experiment keys for the goal # # Returns event hash encapsulating the conversion event. @params = {} add_common_params(user_id, attributes) add_conversion_goal(event_key, event_value) add_experiment_variation_params(user_id, experiment_keys) Event.new(:get, sprintf(OFFLINE_API_PATH, project_id: @params[Params::PROJECT_ID]), @params, {}) end |
#create_impression_event(experiment_key, variation_id, user_id, attributes) ⇒ Object
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/optimizely/event_builder.rb', line 212 def create_impression_event(experiment_key, variation_id, user_id, attributes) # Create conversion Event to be sent to the logging endpoint. # # experiment_key - Experiment for which impression needs to be recorded. # variation_id - ID for variation which would be presented to user. # user_id - ID for user. # attributes - Hash representing user attributes and values which need to be recorded. # # Returns event hash encapsulating the impression event. @params = {} add_common_params(user_id, attributes) add_impression_goal(experiment_key) add_experiment(experiment_key, variation_id) Event.new(:get, sprintf(OFFLINE_API_PATH, project_id: @params[Params::PROJECT_ID]), @params, {}) end |