vwo-sdk 1.16.0 → 1.23.2
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 +33 -5
- data/lib/vwo/core/variation_decider.rb +421 -132
- data/lib/vwo/enums.rb +11 -6
- data/lib/vwo/logger.rb +4 -2
- data/lib/vwo/schemas/settings_file.rb +4 -0
- data/lib/vwo/services/operand_evaluator.rb +2 -3
- data/lib/vwo/services/segment_evaluator.rb +4 -2
- data/lib/vwo/services/settings_file_manager.rb +3 -1
- data/lib/vwo/utils/campaign.rb +58 -0
- data/lib/vwo/utils/custom_dimensions.rb +3 -1
- data/lib/vwo/utils/impression.rb +4 -2
- data/lib/vwo/utils/utility.rb +46 -0
- data/lib/vwo.rb +89 -82
- metadata +3 -2
data/lib/vwo/enums.rb
CHANGED
@@ -106,13 +106,14 @@ class VWO
|
|
106
106
|
IMPRESSION_FOR_TRACK_USER = '(%<file>s): Impression built for track-user - %<properties>s'
|
107
107
|
IMPRESSION_FOR_TRACK_GOAL = '(%<file>s): Impression built for track-goal - %<properties>s'
|
108
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
|
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
110
|
PARAMS_FOR_PUSH_CALL = '(%<file>s): Params for push call - %<properties>s'
|
111
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
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
113
|
BULK_NOT_PROCESSED = "(%<file>s): Batch events couldn't be received by VWO. Calling Flush Callback with error and data."
|
114
114
|
BEFORE_FLUSHING = '(%<file>s): Flushing events queue %<manually>s having %<length>s events %<timer>s queue summary: %<queue_metadata>s'
|
115
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"
|
116
117
|
end
|
117
118
|
|
118
119
|
# Info Messages
|
@@ -127,9 +128,9 @@ class VWO
|
|
127
128
|
AUDIENCE_CONDITION_NOT_MET = '(%<file>s): userId:%<user_id>s does not become part of campaign because of not meeting audience conditions'
|
128
129
|
GOT_VARIATION_FOR_USER = '(%<file>s): userId:%<user_id>s for campaign:%<campaign_key>s got variationName:%<variation_name>s'
|
129
130
|
USER_GOT_NO_VARIATION = '(%<file>s): userId:%<user_id>s for campaign:%<campaign_key>s did not allot any variation'
|
130
|
-
IMPRESSION_SUCCESS = '(%<file>s): Impression event - %<end_point>s was successfully received by VWO having main keys:
|
131
|
-
MAIN_KEYS_FOR_IMPRESSION = '(%<file>s): Having main keys:
|
132
|
-
MAIN_KEYS_FOR_PUSH_API = '(%<file>s): Having main keys:
|
131
|
+
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'
|
132
|
+
MAIN_KEYS_FOR_IMPRESSION = '(%<file>s): Having main keys: accountId:%<account_id>s campaignId:%<campaign_id>s and variationId:%<variation_id>s}'
|
133
|
+
MAIN_KEYS_FOR_PUSH_API = '(%<file>s): Having main keys: accountId:%<account_id>s u:%<u>s and tags:%<tags>s}'
|
133
134
|
INVALID_VARIATION_KEY = '(%<file>s): Variation was not assigned to userId:%<user_id>s for campaign:%<campaign_key>s'
|
134
135
|
|
135
136
|
USER_IN_FEATURE_ROLLOUT = '(%<file>s): User ID:%<user_id>s is in feature rollout:%<campaign_key>s'
|
@@ -142,7 +143,7 @@ class VWO
|
|
142
143
|
USER_PASSED_SEGMENTATION = '(%<file>s): UserId:%<user_id>s of campaign:%<campaign_key>s with custom_variables:%<custom_variables>s passed segmentation'
|
143
144
|
USER_FAILED_SEGMENTATION = '(%<file>s): UserId:%<user_id>s of campaign:%<campaign_key>s with custom_variables:%<custom_variables>s failed segmentation'
|
144
145
|
|
145
|
-
NO_CUSTOM_VARIABLES = '(%<file>s): In API: %<api_name>s, for UserId:%<user_id>s
|
146
|
+
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'
|
146
147
|
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'
|
147
148
|
|
148
149
|
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'
|
@@ -152,9 +153,13 @@ class VWO
|
|
152
153
|
CAMPAIGN_NOT_ACTIVATED = '(%<file>s): Activate the campaign:%<campaign_key>s for User ID:%<user_id>s to %<reason>s.'
|
153
154
|
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'
|
154
155
|
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'
|
155
|
-
API_CALLED = '(%<file>s): API:
|
156
|
+
API_CALLED = '(%<file>s): API: %<api_name>s called for UserId:%<user_id>s'
|
156
157
|
BULK_IMPRESSION_SUCCESS = '(%<file>s): Impression event - %<end_point>s was successfully received by VWO having accountId:%<a>s'
|
157
158
|
AFTER_FLUSHING = '(%<file>s): Events queue having %<length>s events has been flushed %<manually>s queue summary: %<queue_metadata>s'
|
159
|
+
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"
|
160
|
+
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"
|
161
|
+
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"
|
162
|
+
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"
|
158
163
|
end
|
159
164
|
|
160
165
|
# Warning Messages
|
data/lib/vwo/logger.rb
CHANGED
@@ -28,8 +28,10 @@ class VWO
|
|
28
28
|
end
|
29
29
|
|
30
30
|
# Override this method to handle logs in a custom manner
|
31
|
-
def log(level, message)
|
32
|
-
|
31
|
+
def log(level, message, disable_logs = false)
|
32
|
+
unless disable_logs
|
33
|
+
@@logger_instance.log(level, message)
|
34
|
+
end
|
33
35
|
end
|
34
36
|
|
35
37
|
def instance
|
@@ -73,6 +73,9 @@ class VWO
|
|
73
73
|
key: {
|
74
74
|
type: ['string']
|
75
75
|
},
|
76
|
+
name: {
|
77
|
+
type: ['string']
|
78
|
+
},
|
76
79
|
status: {
|
77
80
|
type: ['string']
|
78
81
|
},
|
@@ -91,6 +94,7 @@ class VWO
|
|
91
94
|
'$ref' => '#/definitions/variables_schema'
|
92
95
|
}
|
93
96
|
},
|
97
|
+
isBucketingSeedEnabled: ['boolean'],
|
94
98
|
minItems: 2
|
95
99
|
}
|
96
100
|
},
|
@@ -91,11 +91,10 @@ class VWO
|
|
91
91
|
# @return [Boolean]
|
92
92
|
def evaluate_custom_variable?(operand, custom_variables)
|
93
93
|
# Extract custom_variable_key and custom_variables_value from operand
|
94
|
-
|
95
94
|
operand_key, operand = get_key_value(operand)
|
96
95
|
|
97
96
|
# Retrieve corresponding custom_variable value from custom_variables
|
98
|
-
custom_variables_value = custom_variables[operand_key]
|
97
|
+
custom_variables_value = custom_variables[operand_key.to_sym]
|
99
98
|
|
100
99
|
# Pre process custom_variable value
|
101
100
|
custom_variables_value = process_custom_variables_value(custom_variables_value)
|
@@ -113,7 +112,7 @@ class VWO
|
|
113
112
|
def evaluate_user?(operand, custom_variables)
|
114
113
|
users = operand.split(',')
|
115
114
|
users.each do |user|
|
116
|
-
return true if user.strip == custom_variables[
|
115
|
+
return true if user.strip == custom_variables[:_vwo_user_id]
|
117
116
|
end
|
118
117
|
false
|
119
118
|
end
|
@@ -63,10 +63,11 @@ class VWO
|
|
63
63
|
# @param[String] :user_id Unique user identifier
|
64
64
|
# @param[Hash] :dsl Segments provided in the settings_file
|
65
65
|
# @param[Hash] :custom_variables Custom variables provided in the apis
|
66
|
+
# @param[Boolean] :disable_logs disable logs if True
|
66
67
|
#
|
67
68
|
# @return[Boolean] true if user passed pre-segmentation, else false
|
68
69
|
#
|
69
|
-
def evaluate(campaign_key, user_id, dsl, custom_variables)
|
70
|
+
def evaluate(campaign_key, user_id, dsl, custom_variables, disable_logs = false)
|
70
71
|
result = evaluate_util(dsl, custom_variables) if valid_value?(dsl)
|
71
72
|
result
|
72
73
|
rescue StandardError => e
|
@@ -79,7 +80,8 @@ class VWO
|
|
79
80
|
campaign_key: campaign_key,
|
80
81
|
custom_variables: custom_variables,
|
81
82
|
error_message: e
|
82
|
-
)
|
83
|
+
),
|
84
|
+
disable_logs
|
83
85
|
)
|
84
86
|
false
|
85
87
|
end
|
data/lib/vwo/utils/campaign.rb
CHANGED
@@ -57,6 +57,26 @@ class VWO
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
+
# Sets campaign allocation range in the provided campaigns list
|
61
|
+
#
|
62
|
+
# @param [Array]: Array of Campaigns
|
63
|
+
def set_campaign_allocation(campaigns)
|
64
|
+
current_allocation = 0
|
65
|
+
campaigns.each do |campaign|
|
66
|
+
step_factor = get_variation_bucketing_range(campaign['weight'])
|
67
|
+
if step_factor > 0
|
68
|
+
start_range = current_allocation + 1
|
69
|
+
end_range = current_allocation + step_factor
|
70
|
+
campaign['min_range'] = start_range
|
71
|
+
campaign['max_range'] = end_range
|
72
|
+
current_allocation += step_factor
|
73
|
+
else
|
74
|
+
campaign['min_range'] = -1
|
75
|
+
campaign['max_range'] = -1
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
60
80
|
# Returns goal from given campaign_key and gaol_identifier.
|
61
81
|
# @param[String] :campaign Campaign object
|
62
82
|
# @param[String] :goal_identifier Goal identifier
|
@@ -249,6 +269,44 @@ class VWO
|
|
249
269
|
return campaign
|
250
270
|
end
|
251
271
|
|
272
|
+
# Checks whether a campaign is part of a group.
|
273
|
+
#
|
274
|
+
# @param[Hash] :settings_file Settings file for the project
|
275
|
+
# @param[Integer] :campaign_id Id of campaign which is to be checked
|
276
|
+
# @return[Boolean]
|
277
|
+
def is_part_of_group(settings_file, campaign_id)
|
278
|
+
if settings_file["campaignGroups"] && (settings_file["campaignGroups"].has_key?(campaign_id.to_s))
|
279
|
+
return true
|
280
|
+
end
|
281
|
+
false
|
282
|
+
end
|
283
|
+
|
284
|
+
# Returns campaigns which are part of given group using group_id.
|
285
|
+
#
|
286
|
+
# @param[Hash] :settings_file Settings file for the project
|
287
|
+
# @param[Integer] :group_id id of group whose campaigns are to be return
|
288
|
+
# @return[Array]
|
289
|
+
def get_group_campaigns(settings_file, group_id)
|
290
|
+
group_campaign_ids = []
|
291
|
+
group_campaigns = []
|
292
|
+
groups = settings_file["groups"]
|
293
|
+
|
294
|
+
if groups && groups.has_key?(group_id.to_s)
|
295
|
+
group_campaign_ids = groups[group_id.to_s]["campaigns"]
|
296
|
+
end
|
297
|
+
|
298
|
+
if group_campaign_ids
|
299
|
+
group_campaign_ids.each do |campaign_id|
|
300
|
+
settings_file["campaigns"].each do |campaign|
|
301
|
+
if campaign["id"] == campaign_id && campaign["status"] == STATUS_RUNNING
|
302
|
+
group_campaigns.push(campaign)
|
303
|
+
end
|
304
|
+
end
|
305
|
+
end
|
306
|
+
end
|
307
|
+
group_campaigns
|
308
|
+
end
|
309
|
+
|
252
310
|
end
|
253
311
|
end
|
254
312
|
end
|
@@ -17,6 +17,7 @@ require_relative '../logger'
|
|
17
17
|
require_relative '../enums'
|
18
18
|
require_relative '../constants'
|
19
19
|
require_relative './impression'
|
20
|
+
require_relative './utility'
|
20
21
|
|
21
22
|
# Utility module for helper math and random functions
|
22
23
|
class VWO
|
@@ -25,6 +26,7 @@ class VWO
|
|
25
26
|
include VWO::CONSTANTS
|
26
27
|
include VWO::Enums
|
27
28
|
include VWO::Utils::Impression
|
29
|
+
include VWO::Utils::Utility
|
28
30
|
|
29
31
|
def get_url_params(settings_file, tag_key, tag_value, user_id, sdk_key)
|
30
32
|
url = HTTPS_PROTOCOL + ENDPOINTS::BASE_URL + ENDPOINTS::PUSH
|
@@ -39,7 +41,7 @@ class VWO
|
|
39
41
|
format(
|
40
42
|
LogMessageEnum::DebugMessages::PARAMS_FOR_PUSH_CALL,
|
41
43
|
file: FileNameEnum::CustomDimensionsUtil,
|
42
|
-
properties:
|
44
|
+
properties: remove_sensitive_properties(params)
|
43
45
|
)
|
44
46
|
)
|
45
47
|
params
|
data/lib/vwo/utils/impression.rb
CHANGED
@@ -19,6 +19,7 @@ require_relative '../enums'
|
|
19
19
|
require_relative '../constants'
|
20
20
|
require_relative 'function'
|
21
21
|
require_relative 'uuid'
|
22
|
+
require_relative 'utility'
|
22
23
|
|
23
24
|
# Creates the impression from the arguments passed
|
24
25
|
class VWO
|
@@ -28,6 +29,7 @@ class VWO
|
|
28
29
|
include VWO::CONSTANTS
|
29
30
|
include VWO::Utils::Function
|
30
31
|
include UUID
|
32
|
+
include VWO::Utils::Utility
|
31
33
|
|
32
34
|
# Creates the impression from the arguments passed
|
33
35
|
#
|
@@ -76,7 +78,7 @@ class VWO
|
|
76
78
|
format(
|
77
79
|
LogMessageEnum::DebugMessages::IMPRESSION_FOR_TRACK_USER,
|
78
80
|
file: FileNameEnum::ImpressionUtil,
|
79
|
-
properties:
|
81
|
+
properties: remove_sensitive_properties(impression)
|
80
82
|
)
|
81
83
|
)
|
82
84
|
else
|
@@ -88,7 +90,7 @@ class VWO
|
|
88
90
|
format(
|
89
91
|
LogMessageEnum::DebugMessages::IMPRESSION_FOR_TRACK_GOAL,
|
90
92
|
file: FileNameEnum::ImpressionUtil,
|
91
|
-
properties:
|
93
|
+
properties: remove_sensitive_properties(impression)
|
92
94
|
)
|
93
95
|
)
|
94
96
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# Copyright 2019-2021 Wingify Software Pvt. Ltd.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require 'json'
|
16
|
+
require_relative './validations'
|
17
|
+
|
18
|
+
# Generic utility module
|
19
|
+
class VWO
|
20
|
+
module Utils
|
21
|
+
module Utility
|
22
|
+
include Validations
|
23
|
+
|
24
|
+
# converting hash with keys as strings into hash with keys as strings
|
25
|
+
# @param[Hash]
|
26
|
+
# @return[Hash]
|
27
|
+
def convert_to_symbol_hash(hashObject)
|
28
|
+
convertedHash = {}
|
29
|
+
hashObject.each do |key, value|
|
30
|
+
if valid_hash?(value)
|
31
|
+
convertedHash[key.to_sym] = convert_to_symbol_hash(value)
|
32
|
+
else
|
33
|
+
convertedHash[key.to_sym] = value
|
34
|
+
end
|
35
|
+
end
|
36
|
+
convertedHash
|
37
|
+
end
|
38
|
+
|
39
|
+
def remove_sensitive_properties(properties)
|
40
|
+
properties.delete("env")
|
41
|
+
properties.delete("env".to_sym)
|
42
|
+
JSON.generate(properties)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/vwo.rb
CHANGED
@@ -23,6 +23,7 @@ require_relative 'vwo/utils/campaign'
|
|
23
23
|
require_relative 'vwo/utils/impression'
|
24
24
|
require_relative 'vwo/utils/feature'
|
25
25
|
require_relative 'vwo/utils/custom_dimensions'
|
26
|
+
require_relative 'vwo/utils/utility'
|
26
27
|
require_relative 'vwo/constants'
|
27
28
|
require_relative 'vwo/core/variation_decider'
|
28
29
|
require_relative 'vwo/services/batch_events_dispatcher'
|
@@ -39,6 +40,7 @@ class VWO
|
|
39
40
|
include Utils::CustomDimensions
|
40
41
|
include Utils::Campaign
|
41
42
|
include Utils::Impression
|
43
|
+
include Utils::Utility
|
42
44
|
include CONSTANTS
|
43
45
|
|
44
46
|
FILE = FileNameEnum::VWO
|
@@ -62,6 +64,7 @@ class VWO
|
|
62
64
|
settings_file = nil,
|
63
65
|
options = {}
|
64
66
|
)
|
67
|
+
options = convert_to_symbol_hash(options)
|
65
68
|
@account_id = account_id
|
66
69
|
@sdk_key = sdk_key
|
67
70
|
@user_storage = user_storage
|
@@ -295,9 +298,10 @@ class VWO
|
|
295
298
|
return
|
296
299
|
end
|
297
300
|
|
301
|
+
options = convert_to_symbol_hash(options)
|
298
302
|
# Retrieve custom variables
|
299
|
-
custom_variables = options[
|
300
|
-
variation_targeting_variables = options[
|
303
|
+
custom_variables = options[:custom_variables]
|
304
|
+
variation_targeting_variables = options[:variation_targeting_variables]
|
301
305
|
|
302
306
|
should_track_returning_user = get_should_track_returning_user(options)
|
303
307
|
# Validate input parameters
|
@@ -404,7 +408,6 @@ class VWO
|
|
404
408
|
format(
|
405
409
|
LogMessageEnum::InfoMessages::IMPRESSION_SUCCESS,
|
406
410
|
file: FILE,
|
407
|
-
sdk_key: @sdk_key,
|
408
411
|
account_id: @account_id,
|
409
412
|
campaign_id: campaign['id'],
|
410
413
|
variation_id: variation['id'],
|
@@ -413,7 +416,6 @@ class VWO
|
|
413
416
|
)
|
414
417
|
end
|
415
418
|
end
|
416
|
-
variation['name']
|
417
419
|
else
|
418
420
|
@logger.log(
|
419
421
|
LogLevelEnum::INFO,
|
@@ -425,8 +427,8 @@ class VWO
|
|
425
427
|
api_name: ApiMethods::ACTIVATE
|
426
428
|
)
|
427
429
|
)
|
428
|
-
nil
|
429
430
|
end
|
431
|
+
variation['name']
|
430
432
|
rescue StandardError => e
|
431
433
|
@logger.log(
|
432
434
|
LogLevelEnum::ERROR,
|
@@ -469,9 +471,10 @@ class VWO
|
|
469
471
|
)
|
470
472
|
return
|
471
473
|
end
|
474
|
+
options = convert_to_symbol_hash(options)
|
472
475
|
# Retrieve custom variables
|
473
|
-
custom_variables = options[
|
474
|
-
variation_targeting_variables = options[
|
476
|
+
custom_variables = options[:custom_variables]
|
477
|
+
variation_targeting_variables = options[:variation_targeting_variables]
|
475
478
|
|
476
479
|
# Validate input parameters
|
477
480
|
unless valid_string?(campaign_key) && valid_string?(user_id) && (custom_variables.nil? || valid_hash?(custom_variables)) &&
|
@@ -580,9 +583,10 @@ class VWO
|
|
580
583
|
return false
|
581
584
|
end
|
582
585
|
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
+
options = convert_to_symbol_hash(options)
|
587
|
+
revenue_value = options[:revenue_value]
|
588
|
+
custom_variables = options[:custom_variables]
|
589
|
+
variation_targeting_variables = options[:variation_targeting_variables]
|
586
590
|
should_track_returning_user = get_should_track_returning_user(options)
|
587
591
|
goal_type_to_track = get_goal_type_to_track(options)
|
588
592
|
|
@@ -676,7 +680,7 @@ class VWO
|
|
676
680
|
if !identifiers.include? goal_identifier
|
677
681
|
updated_goal_identifier = variation['goal_identifier']
|
678
682
|
updated_goal_identifier += VWO_DELIMITER + goal_identifier
|
679
|
-
@variation_decider.save_user_storage(user_id, campaign['key'], variation['name'], updated_goal_identifier) if variation['name']
|
683
|
+
@variation_decider.save_user_storage(user_id, campaign['key'], campaign['name'], variation['name'], updated_goal_identifier) if variation['name']
|
680
684
|
# set variation at user storage
|
681
685
|
elsif !should_track_returning_user
|
682
686
|
@logger.log(
|
@@ -720,7 +724,6 @@ class VWO
|
|
720
724
|
format(
|
721
725
|
LogMessageEnum::InfoMessages::IMPRESSION_SUCCESS,
|
722
726
|
file: FILE,
|
723
|
-
sdk_key: @sdk_key,
|
724
727
|
account_id: @account_id,
|
725
728
|
campaign_id: campaign['id'],
|
726
729
|
variation_id: variation['id'],
|
@@ -732,7 +735,6 @@ class VWO
|
|
732
735
|
format(
|
733
736
|
LogMessageEnum::InfoMessages::MAIN_KEYS_FOR_IMPRESSION,
|
734
737
|
file: FILE,
|
735
|
-
sdk_key: @sdk_key,
|
736
738
|
campaign_id: impression[:experiment_id],
|
737
739
|
account_id: impression[:account_id],
|
738
740
|
variation_id: impression[:combination]
|
@@ -800,9 +802,10 @@ class VWO
|
|
800
802
|
return false
|
801
803
|
end
|
802
804
|
|
805
|
+
options = convert_to_symbol_hash(options)
|
803
806
|
# Retrieve custom variables
|
804
|
-
custom_variables = options[
|
805
|
-
variation_targeting_variables = options[
|
807
|
+
custom_variables = options[:custom_variables]
|
808
|
+
variation_targeting_variables = options[:variation_targeting_variables]
|
806
809
|
should_track_returning_user = get_should_track_returning_user(options)
|
807
810
|
@logger.log(
|
808
811
|
LogLevelEnum::INFO,
|
@@ -870,80 +873,84 @@ class VWO
|
|
870
873
|
return false unless variation
|
871
874
|
|
872
875
|
# if campaign type is feature_test Send track call to server
|
873
|
-
if campaign_type == CampaignTypes::FEATURE_TEST
|
874
|
-
if is_eligible_to_send_impression(should_track_returning_user)
|
875
|
-
if defined?(@batch_events)
|
876
|
-
impression = create_bulk_event_impression(
|
877
|
-
@settings_file,
|
878
|
-
campaign['id'],
|
879
|
-
variation['id'],
|
880
|
-
user_id
|
881
|
-
)
|
882
|
-
@batch_events_queue.enqueue(impression)
|
883
|
-
else
|
884
|
-
impression = create_impression(
|
885
|
-
@settings_file,
|
886
|
-
campaign['id'],
|
887
|
-
variation['id'],
|
888
|
-
user_id,
|
889
|
-
@sdk_key,
|
890
|
-
goal_id: nil,
|
891
|
-
revenue: nil,
|
892
|
-
usage_stats: @usage_stats.usage_stats
|
893
|
-
)
|
894
876
|
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
variation_id: impression[:combination]
|
905
|
-
)
|
906
|
-
)
|
907
|
-
end
|
908
|
-
result = variation['isFeatureEnabled']
|
909
|
-
if result
|
910
|
-
@logger.log(
|
911
|
-
LogLevelEnum::INFO,
|
912
|
-
format(
|
913
|
-
LogMessageEnum::InfoMessages::FEATURE_ENABLED_FOR_USER,
|
914
|
-
file: FILE,
|
915
|
-
user_id: user_id,
|
916
|
-
feature_key: campaign_key,
|
917
|
-
api_name: ApiMethods::IS_FEATURE_ENABLED
|
918
|
-
)
|
919
|
-
)
|
920
|
-
else
|
921
|
-
@logger.log(
|
922
|
-
LogLevelEnum::INFO,
|
923
|
-
format(
|
924
|
-
LogMessageEnum::InfoMessages::FEATURE_NOT_ENABLED_FOR_USER,
|
925
|
-
file: FILE,
|
926
|
-
user_id: user_id,
|
927
|
-
feature_key: campaign_key,
|
928
|
-
api_name: ApiMethods::IS_FEATURE_ENABLED
|
929
|
-
)
|
930
|
-
)
|
931
|
-
end
|
932
|
-
return result
|
877
|
+
if is_eligible_to_send_impression(should_track_returning_user)
|
878
|
+
if defined?(@batch_events)
|
879
|
+
impression = create_bulk_event_impression(
|
880
|
+
@settings_file,
|
881
|
+
campaign['id'],
|
882
|
+
variation['id'],
|
883
|
+
user_id
|
884
|
+
)
|
885
|
+
@batch_events_queue.enqueue(impression)
|
933
886
|
else
|
887
|
+
impression = create_impression(
|
888
|
+
@settings_file,
|
889
|
+
campaign['id'],
|
890
|
+
variation['id'],
|
891
|
+
user_id,
|
892
|
+
@sdk_key,
|
893
|
+
nil,
|
894
|
+
nil,
|
895
|
+
usage_stats: @usage_stats.usage_stats
|
896
|
+
)
|
897
|
+
|
898
|
+
@event_dispatcher.dispatch(impression)
|
934
899
|
@logger.log(
|
935
900
|
LogLevelEnum::INFO,
|
936
901
|
format(
|
937
|
-
LogMessageEnum::InfoMessages::
|
902
|
+
LogMessageEnum::InfoMessages::MAIN_KEYS_FOR_IMPRESSION,
|
938
903
|
file: FILE,
|
939
|
-
|
940
|
-
|
941
|
-
|
904
|
+
campaign_id: impression[:experiment_id],
|
905
|
+
account_id: impression[:account_id],
|
906
|
+
variation_id: impression[:combination]
|
942
907
|
)
|
943
908
|
)
|
944
909
|
end
|
910
|
+
|
911
|
+
else
|
912
|
+
@logger.log(
|
913
|
+
LogLevelEnum::INFO,
|
914
|
+
format(
|
915
|
+
LogMessageEnum::InfoMessages::USER_ALREADY_TRACKED,
|
916
|
+
file: FILE,
|
917
|
+
user_id: user_id,
|
918
|
+
campaign_key: campaign_key,
|
919
|
+
api_name: ApiMethods::IS_FEATURE_ENABLED
|
920
|
+
)
|
921
|
+
)
|
945
922
|
end
|
946
|
-
|
923
|
+
if campaign_type == CampaignTypes::FEATURE_ROLLOUT
|
924
|
+
result = true
|
925
|
+
else
|
926
|
+
result = variation['isFeatureEnabled']
|
927
|
+
end
|
928
|
+
|
929
|
+
if result
|
930
|
+
@logger.log(
|
931
|
+
LogLevelEnum::INFO,
|
932
|
+
format(
|
933
|
+
LogMessageEnum::InfoMessages::FEATURE_ENABLED_FOR_USER,
|
934
|
+
file: FILE,
|
935
|
+
user_id: user_id,
|
936
|
+
feature_key: campaign_key,
|
937
|
+
api_name: ApiMethods::IS_FEATURE_ENABLED
|
938
|
+
)
|
939
|
+
)
|
940
|
+
else
|
941
|
+
@logger.log(
|
942
|
+
LogLevelEnum::INFO,
|
943
|
+
format(
|
944
|
+
LogMessageEnum::InfoMessages::FEATURE_NOT_ENABLED_FOR_USER,
|
945
|
+
file: FILE,
|
946
|
+
user_id: user_id,
|
947
|
+
feature_key: campaign_key,
|
948
|
+
api_name: ApiMethods::IS_FEATURE_ENABLED
|
949
|
+
)
|
950
|
+
)
|
951
|
+
end
|
952
|
+
|
953
|
+
result
|
947
954
|
rescue StandardError => e
|
948
955
|
@logger.log(
|
949
956
|
LogLevelEnum::ERROR,
|
@@ -989,9 +996,10 @@ class VWO
|
|
989
996
|
return
|
990
997
|
end
|
991
998
|
|
999
|
+
options = convert_to_symbol_hash(options)
|
992
1000
|
# Retrieve custom variables
|
993
|
-
custom_variables = options[
|
994
|
-
variation_targeting_variables = options[
|
1001
|
+
custom_variables = options[:custom_variables]
|
1002
|
+
variation_targeting_variables = options[:variation_targeting_variables]
|
995
1003
|
|
996
1004
|
unless valid_string?(campaign_key) && valid_string?(variable_key) && valid_string?(user_id) &&
|
997
1005
|
(custom_variables.nil? || valid_hash?(custom_variables)) && (variation_targeting_variables.nil? || valid_hash?(variation_targeting_variables))
|
@@ -1194,7 +1202,6 @@ class VWO
|
|
1194
1202
|
format(
|
1195
1203
|
LogMessageEnum::InfoMessages::MAIN_KEYS_FOR_PUSH_API,
|
1196
1204
|
file: FILE,
|
1197
|
-
sdk_key: @sdk_key,
|
1198
1205
|
u: impression['u'],
|
1199
1206
|
account_id: impression['account_id'],
|
1200
1207
|
tags: impression['tags']
|
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.23.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- VWO
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: codecov
|
@@ -111,6 +111,7 @@ files:
|
|
111
111
|
- lib/vwo/utils/impression.rb
|
112
112
|
- lib/vwo/utils/request.rb
|
113
113
|
- lib/vwo/utils/segment.rb
|
114
|
+
- lib/vwo/utils/utility.rb
|
114
115
|
- lib/vwo/utils/uuid.rb
|
115
116
|
- lib/vwo/utils/validations.rb
|
116
117
|
homepage: https://vwo.com/fullstack/server-side-testing/
|