Class: Optimizely::EventBuilder
- Inherits:
-
BaseEventBuilder
- Object
- BaseEventBuilder
- Optimizely::EventBuilder
- Defined in:
- lib/optimizely/event_builder.rb
Constant Summary collapse
- ENDPOINT =
'https://logx.optimizely.com/v1/events'
- POST_HEADERS =
{'Content-Type' => 'application/json'}.freeze
- ACTIVATE_EVENT_KEY =
'campaign_activated'
Constants inherited from BaseEventBuilder
BaseEventBuilder::CUSTOM_ATTRIBUTE_FEATURE_TYPE
Instance Attribute Summary
Attributes inherited from BaseEventBuilder
Instance Method Summary collapse
- #create_conversion_event(event_key, user_id, attributes, event_tags, experiment_variation_map) ⇒ Object
- #create_impression_event(experiment, 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_tags, experiment_variation_map) ⇒ Object
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/optimizely/event_builder.rb', line 143 def create_conversion_event(event_key, user_id, attributes, , experiment_variation_map) # Create conversion Event to be sent to the logging endpoint. # # event_key - +String+ Event key representing the event which needs to be recorded. # user_id - +String+ ID for user. # attributes - +Hash+ representing user attributes and values which need to be recorded. # event_tags - +Hash+ representing metadata associated with the event. # experiment_variation_map - +Map+ of experiment ID to the ID of the variation that the user is bucketed into. # # Returns +Event+ encapsulating the conversion event. event_params = get_common_params(user_id, attributes) conversion_params = get_conversion_params(event_key, , experiment_variation_map) event_params[:visitors][0][:snapshots] = conversion_params Event.new(:post, ENDPOINT, event_params, POST_HEADERS) end |
#create_impression_event(experiment, variation_id, user_id, attributes) ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/optimizely/event_builder.rb', line 126 def create_impression_event(experiment, variation_id, user_id, attributes) # Create impression Event to be sent to the logging endpoint. # # experiment - +Object+ Experiment for which impression needs to be recorded. # variation_id - +String+ ID for variation which would be presented to user. # user_id - +String+ ID for user. # attributes - +Hash+ representing user attributes and values which need to be recorded. # # Returns +Event+ encapsulating the impression event. event_params = get_common_params(user_id, attributes) impression_params = get_impression_params(experiment, variation_id) event_params[:visitors][0][:snapshots].push(impression_params) Event.new(:post, ENDPOINT, event_params, POST_HEADERS) end |