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
@@ -23,6 +23,7 @@ class VWO
|
|
23
23
|
module Utils
|
24
24
|
module Validations
|
25
25
|
include Enums
|
26
|
+
include CONSTANTS
|
26
27
|
# Validates the settings_file
|
27
28
|
# @param [Hash]: JSON object received from VWO server
|
28
29
|
# must be JSON.
|
@@ -70,7 +71,7 @@ class VWO
|
|
70
71
|
# api_name [String]: current api name
|
71
72
|
#
|
72
73
|
# @return: [Boolean]: True if all conditions are passed else False
|
73
|
-
def
|
74
|
+
def valid_batch_event_settings(batch_events, api_name)
|
74
75
|
events_per_request = batch_events[:events_per_request]
|
75
76
|
request_time_interval = batch_events[:request_time_interval]
|
76
77
|
|
@@ -79,12 +80,12 @@ class VWO
|
|
79
80
|
return false
|
80
81
|
end
|
81
82
|
|
82
|
-
if
|
83
|
+
if request_time_interval && !valid_number?(request_time_interval)
|
83
84
|
invalid_config_log('batch_events', 'object', api_name)
|
84
85
|
return false
|
85
86
|
end
|
86
87
|
|
87
|
-
if
|
88
|
+
if events_per_request && !valid_number?(events_per_request)
|
88
89
|
invalid_config_log('batch_events', 'object', api_name)
|
89
90
|
return false
|
90
91
|
end
|
@@ -132,7 +133,7 @@ class VWO
|
|
132
133
|
LogLevelEnum::INFO,
|
133
134
|
'CONFIG_PARAMETER_USED',
|
134
135
|
{
|
135
|
-
'{file}' => VWO::FileNameEnum::
|
136
|
+
'{file}' => VWO::FileNameEnum::VALIDATE_UTIL,
|
136
137
|
'{parameter}' => parameter,
|
137
138
|
'{type}' => type
|
138
139
|
}
|
@@ -144,13 +145,79 @@ class VWO
|
|
144
145
|
LogLevelEnum::ERROR,
|
145
146
|
'CONFIG_PARAMETER_INVALID',
|
146
147
|
{
|
147
|
-
'{file}' => VWO::FileNameEnum::
|
148
|
+
'{file}' => VWO::FileNameEnum::VALIDATE_UTIL,
|
148
149
|
'{parameter}' => parameter,
|
149
150
|
'{type}' => type,
|
150
151
|
'{api}' => api_name
|
151
152
|
}
|
152
153
|
)
|
153
154
|
end
|
155
|
+
|
156
|
+
def valid_goal?(goal, campaign, user_id, goal_identifier, revenue_value)
|
157
|
+
if goal.nil? || !goal['id']
|
158
|
+
Logger.log(
|
159
|
+
LogLevelEnum::ERROR,
|
160
|
+
'TRACK_API_GOAL_NOT_FOUND',
|
161
|
+
{
|
162
|
+
'{file}' => FILE,
|
163
|
+
'{goalIdentifier}' => goal_identifier,
|
164
|
+
'{userId}' => user_id,
|
165
|
+
'{campaignKey}' => campaign['key']
|
166
|
+
}
|
167
|
+
)
|
168
|
+
return false
|
169
|
+
elsif goal['type'] == GoalTypes::REVENUE && !valid_value?(revenue_value)
|
170
|
+
Logger.log(
|
171
|
+
LogLevelEnum::ERROR,
|
172
|
+
'TRACK_API_REVENUE_NOT_PASSED_FOR_REVENUE_GOAL',
|
173
|
+
{
|
174
|
+
'{file}' => FILE,
|
175
|
+
'{userId}' => user_id,
|
176
|
+
'{goalIdentifier}' => goal_identifier,
|
177
|
+
'{campaignKey}' => campaign['key']
|
178
|
+
}
|
179
|
+
)
|
180
|
+
return false
|
181
|
+
end
|
182
|
+
true
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
def valid_campaign_for_track_api?(user_id, campaign_key, campaign_type)
|
187
|
+
if campaign_type == CONSTANTS::CampaignTypes::FEATURE_ROLLOUT
|
188
|
+
Logger.log(
|
189
|
+
LogLevelEnum::ERROR,
|
190
|
+
'API_NOT_APPLICABLE',
|
191
|
+
{
|
192
|
+
'{file}' => FILE,
|
193
|
+
'{api}' => ApiMethods::TRACK,
|
194
|
+
'{userId}' => user_id,
|
195
|
+
'{campaignKey}' => campaign_key,
|
196
|
+
'{campaignType}' => campaign_type
|
197
|
+
}
|
198
|
+
)
|
199
|
+
return false
|
200
|
+
end
|
201
|
+
true
|
202
|
+
end
|
203
|
+
|
204
|
+
def valid_track_api_params?(user_id, campaign_key, custom_variables, variation_targeting_variables, goal_type_to_track, goal_identifier)
|
205
|
+
unless (valid_string?(campaign_key) || campaign_key.is_a?(Array) || campaign_key.nil?) &&
|
206
|
+
valid_string?(user_id) && valid_string?(goal_identifier) &&
|
207
|
+
(custom_variables.nil? || valid_hash?(custom_variables)) &&
|
208
|
+
(variation_targeting_variables.nil? || valid_hash?(variation_targeting_variables)) && CONSTANTS::GOAL_TYPES.key?(goal_type_to_track)
|
209
|
+
# log invalid params
|
210
|
+
Logger.log(
|
211
|
+
LogLevelEnum::ERROR,
|
212
|
+
'API_BAD_PARAMETERS',
|
213
|
+
{
|
214
|
+
'{file}' => FILE,
|
215
|
+
'{api}' => ApiMethods::TRACK
|
216
|
+
}
|
217
|
+
)
|
218
|
+
return false
|
219
|
+
end
|
220
|
+
true
|
154
221
|
end
|
155
222
|
end
|
156
223
|
end
|