@@ -101,13 +101,17 @@ def get_common_params(project_config, user_id, attributes)
101101 revision : project_config . revision ,
102102 client_name : CLIENT_ENGINE ,
103103 enrich_decisions : true ,
104- client_version : VERSION
104+ client_version : VERSION ,
105+ region : project_config . region || 'US'
105106 }
106107 end
107108 end
108109
109110 class EventBuilder < BaseEventBuilder
110- ENDPOINT = 'https://logx.optimizely.com/v1/events'
111+ ENDPOINTS = {
112+ US : 'https://logx.optimizely.com/v1/events' ,
113+ EU : 'https://eu.logx.optimizely.com/v1/events'
114+ } . freeze
111115 POST_HEADERS = { 'Content-Type' => 'application/json' } . freeze
112116 ACTIVATE_EVENT_KEY = 'campaign_activated'
113117
@@ -122,11 +126,14 @@ def create_impression_event(project_config, experiment, variation_id, user_id, a
122126 #
123127 # Returns +Event+ encapsulating the impression event.
124128
129+ region = project_config . region || 'US'
125130 event_params = get_common_params ( project_config , user_id , attributes )
126131 impression_params = get_impression_params ( project_config , experiment , variation_id )
127132 event_params [ :visitors ] [ 0 ] [ :snapshots ] . push ( impression_params )
128133
129- Event . new ( :post , ENDPOINT , event_params , POST_HEADERS )
134+ endpoint = ENDPOINTS [ region . to_s . upcase . to_sym ]
135+
136+ Event . new ( :post , endpoint , event_params , POST_HEADERS )
130137 end
131138
132139 def create_conversion_event ( project_config , event , user_id , attributes , event_tags )
@@ -140,11 +147,14 @@ def create_conversion_event(project_config, event, user_id, attributes, event_ta
140147 #
141148 # Returns +Event+ encapsulating the conversion event.
142149
150+ region = project_config . region || 'US'
143151 event_params = get_common_params ( project_config , user_id , attributes )
144152 conversion_params = get_conversion_params ( event , event_tags )
145153 event_params [ :visitors ] [ 0 ] [ :snapshots ] = [ conversion_params ]
146154
147- Event . new ( :post , ENDPOINT , event_params , POST_HEADERS )
155+ endpoint = ENDPOINTS [ region . to_s . upcase . to_sym ]
156+
157+ Event . new ( :post , endpoint , event_params , POST_HEADERS )
148158 end
149159
150160 private
0 commit comments