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 Method Summary collapse
- #create_conversion_event(project_config, event, user_id, attributes, event_tags) ⇒ Object
- #create_impression_event(project_config, 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(project_config, event, user_id, attributes, event_tags) ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/optimizely/event_builder.rb', line 132 def create_conversion_event(project_config, event, user_id, attributes, ) # Create conversion Event to be sent to the logging endpoint. # # project_config - +Object+ Instance of ProjectConfig # event - +Object+ 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. # # Returns +Event+ encapsulating the conversion event. event_params = get_common_params(project_config, user_id, attributes) conversion_params = get_conversion_params(event, ) event_params[:visitors][0][:snapshots] = [conversion_params] Event.new(:post, ENDPOINT, event_params, POST_HEADERS) end |
#create_impression_event(project_config, experiment, variation_id, user_id, attributes) ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/optimizely/event_builder.rb', line 114 def create_impression_event(project_config, experiment, variation_id, user_id, attributes) # Create impression Event to be sent to the logging endpoint. # # project_config - +Object+ Instance of ProjectConfig # 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(project_config, user_id, attributes) impression_params = get_impression_params(project_config, experiment, variation_id) event_params[:visitors][0][:snapshots].push(impression_params) Event.new(:post, ENDPOINT, event_params, POST_HEADERS) end |