vwo-sdk 1.36.0 → 1.37.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vwo/constants.rb +2 -2
- data/lib/vwo/core/bucketer.rb +18 -26
- data/lib/vwo/core/variation_decider.rb +216 -220
- data/lib/vwo/enums.rb +16 -19
- data/lib/vwo/logger.rb +2 -3
- data/lib/vwo/schemas/settings_file.rb +6 -6
- data/lib/vwo/services/batch_events_dispatcher.rb +19 -21
- data/lib/vwo/services/batch_events_queue.rb +27 -43
- data/lib/vwo/services/event_dispatcher.rb +31 -21
- data/lib/vwo/services/hooks_manager.rb +8 -12
- data/lib/vwo/services/segment_evaluator.rb +7 -6
- data/lib/vwo/services/settings_file_manager.rb +5 -5
- data/lib/vwo/services/settings_file_processor.rb +1 -1
- data/lib/vwo/services/usage_stats.rb +5 -4
- data/lib/vwo/utils/campaign.rb +37 -39
- data/lib/vwo/utils/custom_dimensions.rb +2 -2
- data/lib/vwo/utils/data_location_manager.rb +2 -9
- data/lib/vwo/utils/feature.rb +2 -2
- data/lib/vwo/utils/impression.rb +29 -37
- data/lib/vwo/utils/log_message.rb +23 -30
- data/lib/vwo/utils/request.rb +7 -9
- data/lib/vwo/utils/utility.rb +44 -34
- data/lib/vwo/utils/validations.rb +72 -5
- data/lib/vwo.rb +197 -344
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea72e150de33227c3e911fd61478a8815fb8f42f788df4a65a6751a1da7c25fb
|
4
|
+
data.tar.gz: c88b275817a6ef0ca80efc03287e57fd1488be9390e7a028a4dc812cca93abc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 294fab2cbb559b6869e547dd0f55b9bb5ac54910ba61d497f9d205fd37c405bc206b6264912bc0600306dd0986d875c034be0e4342260f3d0aa8a647ad0a67e3
|
7
|
+
data.tar.gz: d25b2e2642a1e178eeeba2b0f7f7e82188040df6116a6a14bb13abfba7cf8e0b2ee28c5161936cc9773663f55cdca9d371b72deea94393ac1c9d6a20cf9f383b
|
data/lib/vwo/constants.rb
CHANGED
@@ -19,7 +19,7 @@ class VWO
|
|
19
19
|
SEED_VALUE = 1
|
20
20
|
MAX_TRAFFIC_PERCENT = 100
|
21
21
|
MAX_TRAFFIC_VALUE = 10_000
|
22
|
-
MAX_RANGE =
|
22
|
+
MAX_RANGE = 10_000
|
23
23
|
STATUS_RUNNING = 'RUNNING'
|
24
24
|
# rubocop:disable Style/ExpandPathArguments
|
25
25
|
LIBRARY_PATH = File.expand_path('../..', __FILE__)
|
@@ -27,7 +27,7 @@ class VWO
|
|
27
27
|
HTTP_PROTOCOL = 'http://'
|
28
28
|
HTTPS_PROTOCOL = 'https://'
|
29
29
|
URL_NAMESPACE = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'
|
30
|
-
SDK_VERSION = '1.
|
30
|
+
SDK_VERSION = '1.37.1'
|
31
31
|
SDK_NAME = 'ruby'
|
32
32
|
VWO_DELIMITER = '_vwo_'
|
33
33
|
MAX_EVENTS_PER_REQUEST = 5000
|
data/lib/vwo/core/bucketer.rb
CHANGED
@@ -31,7 +31,7 @@ class VWO
|
|
31
31
|
# Source - https://stackoverflow.com/a/20766900/2494535
|
32
32
|
U_MAX_32_BIT = 0xFFFFFFFF
|
33
33
|
MAX_HASH_VALUE = 2**32
|
34
|
-
FILE = FileNameEnum::
|
34
|
+
FILE = FileNameEnum::BUCKETER
|
35
35
|
|
36
36
|
def initialize
|
37
37
|
@logger = VWO::Utils::Logger
|
@@ -49,16 +49,14 @@ class VWO
|
|
49
49
|
LogLevelEnum::ERROR,
|
50
50
|
'USER_ID_INVALID',
|
51
51
|
{
|
52
|
-
|
53
|
-
|
52
|
+
'{file}' => FILE,
|
53
|
+
'{userId}' => user_id
|
54
54
|
}
|
55
55
|
)
|
56
56
|
return false
|
57
57
|
end
|
58
58
|
|
59
|
-
if campaign.nil?
|
60
|
-
return false
|
61
|
-
end
|
59
|
+
return false if campaign.nil?
|
62
60
|
|
63
61
|
traffic_allocation = campaign['percentTraffic']
|
64
62
|
value_assigned_to_user = get_bucket_value_for_user(user_id, campaign, nil, disable_logs)
|
@@ -92,21 +90,17 @@ class VWO
|
|
92
90
|
LogLevelEnum::ERROR,
|
93
91
|
'USER_ID_INVALID',
|
94
92
|
{
|
95
|
-
|
96
|
-
|
93
|
+
'{file}' => FILE,
|
94
|
+
'{userId}' => user_id
|
97
95
|
}
|
98
96
|
)
|
99
97
|
return
|
100
98
|
end
|
101
99
|
|
102
|
-
unless campaign
|
103
|
-
return
|
104
|
-
end
|
100
|
+
return unless campaign
|
105
101
|
|
106
102
|
user_id_for_hash_value = user_id
|
107
|
-
if campaign['isBucketingSeedEnabled']
|
108
|
-
user_id_for_hash_value = campaign['id'].to_s + "_" + user_id
|
109
|
-
end
|
103
|
+
user_id_for_hash_value = "#{campaign['id']}_#{user_id}" if campaign['isBucketingSeedEnabled']
|
110
104
|
hash_value = MurmurHash3::V32.str_hash(user_id_for_hash_value, SEED_VALUE) & U_MAX_32_BIT
|
111
105
|
normalize = MAX_TRAFFIC_VALUE.to_f / campaign['percentTraffic']
|
112
106
|
multiplier = normalize / 100
|
@@ -120,12 +114,12 @@ class VWO
|
|
120
114
|
LogLevelEnum::DEBUG,
|
121
115
|
'USER_CAMPAIGN_BUCKET_VALUES',
|
122
116
|
{
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
117
|
+
'{file}' => FILE,
|
118
|
+
'{campaignKey}' => campaign['key'],
|
119
|
+
'{userId}' => user_id,
|
120
|
+
'{percentTraffic}' => campaign['percentTraffic'],
|
121
|
+
'{hashValue}' => hash_value,
|
122
|
+
'{bucketValue}' => bucket_value
|
129
123
|
},
|
130
124
|
disable_logs
|
131
125
|
)
|
@@ -156,9 +150,9 @@ class VWO
|
|
156
150
|
def get_bucket_value_for_user(user_id, campaign = {}, group_id = nil, disable_logs = false)
|
157
151
|
user_id_for_hash_value = user_id
|
158
152
|
if group_id
|
159
|
-
user_id_for_hash_value = group_id
|
153
|
+
user_id_for_hash_value = "#{group_id}_#{user_id}"
|
160
154
|
elsif campaign['isBucketingSeedEnabled']
|
161
|
-
user_id_for_hash_value = campaign['id']
|
155
|
+
user_id_for_hash_value = "#{campaign['id']}_#{user_id}"
|
162
156
|
end
|
163
157
|
hash_value = MurmurHash3::V32.str_hash(user_id_for_hash_value, SEED_VALUE) & U_MAX_32_BIT
|
164
158
|
bucket_value = get_bucket_value(hash_value, MAX_TRAFFIC_PERCENT)
|
@@ -198,11 +192,9 @@ class VWO
|
|
198
192
|
# @return[Hash|nil]
|
199
193
|
#
|
200
194
|
def get_campaign_using_range(range_for_campaigns, campaigns)
|
201
|
-
range_for_campaigns
|
195
|
+
range_for_campaigns *= 100
|
202
196
|
campaigns.each do |campaign|
|
203
|
-
if campaign[
|
204
|
-
return campaign
|
205
|
-
end
|
197
|
+
return campaign if campaign['max_range'] && campaign['max_range'] >= range_for_campaigns && campaign['min_range'] <= range_for_campaigns
|
206
198
|
end
|
207
199
|
nil
|
208
200
|
end
|