vwo-sdk 1.25.0 → 1.29.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4871df5d5a50f01ed13a11692aa6b114f03242f4c9257eccb48bce2a65beaa7c
4
- data.tar.gz: fdd46869b068d589e4a85402d10d8852c4bfc48084e75a18fe8631f3a99b07a9
3
+ metadata.gz: 6441e86fb035c61a71233efc6b806be9e5f9bb0ef7a36e4eb20b1de9ddec7f82
4
+ data.tar.gz: 9e027431282f2fc73d45759590999ce85c3a8745cbedb3725e22da592254ee87
5
5
  SHA512:
6
- metadata.gz: 0c23fe3a4fbcb4c85ef1af73a7ef9bb37a0a79eb4f628bad726f66394291cd93d24cecc066a662799670d10b703265eb3afe72a689ce060a2756eb84d0bfce69
7
- data.tar.gz: f60e3e5a8b96e2ab878929c857d4c8d5c3071e6439e811ac59e7bfa00b488f6c79583ebbfa4a8995a3adac5faf80b7c9293ebea3fa0da231224c684ed39adbb4
6
+ metadata.gz: 04dbb5829f1a23dc90b54ae403f93a6c1b8d9f25fccbcce4f94da401faf218aaf0ad928ea555d064043db06c63ddfa5a6373371ebb7f786cdd6e05ce3866dd2a
7
+ data.tar.gz: e1c2f58fb4150a4b76dfcb0da80c1040cd720e9cb0d94b0a7669ec297cef23f9ab5f1ab67711159a8bbb22ce0a749a04039acc24ff2b5063c98df070f64b4706
data/lib/vwo/constants.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2019-2021 Wingify Software Pvt. Ltd.
1
+ # Copyright 2019-2022 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.
@@ -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.25.0'
30
+ SDK_VERSION = '1.29.0'
31
31
  SDK_NAME = 'ruby'
32
32
  VWO_DELIMITER = '_vwo_'
33
33
  MAX_EVENTS_PER_REQUEST = 5000
@@ -102,6 +102,7 @@ class VWO
102
102
  PUSH = 'push'
103
103
  GET_AND_UPDATE_SETTINGS_FILE = 'get_and_update_settings_file'
104
104
  FLUSH_EVENTS = 'flush_events'
105
+ OPT_OUT = 'opt_out'
105
106
  end
106
107
 
107
108
  module PushApi
@@ -1,4 +1,4 @@
1
- # Copyright 2019-2021 Wingify Software Pvt. Ltd.
1
+ # Copyright 2019-2022 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.
@@ -1,4 +1,4 @@
1
- # Copyright 2019-2021 Wingify Software Pvt. Ltd.
1
+ # Copyright 2019-2022 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.
data/lib/vwo/enums.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2019-2021 Wingify Software Pvt. Ltd.
1
+ # Copyright 2019-2022 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.
@@ -164,6 +164,8 @@ class VWO
164
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
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
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."
167
169
  end
168
170
 
169
171
  # Warning Messages
data/lib/vwo/logger.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2019-2021 Wingify Software Pvt. Ltd.
1
+ # Copyright 2019-2022 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.
@@ -1,4 +1,4 @@
1
- # Copyright 2019-2021 Wingify Software Pvt. Ltd.
1
+ # Copyright 2019-2022 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.
@@ -29,6 +29,9 @@ class VWO
29
29
  isEventArchEnabled: {
30
30
  type: ['boolean']
31
31
  },
32
+ collectionPrefix: {
33
+ type: ['string']
34
+ },
32
35
  campaigns: {
33
36
  if: {
34
37
  type: 'array'
@@ -1,4 +1,4 @@
1
- # Copyright 2019-2021 Wingify Software Pvt. Ltd.
1
+ # Copyright 2019-2022 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.
@@ -15,10 +15,12 @@
15
15
  require_relative '../logger'
16
16
  require_relative '../enums'
17
17
  require_relative '../utils/request'
18
+ require_relative '../utils/utility'
18
19
  class VWO
19
20
  module Services
20
21
  class BatchEventsDispatcher
21
22
  include VWO::Enums
23
+ include VWO::Utils::Utility
22
24
  # Initialize the BatchEventDispatcher with logger and development mode
23
25
  #
24
26
  # @param [Boolean] : To specify whether the request
@@ -36,7 +38,7 @@ class VWO
36
38
  # @return[Boolean]
37
39
  #
38
40
  def dispatch(impression, callback, query_params)
39
- url = CONSTANTS::HTTPS_PROTOCOL + CONSTANTS::ENDPOINTS::BASE_URL + CONSTANTS::ENDPOINTS::BATCH_EVENTS
41
+ url = CONSTANTS::HTTPS_PROTOCOL + get_url(CONSTANTS::ENDPOINTS::BATCH_EVENTS)
40
42
  account_id = query_params[:a]
41
43
  resp = VWO::Utils::Request.post(url, query_params, impression)
42
44
  if resp.code == '200'
@@ -1,4 +1,4 @@
1
- # Copyright 2019-2021 Wingify Software Pvt. Ltd.
1
+ # Copyright 2019-2022 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.
@@ -1,4 +1,4 @@
1
- # Copyright 2019-2021 Wingify Software Pvt. Ltd.
1
+ # Copyright 2019-2022 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.
@@ -15,6 +15,7 @@
15
15
  require_relative '../logger'
16
16
  require_relative '../enums'
17
17
  require_relative '../utils/request'
18
+ require_relative '../utils/utility'
18
19
  require_relative '../constants'
19
20
 
20
21
  class VWO
@@ -22,6 +23,7 @@ class VWO
22
23
  class EventDispatcher
23
24
  include VWO::Enums
24
25
  include VWO::CONSTANTS
26
+ include Utils::Utility
25
27
 
26
28
  EXCLUDE_KEYS = ['url'].freeze
27
29
 
@@ -69,7 +71,7 @@ class VWO
69
71
  def dispatch_event_arch_post(params, post_data)
70
72
  return true if @is_development_mode
71
73
 
72
- url = HTTPS_PROTOCOL + ENDPOINTS::BASE_URL + ENDPOINTS::EVENTS
74
+ url = HTTPS_PROTOCOL + get_url(ENDPOINTS::EVENTS)
73
75
  resp = VWO::Utils::Request.event_post(url, params, post_data, SDK_NAME)
74
76
  if resp.code == '200'
75
77
  @logger.log(
@@ -1,4 +1,4 @@
1
- # Copyright 2019-2021 Wingify Software Pvt. Ltd.
1
+ # Copyright 2019-2022 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.
@@ -1,4 +1,4 @@
1
- # Copyright 2019-2021 Wingify Software Pvt. Ltd.
1
+ # Copyright 2019-2022 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.
@@ -1,4 +1,4 @@
1
- # Copyright 2019-2021 Wingify Software Pvt. Ltd.
1
+ # Copyright 2019-2022 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.
@@ -1,4 +1,4 @@
1
- # Copyright 2019-2021 Wingify Software Pvt. Ltd.
1
+ # Copyright 2019-2022 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.
@@ -1,4 +1,4 @@
1
- # Copyright 2019-2021 Wingify Software Pvt. Ltd.
1
+ # Copyright 2019-2022 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.
@@ -1,4 +1,4 @@
1
- # Copyright 2019-2021 Wingify Software Pvt. Ltd.
1
+ # Copyright 2019-2022 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.
@@ -1,4 +1,4 @@
1
- # Copyright 2019-2021 Wingify Software Pvt. Ltd.
1
+ # Copyright 2019-2022 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.
@@ -1,4 +1,4 @@
1
- # Copyright 2019-2021 Wingify Software Pvt. Ltd.
1
+ # Copyright 2019-2022 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.
@@ -1,4 +1,4 @@
1
- # Copyright 2019-2021 Wingify Software Pvt. Ltd.
1
+ # Copyright 2019-2022 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.
@@ -29,7 +29,7 @@ class VWO
29
29
  include VWO::Utils::Utility
30
30
 
31
31
  def get_url_params(settings_file, tag_key, tag_value, user_id, sdk_key)
32
- url = HTTPS_PROTOCOL + ENDPOINTS::BASE_URL + ENDPOINTS::PUSH
32
+ url = HTTPS_PROTOCOL + get_url(ENDPOINTS::PUSH)
33
33
  tag = { 'u' => {} }
34
34
  tag['u'][tag_key] = tag_value
35
35
 
@@ -0,0 +1,46 @@
1
+ # Copyright 2019-2022 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
+
16
+ require_relative '../constants'
17
+
18
+ # Utility module for generating uuid
19
+ class VWO
20
+ module Utils
21
+ class DataLocationManager
22
+
23
+ @@instance = nil
24
+
25
+ def self.get_instance
26
+ if @@instance.nil?
27
+ @@instance = self.new
28
+ end
29
+ @@instance
30
+ end
31
+
32
+
33
+ def get_data_location
34
+ url = VWO::CONSTANTS::ENDPOINTS::BASE_URL
35
+ if @settings.key?("collectionPrefix")
36
+ url = url + '/' + @settings["collectionPrefix"]
37
+ end
38
+ url
39
+ end
40
+
41
+ def set_settings(settings)
42
+ @settings = settings
43
+ end
44
+ end
45
+ end
46
+ end
@@ -1,4 +1,4 @@
1
- # Copyright 2019-2021 Wingify Software Pvt. Ltd.
1
+ # Copyright 2019-2022 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.
@@ -1,4 +1,4 @@
1
- # Copyright 2019-2021 Wingify Software Pvt. Ltd.
1
+ # Copyright 2019-2022 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.
@@ -1,4 +1,4 @@
1
- # Copyright 2019-2021 Wingify Software Pvt. Ltd.
1
+ # Copyright 2019-2022 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.
@@ -67,12 +67,11 @@ class VWO
67
67
 
68
68
  impression = usage_stats.merge(impression)
69
69
 
70
- url = HTTPS_PROTOCOL + ENDPOINTS::BASE_URL
71
70
  logger = VWO::Logger.get_instance
72
71
 
73
72
  if is_track_user_api
74
73
  impression['ed'] = JSON.generate(p: 'server')
75
- impression['url'] = "#{url}#{ENDPOINTS::TRACK_USER}"
74
+ impression['url'] = HTTPS_PROTOCOL + get_url(ENDPOINTS::TRACK_USER)
76
75
  logger.log(
77
76
  LogLevelEnum::DEBUG,
78
77
  format(
@@ -82,7 +81,7 @@ class VWO
82
81
  )
83
82
  )
84
83
  else
85
- impression['url'] = url + ENDPOINTS::TRACK_GOAL
84
+ impression['url'] = HTTPS_PROTOCOL + get_url(ENDPOINTS::TRACK_GOAL)
86
85
  impression['goal_id'] = goal_id
87
86
  impression['r'] = revenue if revenue
88
87
  logger.log(
@@ -1,4 +1,4 @@
1
- # Copyright 2019-2021 Wingify Software Pvt. Ltd.
1
+ # Copyright 2019-2022 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.
@@ -1,4 +1,4 @@
1
- # Copyright 2019-2021 Wingify Software Pvt. Ltd.
1
+ # Copyright 2019-2022 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.
@@ -1,4 +1,4 @@
1
- # Copyright 2019-2021 Wingify Software Pvt. Ltd.
1
+ # Copyright 2019-2022 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.
@@ -14,17 +14,22 @@
14
14
 
15
15
  require 'json'
16
16
  require_relative './validations'
17
+ require_relative './data_location_manager'
18
+ require_relative '../constants'
17
19
 
18
20
  # Generic utility module
19
21
  class VWO
20
22
  module Utils
21
23
  module Utility
22
24
  include Validations
25
+ include VWO::Utils
26
+ include VWO::CONSTANTS
23
27
 
24
28
  # converting hash with keys as strings into hash with keys as strings
25
29
  # @param[Hash]
26
30
  # @return[Hash]
27
31
  def convert_to_symbol_hash(hashObject)
32
+ hashObject ||= {}
28
33
  convertedHash = {}
29
34
  hashObject.each do |key, value|
30
35
  if valid_hash?(value)
@@ -41,6 +46,10 @@ class VWO
41
46
  properties.delete("env".to_sym)
42
47
  JSON.generate(properties)
43
48
  end
49
+
50
+ def get_url(endpoint)
51
+ return DataLocationManager.get_instance().get_data_location + endpoint
52
+ end
44
53
  end
45
54
  end
46
55
  end
@@ -1,4 +1,4 @@
1
- # Copyright 2019-2021 Wingify Software Pvt. Ltd.
1
+ # Copyright 2019-2022 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.
@@ -1,4 +1,4 @@
1
- # Copyright 2019-2021 Wingify Software Pvt. Ltd.
1
+ # Copyright 2019-2022 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.
data/lib/vwo.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2019-2021 Wingify Software Pvt. Ltd.
1
+ # Copyright 2019-2022 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.
@@ -24,6 +24,7 @@ require_relative 'vwo/utils/impression'
24
24
  require_relative 'vwo/utils/feature'
25
25
  require_relative 'vwo/utils/custom_dimensions'
26
26
  require_relative 'vwo/utils/utility'
27
+ require_relative 'vwo/utils/data_location_manager'
27
28
  require_relative 'vwo/constants'
28
29
  require_relative 'vwo/core/variation_decider'
29
30
  require_relative 'vwo/services/batch_events_dispatcher'
@@ -41,6 +42,7 @@ class VWO
41
42
  include Utils::Campaign
42
43
  include Utils::Impression
43
44
  include Utils::Utility
45
+ include VWO::Utils
44
46
  include CONSTANTS
45
47
 
46
48
  FILE = FileNameEnum::VWO
@@ -65,6 +67,7 @@ class VWO
65
67
  options = {}
66
68
  )
67
69
  options = convert_to_symbol_hash(options)
70
+ @is_opted_out = false
68
71
  @account_id = account_id
69
72
  @sdk_key = sdk_key
70
73
  @user_storage = user_storage
@@ -122,6 +125,7 @@ class VWO
122
125
  # Process the settings file
123
126
  @config.process_settings_file
124
127
  @settings_file = @config.get_settings_file
128
+ DataLocationManager.get_instance().set_settings(@settings_file)
125
129
 
126
130
  @usage_stats = VWO::Services::UsageStats.new(usage_stats, @is_development_mode)
127
131
 
@@ -208,6 +212,10 @@ class VWO
208
212
  # VWO get_settings method to get settings for a particular account_id
209
213
  def get_and_update_settings_file
210
214
 
215
+ if is_opted_out(ApiMethods::GET_AND_UPDATE_SETTINGS_FILE)
216
+ return false
217
+ end
218
+
211
219
  unless @is_instance_valid
212
220
  @logger.log(
213
221
  LogLevelEnum::ERROR,
@@ -217,7 +225,7 @@ class VWO
217
225
  api_name: ApiMethods.GET_AND_UPDATE_SETTINGS_FILE
218
226
  )
219
227
  )
220
- return
228
+ return false
221
229
  end
222
230
 
223
231
  latest_settings = @settings_file_manager.get_settings_file(true)
@@ -267,6 +275,10 @@ class VWO
267
275
  # otherwise null in case of user not becoming part
268
276
 
269
277
  def activate(campaign_key, user_id, options = {})
278
+ if is_opted_out(ApiMethods::ACTIVATE)
279
+ return nil
280
+ end
281
+
270
282
  unless @is_instance_valid
271
283
  @logger.log(
272
284
  LogLevelEnum::ERROR,
@@ -444,6 +456,10 @@ class VWO
444
456
  # Otherwise null in case of user not becoming part
445
457
  #
446
458
  def get_variation_name(campaign_key, user_id, options = {})
459
+ if is_opted_out(ApiMethods::GET_VARIATION_NAME)
460
+ return nil
461
+ end
462
+
447
463
  unless @is_instance_valid
448
464
  @logger.log(
449
465
  LogLevelEnum::ERROR,
@@ -555,6 +571,10 @@ class VWO
555
571
  #
556
572
 
557
573
  def track(campaign_key, user_id, goal_identifier, options = {})
574
+ if is_opted_out(ApiMethods::TRACK)
575
+ return false
576
+ end
577
+
558
578
  unless @is_instance_valid
559
579
  @logger.log(
560
580
  LogLevelEnum::ERROR,
@@ -786,6 +806,10 @@ class VWO
786
806
  # @return[Boolean] true if user becomes part of feature test/rollout, otherwise false.
787
807
 
788
808
  def feature_enabled?(campaign_key, user_id, options = {})
809
+ if is_opted_out(ApiMethods::IS_FEATURE_ENABLED)
810
+ return false
811
+ end
812
+
789
813
  unless @is_instance_valid
790
814
  @logger.log(
791
815
  LogLevelEnum::ERROR,
@@ -983,13 +1007,17 @@ class VWO
983
1007
  #
984
1008
 
985
1009
  def get_feature_variable_value(campaign_key, variable_key, user_id, options = {})
1010
+ if is_opted_out(ApiMethods::GET_FEATURE_VARIABLE_VALUE)
1011
+ return nil
1012
+ end
1013
+
986
1014
  unless @is_instance_valid
987
1015
  @logger.log(
988
1016
  LogLevelEnum::ERROR,
989
1017
  format(
990
1018
  LogMessageEnum::ErrorMessages::API_CONFIG_CORRUPTED,
991
1019
  file: FILE,
992
- api_name: ApiMethods.GET_FEATURE_VARIABLE_VALUE
1020
+ api_name: ApiMethods::GET_FEATURE_VARIABLE_VALUE
993
1021
  )
994
1022
  )
995
1023
  return
@@ -1137,16 +1165,20 @@ class VWO
1137
1165
  # @return true if call is made successfully, else false
1138
1166
 
1139
1167
  def push(tag_key, tag_value, user_id = nil)
1168
+ if is_opted_out(ApiMethods::PUSH)
1169
+ return false
1170
+ end
1171
+
1140
1172
  unless @is_instance_valid
1141
1173
  @logger.log(
1142
1174
  LogLevelEnum::ERROR,
1143
1175
  format(
1144
1176
  LogMessageEnum::ErrorMessages::API_CONFIG_CORRUPTED,
1145
1177
  file: FILE,
1146
- api_name: ApiMethods.PUSH
1178
+ api_name: ApiMethods::PUSH
1147
1179
  )
1148
1180
  )
1149
- return
1181
+ return false
1150
1182
  end
1151
1183
 
1152
1184
  # Argument reshuffling.
@@ -1245,6 +1277,10 @@ class VWO
1245
1277
  end
1246
1278
 
1247
1279
  def flush_events
1280
+ if is_opted_out(ApiMethods::FLUSH_EVENTS)
1281
+ return false
1282
+ end
1283
+
1248
1284
  unless @is_instance_valid
1249
1285
  @logger.log(
1250
1286
  LogLevelEnum::ERROR,
@@ -1254,10 +1290,13 @@ class VWO
1254
1290
  api_name: ApiMethods::FLUSH_EVENTS
1255
1291
  )
1256
1292
  )
1257
- return
1293
+ return false
1294
+ end
1295
+ result = false
1296
+ if defined?(@batch_events) && !@batch_events_queue.nil?
1297
+ result = @batch_events_queue.flush(manual: true)
1298
+ @batch_events_queue.kill_thread
1258
1299
  end
1259
- result = @batch_events_queue.flush(manual: true)
1260
- @batch_events_queue.kill_thread
1261
1300
  result
1262
1301
  rescue StandardError => e
1263
1302
  @logger.log(
@@ -1294,6 +1333,55 @@ class VWO
1294
1333
  goal_type_to_track
1295
1334
  end
1296
1335
 
1336
+ # Manually opting out of VWO SDK, No tracking will happen
1337
+ #
1338
+ # return[bool]
1339
+ #
1340
+ def set_opt_out
1341
+ @logger.log(
1342
+ LogLevelEnum::INFO,
1343
+ format(
1344
+ LogMessageEnum::InfoMessages::OPT_OUT_API_CALLED,
1345
+ file: FILE
1346
+ )
1347
+ )
1348
+ if defined?(@batch_events) && !@batch_events_queue.nil?
1349
+ @batch_events_queue.flush(manual: true)
1350
+ @batch_events_queue.kill_thread
1351
+ end
1352
+
1353
+ @is_opted_out = true
1354
+ @settings_file = nil
1355
+ @user_storage = nil
1356
+ @event_dispatcher = nil
1357
+ @variation_decider = nil
1358
+ @config = nil
1359
+ @usage_stats = nil
1360
+ @batch_event_dispatcher = nil
1361
+ @batch_events_queue = nil
1362
+ @batch_events = nil
1363
+
1364
+ return @is_opted_out
1365
+ end
1366
+
1367
+
1368
+ # Check if VWO SDK is manually opted out
1369
+ # @param[String] :api_name api_name is used in logging
1370
+ # @return[bool]
1371
+ def is_opted_out(api_name)
1372
+ if @is_opted_out
1373
+ @logger.log(
1374
+ LogLevelEnum::INFO,
1375
+ format(
1376
+ LogMessageEnum::InfoMessages::API_NOT_ENABLED,
1377
+ file: FILE,
1378
+ api: api_name
1379
+ )
1380
+ )
1381
+ end
1382
+ return @is_opted_out
1383
+ end
1384
+
1297
1385
  def is_event_arch_enabled
1298
1386
  return @settings_file.key?('isEventArchEnabled') && @settings_file['isEventArchEnabled']
1299
1387
  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.25.0
4
+ version: 1.29.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - VWO
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-23 00:00:00.000000000 Z
11
+ date: 2022-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: codecov
@@ -106,6 +106,7 @@ files:
106
106
  - lib/vwo/user_storage.rb
107
107
  - lib/vwo/utils/campaign.rb
108
108
  - lib/vwo/utils/custom_dimensions.rb
109
+ - lib/vwo/utils/data_location_manager.rb
109
110
  - lib/vwo/utils/feature.rb
110
111
  - lib/vwo/utils/function.rb
111
112
  - lib/vwo/utils/impression.rb