vwo-sdk 1.3.0 → 1.14.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/vwo.rb +1020 -84
- data/lib/vwo/constants.rb +64 -13
- data/lib/vwo/core/bucketer.rb +10 -14
- data/lib/vwo/core/variation_decider.rb +391 -80
- data/lib/vwo/enums.rb +113 -10
- data/lib/vwo/logger.rb +9 -3
- data/lib/vwo/schemas/settings_file.rb +1 -3
- data/lib/vwo/services/batch_events_dispatcher.rb +110 -0
- data/lib/vwo/services/batch_events_queue.rb +175 -0
- data/lib/vwo/services/event_dispatcher.rb +3 -17
- data/lib/vwo/services/hooks_manager.rb +36 -0
- data/lib/vwo/services/operand_evaluator.rb +122 -0
- data/lib/vwo/services/segment_evaluator.rb +88 -0
- data/lib/vwo/services/settings_file_manager.rb +11 -9
- data/lib/vwo/services/settings_file_processor.rb +6 -3
- data/lib/vwo/services/usage_stats.rb +29 -0
- data/lib/vwo/user_storage.rb +1 -3
- data/lib/vwo/utils/campaign.rb +151 -22
- data/lib/vwo/utils/custom_dimensions.rb +72 -0
- data/lib/vwo/utils/feature.rb +56 -0
- data/lib/vwo/utils/function.rb +6 -3
- data/lib/vwo/utils/impression.rb +76 -7
- data/lib/vwo/utils/request.rb +15 -3
- data/lib/vwo/utils/segment.rb +116 -0
- data/lib/vwo/utils/uuid.rb +3 -5
- data/lib/vwo/utils/validations.rb +96 -4
- metadata +30 -8
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright 2019 Wingify Software Pvt. Ltd.
|
1
|
+
# Copyright 2019-2021 Wingify Software Pvt. Ltd.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -12,11 +12,12 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
# frozen_string_literal: true
|
16
|
-
|
17
15
|
require 'json'
|
18
16
|
require 'json-schema'
|
19
17
|
require_relative '../schemas/settings_file'
|
18
|
+
require_relative '../logger'
|
19
|
+
require_relative '../enums'
|
20
|
+
require_relative '../constants'
|
20
21
|
|
21
22
|
class VWO
|
22
23
|
module Utils
|
@@ -34,7 +35,7 @@ class VWO
|
|
34
35
|
|
35
36
|
# @return [Boolean]
|
36
37
|
def valid_value?(val)
|
37
|
-
!val.nil?
|
38
|
+
!val.nil? && val != {} && val != []
|
38
39
|
end
|
39
40
|
|
40
41
|
# @return [Boolean]
|
@@ -51,6 +52,97 @@ class VWO
|
|
51
52
|
def valid_hash?(val)
|
52
53
|
val.is_a?(Hash)
|
53
54
|
end
|
55
|
+
|
56
|
+
# @return [Boolean]
|
57
|
+
def valid_boolean?(val)
|
58
|
+
val.is_a?(TrueClass) || val.is_a?(FalseClass)
|
59
|
+
end
|
60
|
+
|
61
|
+
# @return [Boolean]
|
62
|
+
def valid_basic_data_type?(val)
|
63
|
+
valid_number?(val) || valid_string?(val) || valid_boolean?(val)
|
64
|
+
end
|
65
|
+
|
66
|
+
# Validates if the value passed batch_events has correct data type and values or not.
|
67
|
+
#
|
68
|
+
# Args: batch_events [Hash]: value to be tested
|
69
|
+
#
|
70
|
+
# @return: [Boolean]: True if all conditions are passed else False
|
71
|
+
def is_valid_batch_event_settings(batch_events)
|
72
|
+
logger = VWO::Logger.get_instance
|
73
|
+
events_per_request = batch_events[:events_per_request]
|
74
|
+
request_time_interval = batch_events[:request_time_interval]
|
75
|
+
|
76
|
+
unless events_per_request || request_time_interval
|
77
|
+
logger.log(
|
78
|
+
VWO::LogLevelEnum::ERROR,
|
79
|
+
format(
|
80
|
+
VWO::LogMessageEnum::ErrorMessages::EVENT_BATCHING_INSUFFICIENT,
|
81
|
+
file: VWO::FileNameEnum::ValidateUtil
|
82
|
+
)
|
83
|
+
)
|
84
|
+
return false
|
85
|
+
end
|
86
|
+
|
87
|
+
if (request_time_interval && !valid_number?(request_time_interval))
|
88
|
+
logger.log(
|
89
|
+
VWO::LogLevelEnum::ERROR,
|
90
|
+
format(
|
91
|
+
VWO::LogMessageEnum::ErrorMessages::REQUEST_TIME_INTERVAL_INVALID,
|
92
|
+
file: VWO::FileNameEnum::ValidateUtil
|
93
|
+
)
|
94
|
+
)
|
95
|
+
return false
|
96
|
+
end
|
97
|
+
|
98
|
+
if (events_per_request && !valid_number?(events_per_request))
|
99
|
+
logger.log(
|
100
|
+
VWO::LogLevelEnum::ERROR,
|
101
|
+
format(
|
102
|
+
VWO::LogMessageEnum::ErrorMessages::EVENTS_PER_REQUEST_INVALID,
|
103
|
+
file: VWO::FileNameEnum::ValidateUtil
|
104
|
+
)
|
105
|
+
)
|
106
|
+
return false
|
107
|
+
end
|
108
|
+
|
109
|
+
if events_per_request && (events_per_request < VWO::MIN_EVENTS_PER_REQUEST || events_per_request > VWO::MAX_EVENTS_PER_REQUEST)
|
110
|
+
logger.log(
|
111
|
+
VWO::LogLevelEnum::ERROR,
|
112
|
+
format(
|
113
|
+
VWO::LogMessageEnum::ErrorMessages::EVENTS_PER_REQUEST_OUT_OF_BOUNDS,
|
114
|
+
file: VWO::FileNameEnum::ValidateUtil,
|
115
|
+
min_value: VWO::MIN_EVENTS_PER_REQUEST,
|
116
|
+
max_value: VWO::MAX_EVENTS_PER_REQUEST
|
117
|
+
)
|
118
|
+
)
|
119
|
+
return false
|
120
|
+
end
|
121
|
+
|
122
|
+
if request_time_interval && request_time_interval < VWO::MIN_REQUEST_TIME_INTERVAL
|
123
|
+
logger.log(
|
124
|
+
VWO::LogLevelEnum::ERROR,
|
125
|
+
format(
|
126
|
+
VWO::LogMessageEnum::ErrorMessages::REQUEST_TIME_INTERVAL_OUT_OF_BOUNDS,
|
127
|
+
file: VWO::FileNameEnum::ValidateUtil,
|
128
|
+
min_value: VWO::MIN_REQUEST_TIME_INTERVAL
|
129
|
+
)
|
130
|
+
)
|
131
|
+
return false
|
132
|
+
end
|
133
|
+
|
134
|
+
if batch_events.key?(:flushCallback) && !batch_events[:flushCallback].is_a?(Method)
|
135
|
+
logger.log(
|
136
|
+
VWO::LogLevelEnum::ERROR,
|
137
|
+
format(
|
138
|
+
VWO::LogMessageEnum::ErrorMessages::FLUSH_CALLBACK_INVALID,
|
139
|
+
file: VWO::FileNameEnum::ValidateUtil
|
140
|
+
)
|
141
|
+
)
|
142
|
+
return false
|
143
|
+
end
|
144
|
+
true
|
145
|
+
end
|
54
146
|
end
|
55
147
|
end
|
56
148
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vwo-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.14.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- VWO
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coveralls
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.70'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: mocha
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.13.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.13.0
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: json-schema
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,21 +94,30 @@ files:
|
|
80
94
|
- lib/vwo/enums.rb
|
81
95
|
- lib/vwo/logger.rb
|
82
96
|
- lib/vwo/schemas/settings_file.rb
|
97
|
+
- lib/vwo/services/batch_events_dispatcher.rb
|
98
|
+
- lib/vwo/services/batch_events_queue.rb
|
83
99
|
- lib/vwo/services/event_dispatcher.rb
|
100
|
+
- lib/vwo/services/hooks_manager.rb
|
101
|
+
- lib/vwo/services/operand_evaluator.rb
|
102
|
+
- lib/vwo/services/segment_evaluator.rb
|
84
103
|
- lib/vwo/services/settings_file_manager.rb
|
85
104
|
- lib/vwo/services/settings_file_processor.rb
|
105
|
+
- lib/vwo/services/usage_stats.rb
|
86
106
|
- lib/vwo/user_storage.rb
|
87
107
|
- lib/vwo/utils/campaign.rb
|
108
|
+
- lib/vwo/utils/custom_dimensions.rb
|
109
|
+
- lib/vwo/utils/feature.rb
|
88
110
|
- lib/vwo/utils/function.rb
|
89
111
|
- lib/vwo/utils/impression.rb
|
90
112
|
- lib/vwo/utils/request.rb
|
113
|
+
- lib/vwo/utils/segment.rb
|
91
114
|
- lib/vwo/utils/uuid.rb
|
92
115
|
- lib/vwo/utils/validations.rb
|
93
116
|
homepage: https://vwo.com/fullstack/server-side-testing/
|
94
117
|
licenses:
|
95
|
-
- Apache
|
118
|
+
- Apache-2.0
|
96
119
|
metadata: {}
|
97
|
-
post_install_message:
|
120
|
+
post_install_message:
|
98
121
|
rdoc_options: []
|
99
122
|
require_paths:
|
100
123
|
- lib
|
@@ -109,9 +132,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
132
|
- !ruby/object:Gem::Version
|
110
133
|
version: '0'
|
111
134
|
requirements: []
|
112
|
-
|
113
|
-
|
114
|
-
signing_key:
|
135
|
+
rubygems_version: 3.0.6
|
136
|
+
signing_key:
|
115
137
|
specification_version: 4
|
116
138
|
summary: Ruby SDK for VWO full-stack testing
|
117
139
|
test_files: []
|