Skip to content

Commit 32d0d99

Browse files
[FSSDK-9951] add multi thread warning (#345)
1 parent 1333d60 commit 32d0d99

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ You can initialize the Optimizely instance in two ways: directly with a datafile
7878
)
7979
```
8080

81+
**Note:** The SDK spawns multiple threads when initialized. These threads have infinite loops that are used for fetching the datafile, as well as batching and dispatching events in the background. When using in a web server that spawn multiple child processes, you need to initialize the SDK after those child processes or workers have been spawned.
82+
8183
#### HTTP Config Manager
8284

8385
The `HTTPConfigManager` asynchronously polls for datafiles from a specified URL at regular intervals by making HTTP requests.

lib/optimizely/event_builder.rb

+11-11
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,17 @@ def get_common_params(project_config, user_id, attributes)
6565
attributes&.each_key do |attribute_key|
6666
# Omit attribute values that are not supported by the log endpoint.
6767
attribute_value = attributes[attribute_key]
68-
if Helpers::Validator.attribute_valid?(attribute_key, attribute_value)
69-
attribute_id = project_config.get_attribute_id attribute_key
70-
if attribute_id
71-
visitor_attributes.push(
72-
entity_id: attribute_id,
73-
key: attribute_key,
74-
type: CUSTOM_ATTRIBUTE_FEATURE_TYPE,
75-
value: attribute_value
76-
)
77-
end
78-
end
68+
next unless Helpers::Validator.attribute_valid?(attribute_key, attribute_value)
69+
70+
attribute_id = project_config.get_attribute_id attribute_key
71+
next unless attribute_id
72+
73+
visitor_attributes.push(
74+
entity_id: attribute_id,
75+
key: attribute_key,
76+
type: CUSTOM_ATTRIBUTE_FEATURE_TYPE,
77+
value: attribute_value
78+
)
7979
end
8080
# Append Bot Filtering Attribute
8181
if project_config.bot_filtering == true || project_config.bot_filtering == false

0 commit comments

Comments
 (0)