22
22
require 'securerandom'
23
23
24
24
module Optimizely
25
- RESERVED_ATTRIBUTE_KEY_BUCKETING_ID_EVENT_PARAM_KEY = 'optimizely_bucketing_id'
26
-
27
25
class Event
28
26
# Representation of an event which can be sent to the Optimizely logging endpoint.
29
27
@@ -58,6 +56,13 @@ def initialize(config, logger)
58
56
59
57
private
60
58
59
+ def bot_filtering
60
+ # Get bot filtering bool
61
+ #
62
+ # Returns 'botFiltering' value in the datafile.
63
+ @config . bot_filtering
64
+ end
65
+
61
66
def get_common_params ( user_id , attributes )
62
67
# Get params which are used in both conversion and impression events.
63
68
#
@@ -69,33 +74,28 @@ def get_common_params(user_id, attributes)
69
74
visitor_attributes = [ ]
70
75
71
76
attributes &.keys &.each do |attribute_key |
72
- # Omit null attribute value
77
+ # Omit null attribute values
73
78
attribute_value = attributes [ attribute_key ]
74
- next if attribute_value . nil?
75
-
76
- if attribute_key . eql? RESERVED_ATTRIBUTE_KEY_BUCKETING_ID
77
- # TODO: (Copied from PHP-SDK) (Alda): the type for bucketing ID attribute may change so
78
- # that custom attributes are not overloaded
79
- feature = {
80
- entity_id : RESERVED_ATTRIBUTE_KEY_BUCKETING_ID ,
81
- key : RESERVED_ATTRIBUTE_KEY_BUCKETING_ID_EVENT_PARAM_KEY ,
82
- type : CUSTOM_ATTRIBUTE_FEATURE_TYPE ,
83
- value : attribute_value
84
- }
85
- else
86
- # Skip attributes not in the datafile
87
- attribute_id = @config . get_attribute_id ( attribute_key )
88
- next unless attribute_id
89
-
90
- feature = {
91
- entity_id : attribute_id ,
92
- key : attribute_key ,
93
- type : CUSTOM_ATTRIBUTE_FEATURE_TYPE ,
94
- value : attribute_value
95
- }
96
-
79
+ unless attribute_value . nil?
80
+ attribute_id = @config . get_attribute_id attribute_key
81
+ if attribute_id
82
+ visitor_attributes . push (
83
+ entity_id : attribute_id ,
84
+ key : attribute_key ,
85
+ type : CUSTOM_ATTRIBUTE_FEATURE_TYPE ,
86
+ value : attribute_value
87
+ )
88
+ end
97
89
end
98
- visitor_attributes . push ( feature )
90
+ end
91
+ # Append Bot Filtering Attribute
92
+ if bot_filtering == true || bot_filtering == false
93
+ visitor_attributes . push (
94
+ entity_id : Optimizely ::Helpers ::Constants ::CONTROL_ATTRIBUTES [ 'BOT_FILTERING' ] ,
95
+ key : Optimizely ::Helpers ::Constants ::CONTROL_ATTRIBUTES [ 'BOT_FILTERING' ] ,
96
+ type : CUSTOM_ATTRIBUTE_FEATURE_TYPE ,
97
+ value : bot_filtering
98
+ )
99
99
end
100
100
101
101
common_params = {
0 commit comments