vwo-sdk 1.23.0 → 1.24.1

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: 3a74040a37074e3fb8ffc75990383654fec552c7007414409ad6563de6173fe9
4
- data.tar.gz: bac8b215309d14868f7cc8022f9d8afe1924d0ad22df3ed0919e136d8025c8cb
3
+ metadata.gz: 68dad84f9b03958ca980c9f9ef2dc91faabdf57bfc33a55baaf5316123eb010b
4
+ data.tar.gz: de01033026fe5f493d7a6a1419c65a60f41a43ac85526a4f16f90448ff31a3bb
5
5
  SHA512:
6
- metadata.gz: 985e03d85f42c33db7c65580abce890127707b11e479a001a372d75ed779aad2d8010edcf2cc2e3dccb8fef39d02be3a165300465beef0e82851ce221985ef5f
7
- data.tar.gz: d90e9528ba974d9e9a29bb7ee4f2d3b3fcb56e14edb15f62b0aaa45e2c2353c94723084c667785de871a8b43bb5d105747d4413683e097c44dd9f7e68e4d6a55
6
+ metadata.gz: 81bfc307f0aa0482c3426edd657ac960fde1d95843401e1f583dc96b6785ef3c6e59f10b1d577424da40d956cd792618275a4451c1f4dc4dff3458454d15f238
7
+ data.tar.gz: 1f8dadef134e4064962bf606b43de36f9b4e4d4ed00c932948b56ab45960e430e42b20edb9e2eae65709091067dce162959165028698d0010ff767657887f1fd
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.23.0'
30
+ SDK_VERSION = '1.24.1'
31
31
  SDK_NAME = 'ruby'
32
32
  VWO_DELIMITER = '_vwo_'
33
33
  MAX_EVENTS_PER_REQUEST = 5000
@@ -95,6 +95,10 @@ class VWO
95
95
  :vwo_user_id => generator_for(user_id, @settings_file['accountId'])
96
96
  }
97
97
 
98
+ if campaign.has_key?("name")
99
+ decision[:campaign_name] = campaign['name']
100
+ end
101
+
98
102
  if is_campaign_part_of_group
99
103
  group_id = @settings_file["campaignGroups"][campaign["id"].to_s]
100
104
  decision[:group_id] = group_id
@@ -459,10 +463,19 @@ class VWO
459
463
  # @return[Hash]
460
464
 
461
465
  def evaluate_whitelisting(user_id, campaign, api_name, campaign_key, variation_targeting_variables = {}, disable_logs = false)
462
- if variation_targeting_variables.nil?
463
- variation_targeting_variables = { _vwo_user_id: user_id }
466
+ if campaign.key?('isUserListEnabled') && campaign["isUserListEnabled"]
467
+ vwo_user_id = generator_for(user_id, @settings_file['accountId'])
468
+ if variation_targeting_variables.nil?
469
+ variation_targeting_variables = { _vwo_user_id: vwo_user_id }
470
+ else
471
+ variation_targeting_variables[:_vwo_user_id] = vwo_user_id
472
+ end
464
473
  else
465
- variation_targeting_variables[:_vwo_user_id] = user_id
474
+ if variation_targeting_variables.nil?
475
+ variation_targeting_variables = { _vwo_user_id: user_id }
476
+ else
477
+ variation_targeting_variables[:_vwo_user_id] = user_id
478
+ end
466
479
  end
467
480
  targeted_variations = []
468
481
 
@@ -485,7 +498,7 @@ class VWO
485
498
  user_id: user_id,
486
499
  status: status,
487
500
  custom_variables: variation_targeting_variables,
488
- variation_name: variation['name'],
501
+ variation_name: status == StatusEnum::PASSED ? (campaign['type'] == CampaignTypes::FEATURE_ROLLOUT ? 'and hence becomes part of the rollout' : "for " + variation['name']) : '',
489
502
  segmentation_type: SegmentationTypeEnum::WHITELISTING,
490
503
  api_name: api_name
491
504
  ),
@@ -865,8 +878,8 @@ class VWO
865
878
  campaign_key: campaign_key,
866
879
  user_id: user_id,
867
880
  status: status,
868
- custom_variables: variation_targeting_variables,
869
- variation_name: status == StatusEnum::PASSED ? "and #{variation['name']} is Assigned" : ' ',
881
+ custom_variables: variation_targeting_variables ? variation_targeting_variables : {},
882
+ variation_name: (status == StatusEnum::PASSED && campaign['type'] != CampaignTypes::FEATURE_ROLLOUT) ? "and #{variation['name']} is Assigned" : ' ',
870
883
  segmentation_type: SegmentationTypeEnum::WHITELISTING,
871
884
  api_name: api_name
872
885
  ),
@@ -879,10 +892,9 @@ class VWO
879
892
  decision[:variation_id] = variation['id']
880
893
  if campaign['type'] == CampaignTypes::FEATURE_TEST
881
894
  decision[:is_feature_enabled] = variation['isFeatureEnabled']
882
- elsif campaign['type'] == CampaignTypes::VISUAL_AB
883
- decision[:is_user_whitelisted] = !!variation['name']
884
895
  end
885
896
  end
897
+ decision[:is_user_whitelisted] = true
886
898
  @hooks_manager.execute(decision)
887
899
  end
888
900
 
data/lib/vwo/enums.rb CHANGED
@@ -106,7 +106,7 @@ 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 for %<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
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.'
@@ -128,9 +128,9 @@ class VWO
128
128
  AUDIENCE_CONDITION_NOT_MET = '(%<file>s): userId:%<user_id>s does not become part of campaign because of not meeting audience conditions'
129
129
  GOT_VARIATION_FOR_USER = '(%<file>s): userId:%<user_id>s for campaign:%<campaign_key>s got variationName:%<variation_name>s'
130
130
  USER_GOT_NO_VARIATION = '(%<file>s): userId:%<user_id>s for campaign:%<campaign_key>s did not allot any variation'
131
- IMPRESSION_SUCCESS = '(%<file>s): Impression event - %<end_point>s was successfully received by VWO having main keys: sdkKey:%<sdk_key>s accountId:%<account_id>s campaignId:%<campaign_id>s and variationId:%<variation_id>s'
132
- MAIN_KEYS_FOR_IMPRESSION = '(%<file>s): Having main keys: {sdkKey:%<sdk_key>s accountId:%<account_id>s campaignId:%<campaign_id>s and variationId:%<variation_id>s}'
133
- MAIN_KEYS_FOR_PUSH_API = '(%<file>s): Having main keys: {sdkKey:%<sdk_key>s accountId:%<account_id>s u:%<u>s and tags:%<tags>s}'
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}'
134
134
  INVALID_VARIATION_KEY = '(%<file>s): Variation was not assigned to userId:%<user_id>s for campaign:%<campaign_key>s'
135
135
 
136
136
  USER_IN_FEATURE_ROLLOUT = '(%<file>s): User ID:%<user_id>s is in feature rollout:%<campaign_key>s'
@@ -143,7 +143,7 @@ class VWO
143
143
  USER_PASSED_SEGMENTATION = '(%<file>s): UserId:%<user_id>s of campaign:%<campaign_key>s with custom_variables:%<custom_variables>s passed segmentation'
144
144
  USER_FAILED_SEGMENTATION = '(%<file>s): UserId:%<user_id>s of campaign:%<campaign_key>s with custom_variables:%<custom_variables>s failed segmentation'
145
145
 
146
- NO_CUSTOM_VARIABLES = '(%<file>s): In API: %<api_name>s, for UserId:%<user_id>s preSegments/customVariables are not passed for campaign:%<campaign_key>s and campaign has pre-segmentation'
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'
147
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'
148
148
 
149
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'
@@ -201,7 +201,6 @@ class VWO
201
201
  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'
202
202
  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.'
203
203
  NO_CAMPAIGN_FOUND = '(%<file>s): No campaign found for goal_identifier:%<goal_identifier>s. Please verify from VWO app.'
204
- INVALID_TRACK_RETURNING_USER_VALUE = '(%<file>s): should_track_returning_user should be boolean'
205
204
  INVALID_GOAL_TYPE = '(%<file>s): goal_type_to_track should be certain strings'
206
205
  EVENT_BATCHING_NOT_OBJECT = '(%<file>s): Batch events settings are not of type object.'
207
206
  EVENTS_PER_REQUEST_INVALID = '(%<file>s): events_per_request should be an integer'
@@ -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
  },
@@ -92,6 +95,7 @@ class VWO
92
95
  }
93
96
  },
94
97
  isBucketingSeedEnabled: ['boolean'],
98
+ isUserListEnabled: ['boolean'],
95
99
  minItems: 2
96
100
  }
97
101
  },
@@ -78,7 +78,9 @@ class VWO
78
78
  i: @sdk_key,
79
79
  r: get_random_number,
80
80
  platform: 'server',
81
- 'api-version' => 1
81
+ 'api-version' => 1,
82
+ 'sdk-v' => VWO::CONSTANTS::SDK_VERSION,
83
+ 'sdk' => VWO::CONSTANTS::SDK_NAME
82
84
  }
83
85
  end
84
86
  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: JSON.generate(params)
44
+ properties: remove_sensitive_properties(params)
43
45
  )
44
46
  )
45
47
  params
@@ -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: JSON.generate(impression)
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: JSON.generate(impression)
93
+ properties: remove_sensitive_properties(impression)
92
94
  )
93
95
  )
94
96
  end
@@ -35,6 +35,12 @@ class VWO
35
35
  end
36
36
  convertedHash
37
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
38
44
  end
39
45
  end
40
46
  end
data/lib/vwo.rb CHANGED
@@ -89,25 +89,6 @@ class VWO
89
89
  return
90
90
  end
91
91
 
92
- if options.key?(:should_track_returning_user)
93
- if [true, false].include? options[:should_track_returning_user]
94
- @should_track_returning_user = options[:should_track_returning_user]
95
- usage_stats[:tr] = 1 if @should_track_returning_user
96
- else
97
- @logger.log(
98
- LogLevelEnum::ERROR,
99
- format(
100
- LogMessageEnum::ErrorMessages::INVALID_TRACK_RETURNING_USER_VALUE,
101
- file: FILE
102
- )
103
- )
104
- @is_instance_valid = false
105
- return
106
- end
107
- else
108
- @should_track_returning_user = false
109
- end
110
-
111
92
  if options.key?(:goal_type_to_track)
112
93
  if GOAL_TYPES.key? options[:goal_type_to_track]
113
94
  @goal_type_to_track = options[:goal_type_to_track]
@@ -303,10 +284,9 @@ class VWO
303
284
  custom_variables = options[:custom_variables]
304
285
  variation_targeting_variables = options[:variation_targeting_variables]
305
286
 
306
- should_track_returning_user = get_should_track_returning_user(options)
307
287
  # Validate input parameters
308
288
  unless valid_string?(campaign_key) && valid_string?(user_id) && (custom_variables.nil? || valid_hash?(custom_variables)) &&
309
- (variation_targeting_variables.nil? || valid_hash?(variation_targeting_variables)) && [true, false].include?(should_track_returning_user)
289
+ (variation_targeting_variables.nil? || valid_hash?(variation_targeting_variables))
310
290
  @logger.log(
311
291
  LogLevelEnum::ERROR,
312
292
  format(
@@ -381,7 +361,7 @@ class VWO
381
361
  return
382
362
  end
383
363
 
384
- if is_eligible_to_send_impression(should_track_returning_user)
364
+ if is_eligible_to_send_impression()
385
365
  if defined?(@batch_events)
386
366
  impression = create_bulk_event_impression(
387
367
  @settings_file,
@@ -408,7 +388,6 @@ class VWO
408
388
  format(
409
389
  LogMessageEnum::InfoMessages::IMPRESSION_SUCCESS,
410
390
  file: FILE,
411
- sdk_key: @sdk_key,
412
391
  account_id: @account_id,
413
392
  campaign_id: campaign['id'],
414
393
  variation_id: variation['id'],
@@ -588,12 +567,11 @@ class VWO
588
567
  revenue_value = options[:revenue_value]
589
568
  custom_variables = options[:custom_variables]
590
569
  variation_targeting_variables = options[:variation_targeting_variables]
591
- should_track_returning_user = get_should_track_returning_user(options)
592
570
  goal_type_to_track = get_goal_type_to_track(options)
593
571
 
594
572
  # Check for valid args
595
573
  unless (valid_string?(campaign_key) || campaign_key.is_a?(Array) || campaign_key.nil?) && valid_string?(user_id) && valid_string?(goal_identifier) && (custom_variables.nil? || valid_hash?(custom_variables)) &&
596
- (variation_targeting_variables.nil? || valid_hash?(variation_targeting_variables)) && [true, false].include?(should_track_returning_user) && (GOAL_TYPES.key? (goal_type_to_track))
574
+ (variation_targeting_variables.nil? || valid_hash?(variation_targeting_variables)) && (GOAL_TYPES.key? (goal_type_to_track))
597
575
  # log invalid params
598
576
  @logger.log(
599
577
  LogLevelEnum::ERROR,
@@ -683,7 +661,7 @@ class VWO
683
661
  updated_goal_identifier += VWO_DELIMITER + goal_identifier
684
662
  @variation_decider.save_user_storage(user_id, campaign['key'], campaign['name'], variation['name'], updated_goal_identifier) if variation['name']
685
663
  # set variation at user storage
686
- elsif !should_track_returning_user
664
+ else
687
665
  @logger.log(
688
666
  LogLevelEnum::INFO,
689
667
  format(
@@ -725,7 +703,6 @@ class VWO
725
703
  format(
726
704
  LogMessageEnum::InfoMessages::IMPRESSION_SUCCESS,
727
705
  file: FILE,
728
- sdk_key: @sdk_key,
729
706
  account_id: @account_id,
730
707
  campaign_id: campaign['id'],
731
708
  variation_id: variation['id'],
@@ -737,7 +714,6 @@ class VWO
737
714
  format(
738
715
  LogMessageEnum::InfoMessages::MAIN_KEYS_FOR_IMPRESSION,
739
716
  file: FILE,
740
- sdk_key: @sdk_key,
741
717
  campaign_id: impression[:experiment_id],
742
718
  account_id: impression[:account_id],
743
719
  variation_id: impression[:combination]
@@ -809,7 +785,6 @@ class VWO
809
785
  # Retrieve custom variables
810
786
  custom_variables = options[:custom_variables]
811
787
  variation_targeting_variables = options[:variation_targeting_variables]
812
- should_track_returning_user = get_should_track_returning_user(options)
813
788
  @logger.log(
814
789
  LogLevelEnum::INFO,
815
790
  format(
@@ -821,7 +796,7 @@ class VWO
821
796
  )
822
797
  # Validate input parameters
823
798
  unless valid_string?(campaign_key) && valid_string?(user_id) && (custom_variables.nil? || valid_hash?(custom_variables)) &&
824
- (variation_targeting_variables.nil? || valid_hash?(variation_targeting_variables)) && [true, false].include?(should_track_returning_user)
799
+ (variation_targeting_variables.nil? || valid_hash?(variation_targeting_variables))
825
800
  @logger.log(
826
801
  LogLevelEnum::ERROR,
827
802
  format(
@@ -877,7 +852,7 @@ class VWO
877
852
 
878
853
  # if campaign type is feature_test Send track call to server
879
854
 
880
- if is_eligible_to_send_impression(should_track_returning_user)
855
+ if is_eligible_to_send_impression()
881
856
  if defined?(@batch_events)
882
857
  impression = create_bulk_event_impression(
883
858
  @settings_file,
@@ -905,7 +880,6 @@ class VWO
905
880
  LogMessageEnum::InfoMessages::MAIN_KEYS_FOR_IMPRESSION,
906
881
  file: FILE,
907
882
  campaign_id: impression[:experiment_id],
908
- sdk_key: @sdk_key,
909
883
  account_id: impression[:account_id],
910
884
  variation_id: impression[:combination]
911
885
  )
@@ -1206,7 +1180,6 @@ class VWO
1206
1180
  format(
1207
1181
  LogMessageEnum::InfoMessages::MAIN_KEYS_FOR_PUSH_API,
1208
1182
  file: FILE,
1209
- sdk_key: @sdk_key,
1210
1183
  u: impression['u'],
1211
1184
  account_id: impression['account_id'],
1212
1185
  tags: impression['tags']
@@ -1227,23 +1200,8 @@ class VWO
1227
1200
  false
1228
1201
  end
1229
1202
 
1230
- def get_should_track_returning_user(options)
1231
- if !options.key?(:should_track_returning_user)
1232
- options[:should_track_returning_user] = @should_track_returning_user
1233
- elsif ![true, false].include?(options[:should_track_returning_user])
1234
- @logger.log(
1235
- LogLevelEnum::ERROR,
1236
- format(
1237
- LogMessageEnum::ErrorMessages::INVALID_TRACK_RETURNING_USER_VALUE,
1238
- file: FILE
1239
- )
1240
- )
1241
- end
1242
- options[:should_track_returning_user]
1243
- end
1244
-
1245
- def is_eligible_to_send_impression(should_track_returning_user = false)
1246
- !@user_storage || !@variation_decider.has_stored_variation || should_track_returning_user
1203
+ def is_eligible_to_send_impression()
1204
+ !@user_storage || !@variation_decider.has_stored_variation
1247
1205
  end
1248
1206
 
1249
1207
  def flush_events
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.23.0
4
+ version: 1.24.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - VWO
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-11 00:00:00.000000000 Z
11
+ date: 2021-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: codecov