vwo-sdk 1.30.0 → 1.35.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 +42 -32
- 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: dfb56a7b9b42ecdd68adf08aec9d3730718f06e2524391cdd13e36b102f2a101
|
4
|
+
data.tar.gz: 24c6d8e61d28e47af3d2e15c7d1bf359a4b0baf2a45db4c4ca6c020b65b937e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07b6bc00eb777b88e60a1adaa0faa186b214ae492b86af876c3118e9eecac6d598de0e1e60d9abc54d20877ded9c0236c0661d5be9f1d92a1ee5d7f902ad3b9e
|
7
|
+
data.tar.gz: 80163a10745a7683a56dfa3717de522414a38110a54645e609bf8c4522451eca7c1175f5d02b1bfa3efe244aeffe6dfee523d6bf4a3b101bda789550fd967a3d
|
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.35.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,23 +82,24 @@ 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
|
|
@@ -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)
|
@@ -155,13 +165,13 @@ class VWO
|
|
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
|