vwo-sdk 1.14.1 → 1.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/vwo/constants.rb +5 -2
- data/lib/vwo/core/bucketer.rb +33 -5
- data/lib/vwo/core/variation_decider.rb +422 -133
- data/lib/vwo/enums.rb +6 -1
- data/lib/vwo/logger.rb +4 -2
- data/lib/vwo/schemas/settings_file.rb +32 -1
- data/lib/vwo/services/operand_evaluator.rb +2 -3
- data/lib/vwo/services/segment_evaluator.rb +4 -2
- data/lib/vwo/utils/campaign.rb +60 -2
- data/lib/vwo/utils/feature.rb +2 -0
- data/lib/vwo/utils/utility.rb +40 -0
- data/lib/vwo.rb +204 -190
- metadata +15 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a74040a37074e3fb8ffc75990383654fec552c7007414409ad6563de6173fe9
|
4
|
+
data.tar.gz: bac8b215309d14868f7cc8022f9d8afe1924d0ad22df3ed0919e136d8025c8cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 985e03d85f42c33db7c65580abce890127707b11e479a001a372d75ed779aad2d8010edcf2cc2e3dccb8fef39d02be3a165300465beef0e82851ce221985ef5f
|
7
|
+
data.tar.gz: d90e9528ba974d9e9a29bb7ee4f2d3b3fcb56e14edb15f62b0aaa45e2c2353c94723084c667785de871a8b43bb5d105747d4413683e097c44dd9f7e68e4d6a55
|
data/lib/vwo/constants.rb
CHANGED
@@ -19,6 +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 = 10000
|
22
23
|
STATUS_RUNNING = 'RUNNING'
|
23
24
|
# rubocop:disable Style/ExpandPathArguments
|
24
25
|
LIBRARY_PATH = File.expand_path('../..', __FILE__)
|
@@ -26,7 +27,7 @@ class VWO
|
|
26
27
|
HTTP_PROTOCOL = 'http://'
|
27
28
|
HTTPS_PROTOCOL = 'https://'
|
28
29
|
URL_NAMESPACE = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'
|
29
|
-
SDK_VERSION = '1.
|
30
|
+
SDK_VERSION = '1.23.0'
|
30
31
|
SDK_NAME = 'ruby'
|
31
32
|
VWO_DELIMITER = '_vwo_'
|
32
33
|
MAX_EVENTS_PER_REQUEST = 5000
|
@@ -68,6 +69,7 @@ class VWO
|
|
68
69
|
INTEGER = 'integer'
|
69
70
|
DOUBLE = 'double'
|
70
71
|
BOOLEAN = 'boolean'
|
72
|
+
JSON = 'json'
|
71
73
|
end
|
72
74
|
|
73
75
|
module Hooks
|
@@ -80,7 +82,8 @@ class VWO
|
|
80
82
|
'string' => [String],
|
81
83
|
'integer' => [Integer],
|
82
84
|
'double' => [Float],
|
83
|
-
'boolean' => [TrueClass, FalseClass]
|
85
|
+
'boolean' => [TrueClass, FalseClass],
|
86
|
+
'json' => [Hash]
|
84
87
|
}
|
85
88
|
|
86
89
|
GOAL_TYPES = {
|
data/lib/vwo/core/bucketer.rb
CHANGED
@@ -60,7 +60,7 @@ class VWO
|
|
60
60
|
end
|
61
61
|
|
62
62
|
traffic_allocation = campaign['percentTraffic']
|
63
|
-
value_assigned_to_user = get_bucket_value_for_user(user_id)
|
63
|
+
value_assigned_to_user = get_bucket_value_for_user(user_id, campaign)
|
64
64
|
is_user_part = (value_assigned_to_user != 0) && value_assigned_to_user <= traffic_allocation
|
65
65
|
@logger.log(
|
66
66
|
LogLevelEnum::INFO,
|
@@ -94,7 +94,11 @@ class VWO
|
|
94
94
|
return
|
95
95
|
end
|
96
96
|
|
97
|
-
|
97
|
+
user_id_for_hash_value = user_id
|
98
|
+
if campaign[:isBucketingSeedEnabled]
|
99
|
+
user_id_for_hash_value = campaign[:id].to_s + "_" + user_id
|
100
|
+
end
|
101
|
+
hash_value = MurmurHash3::V32.str_hash(user_id_for_hash_value, SEED_VALUE) & U_MAX_32_BIT
|
98
102
|
normalize = MAX_TRAFFIC_VALUE.to_f / campaign['percentTraffic']
|
99
103
|
multiplier = normalize / 100
|
100
104
|
bucket_value = get_bucket_value(
|
@@ -136,10 +140,17 @@ class VWO
|
|
136
140
|
# User by hashing the userId by murmurHash and scaling it down.
|
137
141
|
#
|
138
142
|
# @param[String] :user_id The unique ID assigned to User
|
143
|
+
# @param[String] :campaign Campaign data
|
139
144
|
# @return[Integer] The bucket Value allotted to User
|
140
145
|
# (between 1 to $this->$MAX_TRAFFIC_PERCENT)
|
141
|
-
def get_bucket_value_for_user(user_id)
|
142
|
-
|
146
|
+
def get_bucket_value_for_user(user_id, campaign = {}, group_id = nil, disable_logs = false)
|
147
|
+
user_id_for_hash_value = user_id
|
148
|
+
if group_id
|
149
|
+
user_id_for_hash_value = group_id.to_s + "_" + user_id
|
150
|
+
elsif campaign[:isBucketingSeedEnabled]
|
151
|
+
user_id_for_hash_value = campaign[:id].to_s + "_" + user_id
|
152
|
+
end
|
153
|
+
hash_value = MurmurHash3::V32.str_hash(user_id_for_hash_value, SEED_VALUE) & U_MAX_32_BIT
|
143
154
|
bucket_value = get_bucket_value(hash_value, MAX_TRAFFIC_PERCENT)
|
144
155
|
|
145
156
|
@logger.log(
|
@@ -150,7 +161,8 @@ class VWO
|
|
150
161
|
hash_value: hash_value,
|
151
162
|
bucket_value: bucket_value,
|
152
163
|
user_id: user_id
|
153
|
-
)
|
164
|
+
),
|
165
|
+
disable_logs
|
154
166
|
)
|
155
167
|
bucket_value
|
156
168
|
end
|
@@ -168,6 +180,22 @@ class VWO
|
|
168
180
|
multiplied_value = (max_value * ratio + 1) * multiplier
|
169
181
|
multiplied_value.to_i
|
170
182
|
end
|
183
|
+
|
184
|
+
# Returns a campaign by checking the Start and End Bucket Allocations of each campaign.
|
185
|
+
#
|
186
|
+
# @param[Integer] :range_for_campaigns the bucket value of the user
|
187
|
+
# @param[Hash] :campaigns The bucket Value of the user
|
188
|
+
# @return[Hash|nil]
|
189
|
+
#
|
190
|
+
def get_campaign_using_range(range_for_campaigns, campaigns)
|
191
|
+
range_for_campaigns = range_for_campaigns * 100
|
192
|
+
campaigns.each do |campaign|
|
193
|
+
if campaign["max_range"] && campaign["max_range"] >= range_for_campaigns && campaign["min_range"] <= range_for_campaigns
|
194
|
+
return campaign
|
195
|
+
end
|
196
|
+
end
|
197
|
+
nil
|
198
|
+
end
|
171
199
|
end
|
172
200
|
end
|
173
201
|
end
|