vwo-sdk 1.25.0 → 1.28.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: 83480c79432c0c6199e03e365b71fcf8b2e0ffaf89b976c94234b3bcfc54e931
4
+ data.tar.gz: a695f06bf66c0186c193b05b9d4a6a931c75b9398f260f7d733b57275a3bfedd
5
5
  SHA512:
6
- metadata.gz: 0c23fe3a4fbcb4c85ef1af73a7ef9bb37a0a79eb4f628bad726f66394291cd93d24cecc066a662799670d10b703265eb3afe72a689ce060a2756eb84d0bfce69
7
- data.tar.gz: f60e3e5a8b96e2ab878929c857d4c8d5c3071e6439e811ac59e7bfa00b488f6c79583ebbfa4a8995a3adac5faf80b7c9293ebea3fa0da231224c684ed39adbb4
6
+ metadata.gz: 63572509c60e9e96c39775bab1fe0bea00dd0ca27f436c46055563886a66bca0d78b3259fe70c2d58e13c8ed0c8e036245760923fcf2187b964628cea2f7741b
7
+ data.tar.gz: f96d84a9c2ae09e474ede155e1187cce8cd9a0dc38f56646531519aae27c07d5883c5373a60fae9fe92eef9fe0da7f23b1af7e3a71ce1a4283fda9ee6533551a
data/lib/vwo/constants.rb CHANGED
@@ -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.28.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
data/lib/vwo/enums.rb CHANGED
@@ -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.rb CHANGED
@@ -65,6 +65,7 @@ class VWO
65
65
  options = {}
66
66
  )
67
67
  options = convert_to_symbol_hash(options)
68
+ @is_opted_out = false
68
69
  @account_id = account_id
69
70
  @sdk_key = sdk_key
70
71
  @user_storage = user_storage
@@ -208,6 +209,10 @@ class VWO
208
209
  # VWO get_settings method to get settings for a particular account_id
209
210
  def get_and_update_settings_file
210
211
 
212
+ if is_opted_out(ApiMethods::GET_AND_UPDATE_SETTINGS_FILE)
213
+ return false
214
+ end
215
+
211
216
  unless @is_instance_valid
212
217
  @logger.log(
213
218
  LogLevelEnum::ERROR,
@@ -217,7 +222,7 @@ class VWO
217
222
  api_name: ApiMethods.GET_AND_UPDATE_SETTINGS_FILE
218
223
  )
219
224
  )
220
- return
225
+ return false
221
226
  end
222
227
 
223
228
  latest_settings = @settings_file_manager.get_settings_file(true)
@@ -267,6 +272,10 @@ class VWO
267
272
  # otherwise null in case of user not becoming part
268
273
 
269
274
  def activate(campaign_key, user_id, options = {})
275
+ if is_opted_out(ApiMethods::ACTIVATE)
276
+ return nil
277
+ end
278
+
270
279
  unless @is_instance_valid
271
280
  @logger.log(
272
281
  LogLevelEnum::ERROR,
@@ -444,6 +453,10 @@ class VWO
444
453
  # Otherwise null in case of user not becoming part
445
454
  #
446
455
  def get_variation_name(campaign_key, user_id, options = {})
456
+ if is_opted_out(ApiMethods::GET_VARIATION_NAME)
457
+ return nil
458
+ end
459
+
447
460
  unless @is_instance_valid
448
461
  @logger.log(
449
462
  LogLevelEnum::ERROR,
@@ -555,6 +568,10 @@ class VWO
555
568
  #
556
569
 
557
570
  def track(campaign_key, user_id, goal_identifier, options = {})
571
+ if is_opted_out(ApiMethods::TRACK)
572
+ return false
573
+ end
574
+
558
575
  unless @is_instance_valid
559
576
  @logger.log(
560
577
  LogLevelEnum::ERROR,
@@ -786,6 +803,10 @@ class VWO
786
803
  # @return[Boolean] true if user becomes part of feature test/rollout, otherwise false.
787
804
 
788
805
  def feature_enabled?(campaign_key, user_id, options = {})
806
+ if is_opted_out(ApiMethods::IS_FEATURE_ENABLED)
807
+ return false
808
+ end
809
+
789
810
  unless @is_instance_valid
790
811
  @logger.log(
791
812
  LogLevelEnum::ERROR,
@@ -983,13 +1004,17 @@ class VWO
983
1004
  #
984
1005
 
985
1006
  def get_feature_variable_value(campaign_key, variable_key, user_id, options = {})
1007
+ if is_opted_out(ApiMethods::GET_FEATURE_VARIABLE_VALUE)
1008
+ return nil
1009
+ end
1010
+
986
1011
  unless @is_instance_valid
987
1012
  @logger.log(
988
1013
  LogLevelEnum::ERROR,
989
1014
  format(
990
1015
  LogMessageEnum::ErrorMessages::API_CONFIG_CORRUPTED,
991
1016
  file: FILE,
992
- api_name: ApiMethods.GET_FEATURE_VARIABLE_VALUE
1017
+ api_name: ApiMethods::GET_FEATURE_VARIABLE_VALUE
993
1018
  )
994
1019
  )
995
1020
  return
@@ -1137,16 +1162,20 @@ class VWO
1137
1162
  # @return true if call is made successfully, else false
1138
1163
 
1139
1164
  def push(tag_key, tag_value, user_id = nil)
1165
+ if is_opted_out(ApiMethods::PUSH)
1166
+ return false
1167
+ end
1168
+
1140
1169
  unless @is_instance_valid
1141
1170
  @logger.log(
1142
1171
  LogLevelEnum::ERROR,
1143
1172
  format(
1144
1173
  LogMessageEnum::ErrorMessages::API_CONFIG_CORRUPTED,
1145
1174
  file: FILE,
1146
- api_name: ApiMethods.PUSH
1175
+ api_name: ApiMethods::PUSH
1147
1176
  )
1148
1177
  )
1149
- return
1178
+ return false
1150
1179
  end
1151
1180
 
1152
1181
  # Argument reshuffling.
@@ -1245,6 +1274,10 @@ class VWO
1245
1274
  end
1246
1275
 
1247
1276
  def flush_events
1277
+ if is_opted_out(ApiMethods::FLUSH_EVENTS)
1278
+ return false
1279
+ end
1280
+
1248
1281
  unless @is_instance_valid
1249
1282
  @logger.log(
1250
1283
  LogLevelEnum::ERROR,
@@ -1254,10 +1287,13 @@ class VWO
1254
1287
  api_name: ApiMethods::FLUSH_EVENTS
1255
1288
  )
1256
1289
  )
1257
- return
1290
+ return false
1291
+ end
1292
+ result = false
1293
+ if defined?(@batch_events) && !@batch_events_queue.nil?
1294
+ result = @batch_events_queue.flush(manual: true)
1295
+ @batch_events_queue.kill_thread
1258
1296
  end
1259
- result = @batch_events_queue.flush(manual: true)
1260
- @batch_events_queue.kill_thread
1261
1297
  result
1262
1298
  rescue StandardError => e
1263
1299
  @logger.log(
@@ -1294,6 +1330,55 @@ class VWO
1294
1330
  goal_type_to_track
1295
1331
  end
1296
1332
 
1333
+ # Manually opting out of VWO SDK, No tracking will happen
1334
+ #
1335
+ # return[bool]
1336
+ #
1337
+ def set_opt_out
1338
+ @logger.log(
1339
+ LogLevelEnum::INFO,
1340
+ format(
1341
+ LogMessageEnum::InfoMessages::OPT_OUT_API_CALLED,
1342
+ file: FILE
1343
+ )
1344
+ )
1345
+ if defined?(@batch_events) && !@batch_events_queue.nil?
1346
+ @batch_events_queue.flush(manual: true)
1347
+ @batch_events_queue.kill_thread
1348
+ end
1349
+
1350
+ @is_opted_out = true
1351
+ @settings_file = nil
1352
+ @user_storage = nil
1353
+ @event_dispatcher = nil
1354
+ @variation_decider = nil
1355
+ @config = nil
1356
+ @usage_stats = nil
1357
+ @batch_event_dispatcher = nil
1358
+ @batch_events_queue = nil
1359
+ @batch_events = nil
1360
+
1361
+ return @is_opted_out
1362
+ end
1363
+
1364
+
1365
+ # Check if VWO SDK is manually opted out
1366
+ # @param[String] :api_name api_name is used in logging
1367
+ # @return[bool]
1368
+ def is_opted_out(api_name)
1369
+ if @is_opted_out
1370
+ @logger.log(
1371
+ LogLevelEnum::INFO,
1372
+ format(
1373
+ LogMessageEnum::InfoMessages::API_NOT_ENABLED,
1374
+ file: FILE,
1375
+ api: api_name
1376
+ )
1377
+ )
1378
+ end
1379
+ return @is_opted_out
1380
+ end
1381
+
1297
1382
  def is_event_arch_enabled
1298
1383
  return @settings_file.key?('isEventArchEnabled') && @settings_file['isEventArchEnabled']
1299
1384
  end
metadata CHANGED
@@ -1,7 +1,7 @@
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.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - VWO