diff --git a/README.md b/README.md index a9899291..be5e0613 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,8 @@ You can initialize the Optimizely instance in two ways: directly with a datafile ) ``` +**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. + #### HTTP Config Manager The `HTTPConfigManager` asynchronously polls for datafiles from a specified URL at regular intervals by making HTTP requests. diff --git a/lib/optimizely/event_builder.rb b/lib/optimizely/event_builder.rb index 7b1ba51d..9b4ccd1b 100644 --- a/lib/optimizely/event_builder.rb +++ b/lib/optimizely/event_builder.rb @@ -65,17 +65,17 @@ def get_common_params(project_config, user_id, attributes) attributes&.each_key do |attribute_key| # Omit attribute values that are not supported by the log endpoint. attribute_value = attributes[attribute_key] - if Helpers::Validator.attribute_valid?(attribute_key, attribute_value) - attribute_id = project_config.get_attribute_id attribute_key - if attribute_id - visitor_attributes.push( - entity_id: attribute_id, - key: attribute_key, - type: CUSTOM_ATTRIBUTE_FEATURE_TYPE, - value: attribute_value - ) - end - end + next unless Helpers::Validator.attribute_valid?(attribute_key, attribute_value) + + attribute_id = project_config.get_attribute_id attribute_key + next unless attribute_id + + visitor_attributes.push( + entity_id: attribute_id, + key: attribute_key, + type: CUSTOM_ATTRIBUTE_FEATURE_TYPE, + value: attribute_value + ) end # Append Bot Filtering Attribute if project_config.bot_filtering == true || project_config.bot_filtering == false