vwo-sdk 1.35.0 → 1.38.0
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 +213 -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: a0e08961757aa3ab300766b7c2fd27429d0c3edb97c8e2609d3b41fb8e9b3362
|
4
|
+
data.tar.gz: dda836f16065c27aed8102c2e7f666b47645c20fe38c9830c02f0c9c1a32b959
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd96894eaf16020bddfc7246ee287ae7dbaaa9df40e9dc17ec09b0af31379a05a6d1b682665599f4f45d495ceecd5c66409cb753c7f4e59dd72d25e9037e3ef2
|
7
|
+
data.tar.gz: 56a9930a525ed16aab574920cffe787da6b2ecf8225d0a8bf03edea1ab67b331e433537da35af6b70715787c61abc132e9b04b032da1950a0bc39af085c9fce2
|
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.38.0'
|
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
|