vwo-sdk 1.29.1 → 1.36.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 -1
- data/lib/vwo/core/bucketer.rb +46 -36
- data/lib/vwo/core/variation_decider.rb +309 -306
- data/lib/vwo/enums.rb +0 -134
- data/lib/vwo/logger.rb +7 -3
- data/lib/vwo/schemas/settings_file.rb +1 -0
- data/lib/vwo/services/batch_events_dispatcher.rb +43 -34
- data/lib/vwo/services/batch_events_queue.rb +33 -33
- data/lib/vwo/services/event_dispatcher.rb +39 -19
- data/lib/vwo/services/segment_evaluator.rb +11 -10
- data/lib/vwo/services/settings_file_processor.rb +7 -4
- data/lib/vwo/utils/campaign.rb +26 -27
- data/lib/vwo/utils/custom_dimensions.rb +14 -14
- data/lib/vwo/utils/feature.rb +6 -9
- data/lib/vwo/utils/impression.rb +65 -56
- data/lib/vwo/utils/log_message.rb +76 -0
- data/lib/vwo/utils/utility.rb +7 -0
- data/lib/vwo/utils/uuid.rb +12 -10
- data/lib/vwo/utils/validations.rb +56 -48
- data/lib/vwo.rb +437 -438
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43fec6e51e5bb0377e3714ca0fa90bc1cd11c26c29c99af86e0b8fec858af4b1
|
4
|
+
data.tar.gz: 6b63f796cc23e812e65a731cfeefddfcee46c1bb1d24ece33b9bdecbc619bc62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0357c8d8c220348265463a1adaabd0480c9424cf8082d05541643c6ccdbdfbf2692e603a08acfd1b71d4762d31649ba1e5fd5469707f1e01251d96329509a6e2
|
7
|
+
data.tar.gz: e30bd9f514a53da482f5e7d38dda6a3ced309fa027afe4d9148cfb464fff6acf3da0e012574dbf38712390ab24daa0148a42ce76f83fb8d264ecfb88c8bfb84a
|
data/lib/vwo/constants.rb
CHANGED
@@ -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.36.0'
|
31
31
|
SDK_NAME = 'ruby'
|
32
32
|
VWO_DELIMITER = '_vwo_'
|
33
33
|
MAX_EVENTS_PER_REQUEST = 5000
|
@@ -94,6 +94,7 @@ class VWO
|
|
94
94
|
}
|
95
95
|
|
96
96
|
module ApiMethods
|
97
|
+
LAUNCH = 'launch'
|
97
98
|
ACTIVATE = 'activate'
|
98
99
|
GET_VARIATION_NAME = 'get_variation_name'
|
99
100
|
TRACK = 'track'
|
data/lib/vwo/core/bucketer.rb
CHANGED
@@ -13,9 +13,9 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
15
|
require 'murmurhash3'
|
16
|
-
require_relative '../logger'
|
17
16
|
require_relative '../enums'
|
18
17
|
require_relative '../utils/validations'
|
18
|
+
require_relative '../utils/log_message'
|
19
19
|
require_relative '../constants'
|
20
20
|
|
21
21
|
class VWO
|
@@ -34,37 +34,45 @@ class VWO
|
|
34
34
|
FILE = FileNameEnum::Bucketer
|
35
35
|
|
36
36
|
def initialize
|
37
|
-
@logger = VWO::Logger
|
37
|
+
@logger = VWO::Utils::Logger
|
38
38
|
end
|
39
39
|
|
40
40
|
# Calculate if this user should become part of the campaign or not
|
41
41
|
# @param[String] :user_id The unique ID assigned to a user
|
42
42
|
# @param[Dict] :campaign For getting traffic allotted to the campaign
|
43
|
+
# @param[Boolean] :disable_logs if true, do not log log-message
|
43
44
|
# @return[Boolean] If User is a part of Campaign or not
|
44
45
|
|
45
|
-
def user_part_of_campaign?(user_id, campaign)
|
46
|
+
def user_part_of_campaign?(user_id, campaign, disable_logs = false)
|
46
47
|
unless valid_value?(user_id)
|
47
48
|
@logger.log(
|
48
49
|
LogLevelEnum::ERROR,
|
49
|
-
|
50
|
+
'USER_ID_INVALID',
|
51
|
+
{
|
52
|
+
'{file}' => FILE,
|
53
|
+
'{userId}' => user_id
|
54
|
+
}
|
50
55
|
)
|
51
56
|
return false
|
52
57
|
end
|
53
58
|
|
54
59
|
if campaign.nil?
|
55
|
-
@logger.log(
|
56
|
-
LogLevelEnum::ERROR,
|
57
|
-
format(LogMessageEnum::ErrorMessages::INVALID_CAMPAIGN, file: FILE, method: 'is_user_part_of_campaign')
|
58
|
-
)
|
59
60
|
return false
|
60
61
|
end
|
61
62
|
|
62
63
|
traffic_allocation = campaign['percentTraffic']
|
63
|
-
value_assigned_to_user = get_bucket_value_for_user(user_id, campaign)
|
64
|
+
value_assigned_to_user = get_bucket_value_for_user(user_id, campaign, nil, disable_logs)
|
64
65
|
is_user_part = (value_assigned_to_user != 0) && value_assigned_to_user <= traffic_allocation
|
65
66
|
@logger.log(
|
66
67
|
LogLevelEnum::INFO,
|
67
|
-
|
68
|
+
'USER_CAMPAIGN_ELIGIBILITY',
|
69
|
+
{
|
70
|
+
'{file}' => FILE,
|
71
|
+
'{userId}' => user_id,
|
72
|
+
'{status}' => is_user_part ? 'eligible' : 'not eligible',
|
73
|
+
'{campaignKey}' => campaign['key']
|
74
|
+
},
|
75
|
+
disable_logs
|
68
76
|
)
|
69
77
|
is_user_part
|
70
78
|
end
|
@@ -74,29 +82,30 @@ class VWO
|
|
74
82
|
#
|
75
83
|
# @param[String] :user_id The unique ID assigned to User
|
76
84
|
# @param[Hash] :campaign The Campaign of which User is a part of
|
85
|
+
# @param[Boolean] :disable_logs if true, do not log log-message
|
77
86
|
#
|
78
87
|
# @return[Hash|nil} Variation data into which user is bucketed to
|
79
88
|
# or nil if not
|
80
|
-
def bucket_user_to_variation(user_id, campaign)
|
89
|
+
def bucket_user_to_variation(user_id, campaign, disable_logs = false)
|
81
90
|
unless valid_value?(user_id)
|
82
91
|
@logger.log(
|
83
92
|
LogLevelEnum::ERROR,
|
84
|
-
|
93
|
+
'USER_ID_INVALID',
|
94
|
+
{
|
95
|
+
'{file}' => FILE,
|
96
|
+
'{userId}' => user_id
|
97
|
+
}
|
85
98
|
)
|
86
99
|
return
|
87
100
|
end
|
88
101
|
|
89
102
|
unless campaign
|
90
|
-
@logger.log(
|
91
|
-
LogLevelEnum::ERROR,
|
92
|
-
format(LogMessageEnum::ErrorMessages::INVALID_CAMPAIGN, file: FILE, method: 'is_user_part_of_campaign')
|
93
|
-
)
|
94
103
|
return
|
95
104
|
end
|
96
105
|
|
97
106
|
user_id_for_hash_value = user_id
|
98
|
-
if campaign[
|
99
|
-
user_id_for_hash_value = campaign[
|
107
|
+
if campaign['isBucketingSeedEnabled']
|
108
|
+
user_id_for_hash_value = campaign['id'].to_s + "_" + user_id
|
100
109
|
end
|
101
110
|
hash_value = MurmurHash3::V32.str_hash(user_id_for_hash_value, SEED_VALUE) & U_MAX_32_BIT
|
102
111
|
normalize = MAX_TRAFFIC_VALUE.to_f / campaign['percentTraffic']
|
@@ -109,15 +118,16 @@ class VWO
|
|
109
118
|
|
110
119
|
@logger.log(
|
111
120
|
LogLevelEnum::DEBUG,
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
+
'USER_CAMPAIGN_BUCKET_VALUES',
|
122
|
+
{
|
123
|
+
'{file}' => FILE,
|
124
|
+
'{campaignKey}' => campaign['key'],
|
125
|
+
'{userId}' => user_id,
|
126
|
+
'{percentTraffic}' => campaign['percentTraffic'],
|
127
|
+
'{hashValue}' => hash_value,
|
128
|
+
'{bucketValue}' => bucket_value,
|
129
|
+
},
|
130
|
+
disable_logs
|
121
131
|
)
|
122
132
|
|
123
133
|
get_variation(campaign['variations'], bucket_value)
|
@@ -147,21 +157,21 @@ class VWO
|
|
147
157
|
user_id_for_hash_value = user_id
|
148
158
|
if group_id
|
149
159
|
user_id_for_hash_value = group_id.to_s + "_" + user_id
|
150
|
-
elsif campaign[
|
151
|
-
user_id_for_hash_value = campaign[
|
160
|
+
elsif campaign['isBucketingSeedEnabled']
|
161
|
+
user_id_for_hash_value = campaign['id'].to_s + "_" + user_id
|
152
162
|
end
|
153
163
|
hash_value = MurmurHash3::V32.str_hash(user_id_for_hash_value, SEED_VALUE) & U_MAX_32_BIT
|
154
164
|
bucket_value = get_bucket_value(hash_value, MAX_TRAFFIC_PERCENT)
|
155
165
|
|
156
166
|
@logger.log(
|
157
167
|
LogLevelEnum::DEBUG,
|
158
|
-
|
159
|
-
|
160
|
-
file
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
168
|
+
'USER_HASH_BUCKET_VALUE',
|
169
|
+
{
|
170
|
+
'{file}' => FILE,
|
171
|
+
'{hashValue}' => hash_value,
|
172
|
+
'{userId}' => user_id,
|
173
|
+
'{bucketValue}' => bucket_value
|
174
|
+
},
|
165
175
|
disable_logs
|
166
176
|
)
|
167
177
|
bucket_value
|