vwo-sdk 1.30.0 → 1.35.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 +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
data/lib/vwo/enums.rb
CHANGED
@@ -83,140 +83,6 @@ class VWO
|
|
83
83
|
CustomDimensionsUtil = UTIL_PATH + '/custom_dimensions_util'
|
84
84
|
end
|
85
85
|
|
86
|
-
# Logging Enums
|
87
|
-
module LogMessageEnum
|
88
|
-
# Debug Messages
|
89
|
-
module DebugMessages
|
90
|
-
LOG_LEVEL_SET = '(%<file>s): Log level set to %<level>s'
|
91
|
-
SET_DEVELOPMENT_MODE = '(%<file>s): DEVELOPMENT mode is ON'
|
92
|
-
VALID_CONFIGURATION = '(%<file>s): SDK configuration and account settings are valid.'
|
93
|
-
CUSTOM_LOGGER_USED = '(%<file>s): Custom logger used'
|
94
|
-
SDK_INITIALIZED = '(%<file>s): SDK properly initialized'
|
95
|
-
SETTINGS_FILE_PROCESSED = '(%<file>s): Settings file processed'
|
96
|
-
NO_STORED_VARIATION = '(%<file>s): No stored variation for UserId:%<user_id>s for Campaign:%<campaign_key>s found in UserStorageService'
|
97
|
-
NO_USER_STORAGE_SERVICE_LOOKUP = '(%<file>s): No UserStorageService to look for stored data'
|
98
|
-
NO_USER_STORAGE_SERVICE_SAVE = '(%<file>s): No UserStorageService to save data'
|
99
|
-
GETTING_STORED_VARIATION = '(%<file>s): Got stored variation for UserId:%<user_id>s of Campaign:%<campaign_key>s as Variation: %<variation_name>s found in UserStorageService'
|
100
|
-
CHECK_USER_ELIGIBILITY_FOR_CAMPAIGN = '(%<file>s): campaign:%<campaign_key>s having traffic allocation:%<traffic_allocation>s assigned value:%<traffic_allocation>s to userId:%<user_id>s'
|
101
|
-
USER_HASH_BUCKET_VALUE = '(%<file>s): userId:%<user_id>s having hash:%<hash_value>s got bucketValue:%<bucket_value>s'
|
102
|
-
VARIATION_HASH_BUCKET_VALUE = '(%<file>s): userId:%<user_id>s for campaign:%<campaign_key>s having percent traffic:%<percent_traffic>s got hash-value:%<hash_value>s and bucket value:%<bucket_value>s'
|
103
|
-
IMPRESSION_FAILED = '(%<file>s): userId:%<user_id>s for campaign:%<campaign_key>s got variationName:%<variation_name>s inside method:%<method>s'
|
104
|
-
USER_NOT_PART_OF_CAMPAIGN = '(%<file>s): userId:%<user_id>s for campaign:%<campaign_key>s did not become part of campaign method:%<method>s'
|
105
|
-
UUID_FOR_USER = '(%<file>s): Uuid generated for userId:%<user_id>s and accountId:%<account_id>s is %<desired_uuid>s'
|
106
|
-
IMPRESSION_FOR_TRACK_USER = '(%<file>s): Impression built for track-user - %<properties>s'
|
107
|
-
IMPRESSION_FOR_TRACK_GOAL = '(%<file>s): Impression built for track-goal - %<properties>s'
|
108
|
-
GOT_VARIATION_FOR_USER = '(%<file>s): userId:%<user_id>s for campaign:%<campaign_key>s got variationName:%<variation_name>s'
|
109
|
-
SEGMENTATION_STATUS = '(%<file>s): In API: %<api_name>s, for UserId:%<user_id>s of campaign:%<campaign_key>s with variables:%<custom_variables>s %<status>s %<segmentation_type>s %<variation_name>s'
|
110
|
-
PARAMS_FOR_PUSH_CALL = '(%<file>s): Params for push call - %<properties>s'
|
111
|
-
CAMPAIGN_NOT_ACTIVATED = '(%<file>s): Campaign:%<campaign_key>s for User ID:%<user_id>s is not yet activated for API:%<api_name>s. Use activate API to activate A/B test or isFeatureEnabled API to activate Feature Test.'
|
112
|
-
BATCH_EVENT_LIMIT_EXCEEDED = '(%<file>s): Impression event - %<end_point>s failed due to exceeding payload size. Parameter eventsPerRequest in batchEvents config in launch API has value:%<eventsPerRequest>s for accountId:%<accountId>s. Please read the official documentation for knowing the size limits.'
|
113
|
-
BULK_NOT_PROCESSED = "(%<file>s): Batch events couldn't be received by VWO. Calling Flush Callback with error and data."
|
114
|
-
BEFORE_FLUSHING = '(%<file>s): Flushing events queue %<manually>s having %<length>s events %<timer>s queue summary: %<queue_metadata>s'
|
115
|
-
EVENT_BATCHING_INSUFFICIENT = '(%<file>s): %<key>s not provided, assigning default value'
|
116
|
-
GOT_ELIGIBLE_CAMPAIGNS = "(%<file>s): Campaigns:%<eligible_campaigns_key>s are eligible, %<ineligible_campaigns_log_text>s are ineligible from the Group:%<group_name>s for the User ID:%<user_id>s"
|
117
|
-
IMPRESSION_FOR_EVENT_ARCH_TRACK_USER = "(%<file>s): impression built for vwo_variationShown event for account ID:%<a>s, user ID:%<u>s, and campaign ID:%<c>s"
|
118
|
-
IMPRESSION_FOR_EVENT_ARCH_TRACK_GOAL = "(%<file>s): impression built for %<goal_identifier>s event for account ID:%<a>s, user ID:%<u>s, and campaign ID:%<c>s"
|
119
|
-
IMPRESSION_FOR_EVENT_ARCH_PUSH = "(%<file>s): impression built for visitor property:%<property>s for account ID:%<a>s and user ID:%<u>s"
|
120
|
-
end
|
121
|
-
|
122
|
-
# Info Messages
|
123
|
-
module InfoMessages
|
124
|
-
VARIATION_RANGE_ALLOCATION = '(%<file>s): Campaign:%<campaign_key>s having variations:%<variation_name>s with weight:%<variation_weight>s got range as: ( %<start>s - %<end>s ))'
|
125
|
-
VARIATION_ALLOCATED = '(%<file>s): UserId:%<user_id>s of Campaign:%<campaign_key>s type: %<campaign_type>s got variation: %<variation_name>s'
|
126
|
-
LOOKING_UP_USER_STORAGE_SERVICE = '(%<file>s): Looked into UserStorageService for userId:%<user_id>s %<status>s'
|
127
|
-
SAVING_DATA_USER_STORAGE_SERVICE = '(%<file>s): Saving into UserStorageService for userId:%<user_id>s successful'
|
128
|
-
GOT_STORED_VARIATION = '(%<file>s): Got stored variation:%<variation_name>s of campaign:%<campaign_key>s for userId:%<user_id>s from UserStorageService'
|
129
|
-
NO_VARIATION_ALLOCATED = '(%<file>s): UserId:%<user_id>s of Campaign:%<campaign_key>s did not get any variation'
|
130
|
-
USER_ELIGIBILITY_FOR_CAMPAIGN = '(%<file>s): Is userId:%<user_id>s part of campaign? %<is_user_part>s'
|
131
|
-
AUDIENCE_CONDITION_NOT_MET = '(%<file>s): userId:%<user_id>s does not become part of campaign because of not meeting audience conditions'
|
132
|
-
GOT_VARIATION_FOR_USER = '(%<file>s): userId:%<user_id>s for campaign:%<campaign_key>s got variationName:%<variation_name>s'
|
133
|
-
USER_GOT_NO_VARIATION = '(%<file>s): userId:%<user_id>s for campaign:%<campaign_key>s did not allot any variation'
|
134
|
-
IMPRESSION_SUCCESS_FOR_EVENT_ARCH = '(%<file>s): Impression for %<event>s - %<url>s was successfully received by VWO for account ID:%<a>s'
|
135
|
-
IMPRESSION_SUCCESS = '(%<file>s): Impression event - %<end_point>s was successfully received by VWO having main keys: accountId:%<account_id>s campaignId:%<campaign_id>s and variationId:%<variation_id>s'
|
136
|
-
MAIN_KEYS_FOR_IMPRESSION = '(%<file>s): Having main keys: accountId:%<account_id>s campaignId:%<campaign_id>s and variationId:%<variation_id>s}'
|
137
|
-
MAIN_KEYS_FOR_PUSH_API = '(%<file>s): Having main keys: accountId:%<account_id>s u:%<u>s and tags:%<tags>s}'
|
138
|
-
INVALID_VARIATION_KEY = '(%<file>s): Variation was not assigned to userId:%<user_id>s for campaign:%<campaign_key>s'
|
139
|
-
|
140
|
-
USER_IN_FEATURE_ROLLOUT = '(%<file>s): User ID:%<user_id>s is in feature rollout:%<campaign_key>s'
|
141
|
-
USER_NOT_IN_FEATURE_ROLLOUT = '(%<file>s): User ID:%<user_id>s is NOT in feature rollout:%<campaign_key>s'
|
142
|
-
FEATURE_ENABLED_FOR_USER = '(%<file>s): In API: %<api_name>s Feature having feature-key:%<feature_key>s for user ID:%<user_id>s is enabled'
|
143
|
-
FEATURE_NOT_ENABLED_FOR_USER = '(%<file>s): In API: %<api_name>s Feature having feature-key:%<feature_key>s for user ID:%<user_id>s is not enabled'
|
144
|
-
|
145
|
-
VARIABLE_FOUND = '(%<file>s): In API: %<api_name>s Value for variable:%<variable_key>s of campaign:%<campaign_key>s and campaign type: %<campaign_type>s is:%<variable_value>s for user:%<user_id>s'
|
146
|
-
|
147
|
-
USER_PASSED_SEGMENTATION = '(%<file>s): UserId:%<user_id>s of campaign:%<campaign_key>s with custom_variables:%<custom_variables>s passed segmentation'
|
148
|
-
USER_FAILED_SEGMENTATION = '(%<file>s): UserId:%<user_id>s of campaign:%<campaign_key>s with custom_variables:%<custom_variables>s failed segmentation'
|
149
|
-
|
150
|
-
NO_CUSTOM_VARIABLES = '(%<file>s): In API: %<api_name>s, for UserId:%<user_id>s customVariables are not passed for campaign:%<campaign_key>s and campaign has pre-segmentation'
|
151
|
-
SKIPPING_SEGMENTATION = '(%<file>s): In API: %<api_name>s, Skipping segmentation:%<variation>s for UserId:%<user_id>s as no valid segments found in campaign:%<campaign_key>s'
|
152
|
-
|
153
|
-
SEGMENTATION_STATUS = '(%<file>s): In API: %<api_name>s, for UserId:%<user_id>s of campaign:%<campaign_key>s with variables:%<custom_variables>s %<status>s %<segmentation_type>s %<variation_name>s'
|
154
|
-
WHITELISTING_SKIPPED = '(%<file>s): In API: %<api_name>s, Skipping whitelisting for UserId:%<user_id>s of campaign:%<campaign_key>s'
|
155
|
-
SETTINGS_NOT_UPDATED = '(%<file>s): Settings-file fetched are same as earlier fetched settings'
|
156
|
-
SETTINGS_FILE_UPDATED = '(%<file>s): %<api_name>s vwo_sdk_instance is updated with the latest settings_file'
|
157
|
-
CAMPAIGN_NOT_ACTIVATED = '(%<file>s): Activate the campaign:%<campaign_key>s for User ID:%<user_id>s to %<reason>s.'
|
158
|
-
GOAL_ALREADY_TRACKED = '(%<file>s): Goal:%<goal_identifier>s of Campaign:%<campaign_key>s for User ID:%<user_id>s has already been tracked earlier. Skipping now'
|
159
|
-
USER_ALREADY_TRACKED = '(%<file>s): User ID:%<user_id>s for Campaign:%<campaign_key>s has already been tracked earlier for "%<api_name>s" API. Skipping now'
|
160
|
-
API_CALLED = '(%<file>s): API: %<api_name>s called for UserId:%<user_id>s'
|
161
|
-
BULK_IMPRESSION_SUCCESS = '(%<file>s): Impression event - %<end_point>s was successfully received by VWO having accountId:%<a>s'
|
162
|
-
AFTER_FLUSHING = '(%<file>s): Events queue having %<length>s events has been flushed %<manually>s queue summary: %<queue_metadata>s'
|
163
|
-
GOT_WINNER_CAMPAIGN = "(%<file>s): Campaign:%<campaign_key>s is selected from the mutually exclusive group:%<group_name>s for the User ID:%<user_id>s"
|
164
|
-
GOT_ELIGIBLE_CAMPAIGNS = "(%<file>s): Got %<no_of_eligible_campaigns>s eligible winners out of %<no_of_group_campaigns>s from the Group:%<group_name>s and for User ID:%<user_id>s"
|
165
|
-
CALLED_CAMPAIGN_NOT_WINNER = "(%<file>s): Campaign:%<campaign_key>s does not qualify from the mutually exclusive group:%<group_name>s for User ID:%<user_id>s"
|
166
|
-
OTHER_CAMPAIGN_SATISFIES_WHITELISTING_OR_STORAGE = "(%<file>s): Campaign:%<campaign_key>s of Group:%<group_name>s satisfies %<type>s for User ID:%<user_id>s"
|
167
|
-
OPT_OUT_API_CALLED = "(%<file>s): You have opted out for not tracking i.e. all API calls will stop functioning and will simply early return"
|
168
|
-
API_NOT_ENABLED = "(%<file>s): %<api>s API is disabled as you opted out for tracking. Reinitialize the SDK to enable the normal functioning of all APIs."
|
169
|
-
end
|
170
|
-
|
171
|
-
# Warning Messages
|
172
|
-
module WarningMessages; end
|
173
|
-
|
174
|
-
# Error Messages
|
175
|
-
module ErrorMessages
|
176
|
-
SETTINGS_FILE_CORRUPTED = '(%<file>s): Settings file is corrupted. Please contact VWO Support for help.'
|
177
|
-
ACTIVATE_API_MISSING_PARAMS = '(%<file>s): %<api_name>s API got bad parameters. It expects campaignTestKey(String) as first and userId(String) as second argument, customVariables(Hash) can be passed via options for pre-segmentation'
|
178
|
-
API_CONFIG_CORRUPTED = '(%<file>s): %<api_name>s API has corrupted configuration'
|
179
|
-
GET_VARIATION_NAME_API_INVALID_PARAMS = '(%<file>s): %<api_name>s API got bad parameters. It expects campaignTestKey(String) as first and userId(String) as second argument, customVariables(Hash) can be passed via options for pre-segmentation'
|
180
|
-
GET_VARIATION_API_CONFIG_CORRUPTED = '(%<file>s): "getVariation" API has corrupted configuration'
|
181
|
-
TRACK_API_INVALID_PARAMS = '(%<file>s): %<api_name>s API got bad parameters. It expects campaignTestKey(Nil/String/Array) as first userId(String) as second and goalIdentifier(String/Number) as third argument. Fourth is revenueValue(Float/Number/String) and is required for revenue goal only. customVariables(Hash) can be passed via options for pre-segmentation'
|
182
|
-
TRACK_API_CONFIG_CORRUPTED = '(%<file>s): "track" API has corrupted configuration'
|
183
|
-
TRACK_API_GOAL_NOT_FOUND = '(%<file>s): Goal:%<goal_identifier>s not found for campaign:%<campaign_key>s and userId:%<user_id>s'
|
184
|
-
TRACK_API_REVENUE_NOT_PASSED_FOR_REVENUE_GOAL = '(%<file>s): Revenue value should be passed for revenue goal:%<goal_identifier>s for campaign:%<campaign_key>s and userId:%<user_id>s'
|
185
|
-
TRACK_API_VARIATION_NOT_FOUND = '(%<file>s): Variation not found for campaign:%<campaign_key>s and userId:%<user_id>s'
|
186
|
-
CAMPAIGN_NOT_RUNNING = '(%<file>s): API used:%<api_name>s - Campaign:%<campaign_key>s is not RUNNING. Please verify from VWO App'
|
187
|
-
LOOK_UP_USER_STORAGE_SERVICE_FAILED = '(%<file>s): Looking data from UserStorageService failed for userId:%<user_id>s'
|
188
|
-
SAVE_USER_STORAGE_SERVICE_FAILED = '(%<file>s): Saving data into UserStorageService failed for userId:%<user_id>s'
|
189
|
-
INVALID_CAMPAIGN = '(%<file>s): Invalid campaign passed to %<method>s of this file'
|
190
|
-
INVALID_USER_ID = '(%<file>s): Invalid userId:%<user_id>s passed to %<method>s of this file'
|
191
|
-
IMPRESSION_FAILED = '(%<file>s): Impression event could not be sent to VWO - %<end_point>s'
|
192
|
-
CUSTOM_LOGGER_MISCONFIGURED = '(%<file>s): Custom logger is provided but seems to have mis-configured. %<extra_info>s Please check the API Docs. Using default logger.'
|
193
|
-
INVALID_API = '(%<file>s): %<api_name>s API is not valid for user ID: %<user_id>s in campaign ID: %<campaign_key>s having campaign type: %<campaign_type>s.'
|
194
|
-
IS_FEATURE_ENABLED_API_INVALID_PARAMS = '(%<file>s): %<api_name>s API got bad parameters. It expects campaign_key(String) as first and user_id(String) as second argument, customVariables(dict) can be passed via options for pre-segmentation'
|
195
|
-
GET_FEATURE_VARIABLE_VALUE_API_INVALID_PARAMS = '(%<file>s): "get_feature_variable" API got bad parameters. It expects campaign_key(String) as first, variable_key(string) as second and user_id(String) as third argument, customVariables(dict) can be passed via options for pre-segmentation'
|
196
|
-
|
197
|
-
VARIABLE_NOT_FOUND = '(%<file>s): In API: %<api_name>s Variable %<variable_key>s not found for campaign %<campaign_key>s and type %<campaign_type>s for user ID %<user_id>s'
|
198
|
-
UNABLE_TO_TYPE_CAST = '(%<file>s): Unable to typecast value: %<value>s of type: %<of_type>s to type: %<variable_type>s.'
|
199
|
-
|
200
|
-
USER_NOT_IN_CAMPAIGN = '(%<file>s): userId:%<user_id>s did not become part of campaign:%<campaign_key>s and campaign type:%<campaign_type>s'
|
201
|
-
API_NOT_WORKING = '(%<file>s): API: %<api_name>s not working, exception caught: %<exception>s. Please contact VWO Support for help.'
|
202
|
-
|
203
|
-
SEGMENTATION_ERROR = '(%<file>s): Error while segmenting the UserId:%<user_id>s of campaign:%<campaign_key>s with custom_variables:%<custom_variables>s. Error message: %<error_message>s'
|
204
|
-
|
205
|
-
PUSH_API_INVALID_PARAMS = '(%<file>s): %<api_name>s API got bad parameters. It expects tag_key(String) as first and tag_value(String) as second argument and user_id(String) as third argument'
|
206
|
-
TAG_VALUE_LENGTH_EXCEEDED = '(%<file>s): In API: %<api_name>s, the length of tag_value:%<tag_value>s and userID: %<user_id>s can not be greater than 255'
|
207
|
-
TAG_KEY_LENGTH_EXCEEDED = '(%<file>s): In API: %<api_name>s, the length of tag_key:%<tag_key>s and userID: %<user_id>s can not be greater than 255'
|
208
|
-
TRACK_API_MISSING_PARAMS = '(%<file>s): "track" API got bad parameters. It expects campaignKey(null/String/array) as first, userId(String/Number) as second and goalIdentifier (string) as third argument. options is revenueValue(Float/Number/String) and is required for revenue goal only.'
|
209
|
-
NO_CAMPAIGN_FOUND = '(%<file>s): No campaign found for goal_identifier:%<goal_identifier>s. Please verify from VWO app.'
|
210
|
-
INVALID_GOAL_TYPE = '(%<file>s): goal_type_to_track should be certain strings'
|
211
|
-
EVENT_BATCHING_NOT_OBJECT = '(%<file>s): Batch events settings are not of type object.'
|
212
|
-
EVENTS_PER_REQUEST_INVALID = '(%<file>s): events_per_request should be an integer'
|
213
|
-
REQUEST_TIME_INTERVAL_INVALID = '(%<file>s): request_time_interval should be a number'
|
214
|
-
EVENTS_PER_REQUEST_OUT_OF_BOUNDS = '(%<file>s): events_per_request should be >= %<min_value>s and <= %<max_value>s'
|
215
|
-
REQUEST_TIME_INTERVAL_OUT_OF_BOUNDS = '(%<file>s): request_time_interval should be >= %<min_value>s'
|
216
|
-
FLUSH_CALLBACK_INVALID = '(%<file>s): flush_callback is not callable'
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
86
|
module LogLevelEnum
|
221
87
|
INFO = ::Logger::INFO
|
222
88
|
DEBUG = ::Logger::DEBUG
|
data/lib/vwo/logger.rb
CHANGED
@@ -16,6 +16,12 @@ require 'logger'
|
|
16
16
|
|
17
17
|
class VWO
|
18
18
|
class Logger
|
19
|
+
|
20
|
+
DEBUG = ::Logger::DEBUG
|
21
|
+
INFO = ::Logger::INFO
|
22
|
+
ERROR = ::Logger::ERROR
|
23
|
+
WARN = ::Logger::WARN
|
24
|
+
|
19
25
|
@logger = nil
|
20
26
|
@logger_instance = nil
|
21
27
|
|
@@ -28,10 +34,8 @@ class VWO
|
|
28
34
|
end
|
29
35
|
|
30
36
|
# Override this method to handle logs in a custom manner
|
31
|
-
def log(level, message
|
32
|
-
unless disable_logs
|
37
|
+
def log(level, message)
|
33
38
|
@@logger_instance.log(level, message)
|
34
|
-
end
|
35
39
|
end
|
36
40
|
|
37
41
|
def instance
|
@@ -12,10 +12,10 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
require_relative '../logger'
|
16
15
|
require_relative '../enums'
|
17
16
|
require_relative '../utils/request'
|
18
17
|
require_relative '../utils/utility'
|
18
|
+
require_relative '../utils/log_message'
|
19
19
|
class VWO
|
20
20
|
module Services
|
21
21
|
class BatchEventsDispatcher
|
@@ -26,8 +26,9 @@ class VWO
|
|
26
26
|
# @param [Boolean] : To specify whether the request
|
27
27
|
# to our server should be made or not.
|
28
28
|
#
|
29
|
-
def initialize
|
30
|
-
@logger = VWO::Logger
|
29
|
+
def initialize(development_mode = false)
|
30
|
+
@logger = VWO::Utils::Logger
|
31
|
+
@development_mode = development_mode
|
31
32
|
@queue = []
|
32
33
|
end
|
33
34
|
|
@@ -44,66 +45,74 @@ class VWO
|
|
44
45
|
if resp.code == '200'
|
45
46
|
@logger.log(
|
46
47
|
LogLevelEnum::INFO,
|
47
|
-
|
48
|
-
|
49
|
-
file
|
50
|
-
|
51
|
-
|
52
|
-
|
48
|
+
'IMPRESSION_BATCH_SUCCESS',
|
49
|
+
{
|
50
|
+
'{file}' => FILE,
|
51
|
+
'{endPoint}' => url,
|
52
|
+
'{accountId}' => account_id,
|
53
|
+
}
|
53
54
|
)
|
54
55
|
message = nil
|
55
56
|
elsif resp.code == '413'
|
56
57
|
@logger.log(
|
57
58
|
LogLevelEnum::DEBUG,
|
58
|
-
|
59
|
-
|
60
|
-
file
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
59
|
+
'CONFIG_BATCH_EVENT_LIMIT_EXCEEDED',
|
60
|
+
{
|
61
|
+
'{file}' => FileNameEnum::BatchEventsDispatcher,
|
62
|
+
'{endPoint}' => url,
|
63
|
+
'{eventsPerRequest}' => impression.length(),
|
64
|
+
'{accountId}' => impression[:a]
|
65
|
+
}
|
65
66
|
)
|
66
67
|
|
67
68
|
@logger.log(
|
68
69
|
LogLevelEnum::ERROR,
|
69
|
-
|
70
|
-
|
71
|
-
file
|
72
|
-
|
73
|
-
|
70
|
+
'IMPRESSION_FAILED',
|
71
|
+
{
|
72
|
+
'{file}' => FileNameEnum::BatchEventsDispatcher,
|
73
|
+
'{err}' => resp.message,
|
74
|
+
'{endPoint}' => url
|
75
|
+
}
|
74
76
|
)
|
75
77
|
message = resp.message
|
76
78
|
else
|
77
79
|
@logger.log(
|
78
|
-
LogLevelEnum::
|
79
|
-
|
80
|
-
|
81
|
-
file: FileNameEnum::BatchEventsDispatcher
|
82
|
-
)
|
80
|
+
LogLevelEnum::INFO,
|
81
|
+
'IMPRESSION_BATCH_FAILED',
|
82
|
+
{'{file}' => FileNameEnum::BatchEventsDispatcher}
|
83
83
|
)
|
84
84
|
|
85
85
|
@logger.log(
|
86
86
|
LogLevelEnum::ERROR,
|
87
|
-
|
87
|
+
'IMPRESSION_FAILED',
|
88
|
+
{
|
89
|
+
'{file}' => FileNameEnum::BatchEventsDispatcher,
|
90
|
+
'{err}' => resp.message,
|
91
|
+
'{endPoint}' => url
|
92
|
+
}
|
88
93
|
)
|
89
94
|
message = resp.message
|
90
95
|
end
|
91
96
|
if callback
|
92
97
|
callback.call(message, impression)
|
93
98
|
end
|
99
|
+
true
|
94
100
|
rescue StandardError => e
|
95
101
|
@logger.log(
|
96
102
|
LogLevelEnum::DEBUG,
|
97
|
-
|
98
|
-
|
99
|
-
file: FileNameEnum::BatchEventsDispatcher
|
100
|
-
)
|
103
|
+
'IMPRESSION_BATCH_FAILED',
|
104
|
+
{'{file}' => FileNameEnum::BatchEventsDispatcher}
|
101
105
|
)
|
102
106
|
|
103
107
|
@logger.log(
|
104
|
-
|
105
|
-
|
106
|
-
|
108
|
+
LogLevelEnum::ERROR,
|
109
|
+
'IMPRESSION_FAILED',
|
110
|
+
{
|
111
|
+
'{file}' => FileNameEnum::BatchEventsDispatcher,
|
112
|
+
'{err}' => e.message,
|
113
|
+
'{endPoint}' => url
|
114
|
+
}
|
115
|
+
)
|
107
116
|
false
|
108
117
|
end
|
109
118
|
|
@@ -12,9 +12,9 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
require_relative '../logger'
|
16
15
|
require_relative '../enums'
|
17
16
|
require_relative '../utils/request'
|
17
|
+
require_relative '../utils/log_message'
|
18
18
|
|
19
19
|
class VWO
|
20
20
|
module Services
|
@@ -23,7 +23,7 @@ class VWO
|
|
23
23
|
|
24
24
|
def initialize(batch_config, is_development_mode = false)
|
25
25
|
@is_development_mode = is_development_mode
|
26
|
-
@logger = VWO::Logger
|
26
|
+
@logger = VWO::Utils::Logger
|
27
27
|
@queue = []
|
28
28
|
@queue_metadata = {}
|
29
29
|
@batch_config = batch_config
|
@@ -33,12 +33,13 @@ class VWO
|
|
33
33
|
else
|
34
34
|
@request_time_interval = CONSTANTS::DEFAULT_REQUEST_TIME_INTERVAL
|
35
35
|
@logger.log(
|
36
|
-
LogLevelEnum::
|
37
|
-
|
38
|
-
|
39
|
-
file
|
40
|
-
|
41
|
-
|
36
|
+
LogLevelEnum::INFO,
|
37
|
+
'EVENT_BATCH_DEFAULTS',
|
38
|
+
{
|
39
|
+
'{file}' => FileNameEnum::BatchEventsQueue,
|
40
|
+
'{parameter}' => 'request_time_interval',
|
41
|
+
'{defaultValue}' => @request_time_interval.to_s + ' ms'
|
42
|
+
}
|
42
43
|
)
|
43
44
|
end
|
44
45
|
|
@@ -47,12 +48,13 @@ class VWO
|
|
47
48
|
else
|
48
49
|
@events_per_request = CONSTANTS::DEFAULT_EVENTS_PER_REQUEST
|
49
50
|
@logger.log(
|
50
|
-
LogLevelEnum::
|
51
|
-
|
52
|
-
|
53
|
-
file
|
54
|
-
|
55
|
-
|
51
|
+
LogLevelEnum::INFO,
|
52
|
+
'EVENT_BATCH_DEFAULTS',
|
53
|
+
{
|
54
|
+
'{file}' => FileNameEnum::BatchEventsQueue,
|
55
|
+
'{parameter}' => 'events_per_request',
|
56
|
+
'{defaultValue}' => @events_per_request.to_s
|
57
|
+
}
|
56
58
|
)
|
57
59
|
end
|
58
60
|
|
@@ -94,36 +96,34 @@ class VWO
|
|
94
96
|
if @queue.length() > 0
|
95
97
|
@logger.log(
|
96
98
|
LogLevelEnum::DEBUG,
|
97
|
-
|
98
|
-
|
99
|
-
file
|
100
|
-
manually
|
101
|
-
length
|
102
|
-
timer
|
103
|
-
|
104
|
-
|
99
|
+
'EVENT_BATCH_BEFORE_FLUSHING',
|
100
|
+
{
|
101
|
+
'{file}' => FileNameEnum::BatchEventsQueue,
|
102
|
+
'{manually}' => manual ? 'manually' : '',
|
103
|
+
'{length}' => @queue.length(),
|
104
|
+
'{timer}' => manual ? 'Timer will be cleared and registered again,' : '',
|
105
|
+
'{accountId}' => @batch_config[:account_id]
|
106
|
+
}
|
105
107
|
)
|
106
108
|
|
107
109
|
@dispatcher.call(@queue, @flush_callback)
|
110
|
+
|
108
111
|
@logger.log(
|
109
112
|
LogLevelEnum::INFO,
|
110
|
-
|
111
|
-
|
112
|
-
file
|
113
|
-
manually
|
114
|
-
length
|
115
|
-
|
116
|
-
)
|
113
|
+
'EVENT_BATCH_After_FLUSHING',
|
114
|
+
{
|
115
|
+
'{file}' => FileNameEnum::BatchEventsQueue,
|
116
|
+
'{manually}' => manual ? 'manually,' : '',
|
117
|
+
'{length}' => @queue.length()
|
118
|
+
}
|
117
119
|
)
|
118
120
|
@queue_metadata = {}
|
119
121
|
@queue = []
|
120
122
|
else
|
121
123
|
@logger.log(
|
122
124
|
LogLevelEnum::INFO,
|
123
|
-
|
124
|
-
|
125
|
-
file: FILE
|
126
|
-
)
|
125
|
+
'Batch queue is empty. Nothing to flush.',
|
126
|
+
{'{file}' => FILE}
|
127
127
|
)
|
128
128
|
end
|
129
129
|
|
@@ -12,10 +12,10 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
require_relative '../logger'
|
16
15
|
require_relative '../enums'
|
17
16
|
require_relative '../utils/request'
|
18
17
|
require_relative '../utils/utility'
|
18
|
+
require_relative '../utils/log_message'
|
19
19
|
require_relative '../constants'
|
20
20
|
|
21
21
|
class VWO
|
@@ -33,7 +33,7 @@ class VWO
|
|
33
33
|
# to our server should be made or not.
|
34
34
|
#
|
35
35
|
def initialize(is_development_mode = false)
|
36
|
-
@logger = VWO::Logger
|
36
|
+
@logger = VWO::Utils::Logger
|
37
37
|
@is_development_mode = is_development_mode
|
38
38
|
end
|
39
39
|
|
@@ -56,15 +56,25 @@ class VWO
|
|
56
56
|
else
|
57
57
|
@logger.log(
|
58
58
|
LogLevelEnum::ERROR,
|
59
|
-
|
59
|
+
'IMPRESSION_FAILED',
|
60
|
+
{
|
61
|
+
'{file}' => FileNameEnum::BatchEventsDispatcher,
|
62
|
+
'{err}' => resp.message,
|
63
|
+
'{endPoint}' => impression['url']
|
64
|
+
}
|
60
65
|
)
|
61
66
|
false
|
62
67
|
end
|
63
|
-
rescue StandardError
|
68
|
+
rescue StandardError => e
|
64
69
|
@logger.log(
|
65
|
-
|
66
|
-
|
67
|
-
|
70
|
+
LogLevelEnum::ERROR,
|
71
|
+
'IMPRESSION_FAILED',
|
72
|
+
{
|
73
|
+
'{file}' => FileNameEnum::BatchEventsDispatcher,
|
74
|
+
'{err}' => e.message,
|
75
|
+
'{endPoint}' => impression['url']
|
76
|
+
}
|
77
|
+
)
|
68
78
|
false
|
69
79
|
end
|
70
80
|
|
@@ -76,27 +86,37 @@ class VWO
|
|
76
86
|
if resp.code == '200'
|
77
87
|
@logger.log(
|
78
88
|
LogLevelEnum::INFO,
|
79
|
-
|
80
|
-
|
81
|
-
file
|
82
|
-
event
|
83
|
-
|
84
|
-
|
85
|
-
|
89
|
+
'IMPRESSION_SUCCESS_FOR_EVENT_ARCH',
|
90
|
+
{
|
91
|
+
'{file}' => FileNameEnum::BatchEventsDispatcher,
|
92
|
+
'{event}' => 'visitor property:' + JSON.generate(post_data[:d][:visitor][:props]),
|
93
|
+
'{endPoint}' => url,
|
94
|
+
'{accountId}' => params[:a]
|
95
|
+
}
|
86
96
|
)
|
87
97
|
true
|
88
98
|
else
|
89
99
|
@logger.log(
|
90
100
|
LogLevelEnum::ERROR,
|
91
|
-
|
101
|
+
'IMPRESSION_FAILED',
|
102
|
+
{
|
103
|
+
'{file}' => FileNameEnum::EventDispatcher,
|
104
|
+
'{err}' => resp.message,
|
105
|
+
'{endPoint}' => url
|
106
|
+
}
|
92
107
|
)
|
93
108
|
false
|
94
109
|
end
|
95
|
-
rescue StandardError
|
110
|
+
rescue StandardError => e
|
96
111
|
@logger.log(
|
97
|
-
|
98
|
-
|
99
|
-
|
112
|
+
LogLevelEnum::ERROR,
|
113
|
+
'IMPRESSION_FAILED',
|
114
|
+
{
|
115
|
+
'{file}' => FileNameEnum::EventDispatcher,
|
116
|
+
'{err}' => e.message,
|
117
|
+
'{endPoint}' => url
|
118
|
+
}
|
119
|
+
)
|
100
120
|
false
|
101
121
|
end
|
102
122
|
end
|
@@ -12,12 +12,12 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
require_relative '../logger'
|
16
15
|
require_relative '../enums'
|
17
16
|
require_relative './operand_evaluator'
|
18
17
|
require_relative '../utils/function'
|
19
18
|
require_relative '../utils/segment'
|
20
19
|
require_relative '../utils/validations'
|
20
|
+
require_relative '../utils/log_message'
|
21
21
|
|
22
22
|
class VWO
|
23
23
|
module Services
|
@@ -29,7 +29,7 @@ class VWO
|
|
29
29
|
|
30
30
|
# Initializes this class with VWOLogger and OperandEvaluator
|
31
31
|
def initialize
|
32
|
-
@logger = VWO::Logger
|
32
|
+
@logger = VWO::Utils::Logger
|
33
33
|
@operand_evaluator = OperandEvaluator.new
|
34
34
|
end
|
35
35
|
|
@@ -73,14 +73,15 @@ class VWO
|
|
73
73
|
rescue StandardError => e
|
74
74
|
@logger.log(
|
75
75
|
LogLevelEnum::ERROR,
|
76
|
-
|
77
|
-
|
78
|
-
file
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
76
|
+
'SEGMENTATION_ERROR',
|
77
|
+
{
|
78
|
+
'{file}' => FileNameEnum::SegmentEvaluator,
|
79
|
+
'{userId}' => user_id,
|
80
|
+
'{campaignKey}' => campaign_key,
|
81
|
+
'{variation}' => '',
|
82
|
+
'{customVariables}' => custom_variables,
|
83
|
+
'{err}' => e.message
|
84
|
+
},
|
84
85
|
disable_logs
|
85
86
|
)
|
86
87
|
false
|
@@ -12,9 +12,9 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
require_relative '../logger'
|
16
15
|
require_relative '../enums'
|
17
16
|
require_relative '../utils/campaign'
|
17
|
+
require_relative '../utils/log_message'
|
18
18
|
|
19
19
|
class VWO
|
20
20
|
module Services
|
@@ -30,7 +30,6 @@ class VWO
|
|
30
30
|
|
31
31
|
def initialize(settings_file)
|
32
32
|
@settings_file = JSON.parse(settings_file)
|
33
|
-
@logger = VWO::Logger.get_instance
|
34
33
|
end
|
35
34
|
|
36
35
|
# Processes the settings_file, assigns variation allocation range
|
@@ -38,9 +37,13 @@ class VWO
|
|
38
37
|
(@settings_file['campaigns'] || []).each do |campaign|
|
39
38
|
set_variation_allocation(campaign)
|
40
39
|
end
|
41
|
-
|
40
|
+
Utils::Logger.log(
|
42
41
|
LogLevelEnum::DEBUG,
|
43
|
-
|
42
|
+
'SETTINGS_FILE_PROCESSED',
|
43
|
+
{
|
44
|
+
'{file}' => FileNameEnum::SettingsFileProcessor,
|
45
|
+
'{accountId}' => @settings_file['accountId']
|
46
|
+
}
|
44
47
|
)
|
45
48
|
end
|
46
49
|
|