-
Notifications
You must be signed in to change notification settings - Fork 28
[FSSDK-11459] Ruby - Add SDK Multi-Region Support for Data Hosting #365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 19 commits
0165dee
73769f1
f9156d0
a5e6faf
9f47706
e776ead
884c972
6d0245e
e1ae8b5
c8a47b1
93e7a11
06295e6
04e3a7e
474d01d
ae26ced
80d0c16
fd72f77
4dea3ec
904d0bd
7f98564
56bc8cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -101,13 +101,17 @@ def get_common_params(project_config, user_id, attributes) | |||||
revision: project_config.revision, | ||||||
client_name: CLIENT_ENGINE, | ||||||
enrich_decisions: true, | ||||||
client_version: VERSION | ||||||
client_version: VERSION, | ||||||
region: project_config.region || 'US' | ||||||
} | ||||||
end | ||||||
end | ||||||
|
||||||
class EventBuilder < BaseEventBuilder | ||||||
ENDPOINT = 'https://logx.optimizely.com/v1/events' | ||||||
ENDPOINTS = { | ||||||
US: 'https://logx.optimizely.com/v1/events', | ||||||
EU: 'https://eu.logx.optimizely.com/v1/events' | ||||||
}.freeze | ||||||
POST_HEADERS = {'Content-Type' => 'application/json'}.freeze | ||||||
ACTIVATE_EVENT_KEY = 'campaign_activated' | ||||||
|
||||||
|
@@ -122,11 +126,14 @@ def create_impression_event(project_config, experiment, variation_id, user_id, a | |||||
# | ||||||
# Returns +Event+ encapsulating the impression event. | ||||||
|
||||||
region = project_config.region || 'US' | ||||||
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) | ||||||
endpoint = ENDPOINTS[region.to_sym] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Converting
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
|
||||||
Event.new(:post, endpoint, event_params, POST_HEADERS) | ||||||
end | ||||||
|
||||||
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 | |||||
# | ||||||
# Returns +Event+ encapsulating the conversion event. | ||||||
|
||||||
region = project_config.region || 'US' | ||||||
event_params = get_common_params(project_config, user_id, attributes) | ||||||
conversion_params = get_conversion_params(event, event_tags) | ||||||
event_params[:visitors][0][:snapshots] = [conversion_params] | ||||||
|
||||||
Event.new(:post, ENDPOINT, event_params, POST_HEADERS) | ||||||
endpoint = ENDPOINTS[region.to_sym] | ||||||
|
||||||
Event.new(:post, endpoint, event_params, POST_HEADERS) | ||||||
end | ||||||
|
||||||
private | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,8 @@ def host_for_odp; end | |
|
||
def all_segments; end | ||
|
||
def region; end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
|
||
def experiment_running?(experiment); end | ||
|
||
def get_experiment_from_key(experiment_key); end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Symbolizing
user_context[:region]
as-is can miss the intended key if the casing differs. Consider normalizing withuser_context[:region].to_s.upcase.to_sym
.Copilot uses AI. Check for mistakes.