vwo-sdk 1.22.0 → 1.23.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: 84d01560f605a69e8ed011a19ba4e3aae0f67341fd653a562d817801d6a55073
4
- data.tar.gz: b1355bef1b2b095774c702a6757c1a7141e2cf9758d0a1b8a0510111a8ee597a
3
+ metadata.gz: 3a74040a37074e3fb8ffc75990383654fec552c7007414409ad6563de6173fe9
4
+ data.tar.gz: bac8b215309d14868f7cc8022f9d8afe1924d0ad22df3ed0919e136d8025c8cb
5
5
  SHA512:
6
- metadata.gz: cc2c8a411e3c0a674ab2bc00e540b3e49a8dd943ec50aa04fba04839ef6f3e255fc275529f872aa5ca73dfe893cb43e8853a0875cc3dda9330554b6491590947
7
- data.tar.gz: 5482e79564a365ec8fe4012b25997096352129e915daca28774c790c416a528302ea1f0bb685ef559b9ee0846b0229957a8f6ab77008f4e48222a7cae5892699
6
+ metadata.gz: 985e03d85f42c33db7c65580abce890127707b11e479a001a372d75ed779aad2d8010edcf2cc2e3dccb8fef39d02be3a165300465beef0e82851ce221985ef5f
7
+ data.tar.gz: d90e9528ba974d9e9a29bb7ee4f2d3b3fcb56e14edb15f62b0aaa45e2c2353c94723084c667785de871a8b43bb5d105747d4413683e097c44dd9f7e68e4d6a55
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.22.0'
30
+ SDK_VERSION = '1.23.0'
31
31
  SDK_NAME = 'ruby'
32
32
  VWO_DELIMITER = '_vwo_'
33
33
  MAX_EVENTS_PER_REQUEST = 5000
@@ -460,9 +460,9 @@ class VWO
460
460
 
461
461
  def evaluate_whitelisting(user_id, campaign, api_name, campaign_key, variation_targeting_variables = {}, disable_logs = false)
462
462
  if variation_targeting_variables.nil?
463
- variation_targeting_variables = { '_vwo_user_id' => user_id }
463
+ variation_targeting_variables = { _vwo_user_id: user_id }
464
464
  else
465
- variation_targeting_variables['_vwo_user_id'] = user_id
465
+ variation_targeting_variables[:_vwo_user_id] = user_id
466
466
  end
467
467
  targeted_variations = []
468
468
 
@@ -717,7 +717,7 @@ class VWO
717
717
 
718
718
  group_campaigns.each do |campaign|
719
719
  if called_campaign["id"] == campaign["id"] || check_presegmentation(campaign, user_id, custom_variables, '', true) && @bucketer.user_part_of_campaign?(user_id, campaign)
720
- eligible_campaigns.append(campaign)
720
+ eligible_campaigns.push(campaign)
721
721
  end
722
722
  end
723
723
  return eligible_campaigns
@@ -748,7 +748,7 @@ class VWO
748
748
  def get_eligible_campaigns_key(eligible_campaigns)
749
749
  eligible_campaigns_key = []
750
750
  eligible_campaigns.each do |campaign|
751
- eligible_campaigns_key.append(campaign["key"])
751
+ eligible_campaigns_key.push(campaign["key"])
752
752
  end
753
753
  eligible_campaigns_key
754
754
  end
@@ -763,7 +763,7 @@ class VWO
763
763
  non_eligible_campaigns_key = []
764
764
  group_campaigns.each do |campaign|
765
765
  unless eligible_campaigns.include? campaign
766
- non_eligible_campaigns_key.append(campaign["key"])
766
+ non_eligible_campaigns_key.push(campaign["key"])
767
767
  end
768
768
  end
769
769
  non_eligible_campaigns_key
@@ -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['_vwo_user_id']
115
+ return true if user.strip == custom_variables[:_vwo_user_id]
117
116
  end
118
117
  false
119
118
  end
@@ -299,7 +299,7 @@ class VWO
299
299
  group_campaign_ids.each do |campaign_id|
300
300
  settings_file["campaigns"].each do |campaign|
301
301
  if campaign["id"] == campaign_id && campaign["status"] == STATUS_RUNNING
302
- group_campaigns.append(campaign)
302
+ group_campaigns.push(campaign)
303
303
  end
304
304
  end
305
305
  end
@@ -0,0 +1,40 @@
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
+ end
39
+ end
40
+ 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['custom_variables'] || options[:custom_variables]
300
- variation_targeting_variables = options['variation_targeting_variables'] || options[:variation_targeting_variables]
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
@@ -468,9 +472,10 @@ class VWO
468
472
  )
469
473
  return
470
474
  end
475
+ options = convert_to_symbol_hash(options)
471
476
  # Retrieve custom variables
472
- custom_variables = options['custom_variables'] || options[:custom_variables]
473
- variation_targeting_variables = options['variation_targeting_variables'] || options[:variation_targeting_variables]
477
+ custom_variables = options[:custom_variables]
478
+ variation_targeting_variables = options[:variation_targeting_variables]
474
479
 
475
480
  # Validate input parameters
476
481
  unless valid_string?(campaign_key) && valid_string?(user_id) && (custom_variables.nil? || valid_hash?(custom_variables)) &&
@@ -579,9 +584,10 @@ class VWO
579
584
  return false
580
585
  end
581
586
 
582
- revenue_value = options['revenue_value'] || options[:revenue_value]
583
- custom_variables = options['custom_variables'] || options[:custom_variables]
584
- variation_targeting_variables = options['variation_targeting_variables'] || options[:variation_targeting_variables]
587
+ options = convert_to_symbol_hash(options)
588
+ revenue_value = options[:revenue_value]
589
+ custom_variables = options[:custom_variables]
590
+ variation_targeting_variables = options[:variation_targeting_variables]
585
591
  should_track_returning_user = get_should_track_returning_user(options)
586
592
  goal_type_to_track = get_goal_type_to_track(options)
587
593
 
@@ -799,9 +805,10 @@ class VWO
799
805
  return false
800
806
  end
801
807
 
808
+ options = convert_to_symbol_hash(options)
802
809
  # Retrieve custom variables
803
- custom_variables = options['custom_variables'] || options[:custom_variables]
804
- variation_targeting_variables = options['variation_targeting_variables'] || options[:variation_targeting_variables]
810
+ custom_variables = options[:custom_variables]
811
+ variation_targeting_variables = options[:variation_targeting_variables]
805
812
  should_track_returning_user = get_should_track_returning_user(options)
806
813
  @logger.log(
807
814
  LogLevelEnum::INFO,
@@ -993,9 +1000,10 @@ class VWO
993
1000
  return
994
1001
  end
995
1002
 
1003
+ options = convert_to_symbol_hash(options)
996
1004
  # Retrieve custom variables
997
- custom_variables = options['custom_variables'] || options[:custom_variables]
998
- variation_targeting_variables = options['variation_targeting_variables'] || options[:variation_targeting_variables]
1005
+ custom_variables = options[:custom_variables]
1006
+ variation_targeting_variables = options[:variation_targeting_variables]
999
1007
 
1000
1008
  unless valid_string?(campaign_key) && valid_string?(variable_key) && valid_string?(user_id) &&
1001
1009
  (custom_variables.nil? || valid_hash?(custom_variables)) && (variation_targeting_variables.nil? || valid_hash?(variation_targeting_variables))
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.22.0
4
+ version: 1.23.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-09-02 00:00:00.000000000 Z
11
+ date: 2021-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: codecov
@@ -87,7 +87,6 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - lib/abc.txt
91
90
  - lib/vwo.rb
92
91
  - lib/vwo/constants.rb
93
92
  - lib/vwo/core/bucketer.rb
@@ -112,6 +111,7 @@ files:
112
111
  - lib/vwo/utils/impression.rb
113
112
  - lib/vwo/utils/request.rb
114
113
  - lib/vwo/utils/segment.rb
114
+ - lib/vwo/utils/utility.rb
115
115
  - lib/vwo/utils/uuid.rb
116
116
  - lib/vwo/utils/validations.rb
117
117
  homepage: https://vwo.com/fullstack/server-side-testing/
data/lib/abc.txt DELETED
@@ -1,28 +0,0 @@
1
- {"user_id"=>"Ashley", "variation_name"=>"Control", "campaign_key"=>"DEV_TEST_162"}
2
- GOT_ELIGIBLE_CAMPAIGNS
3
- {"user_id"=>"Ashley", "variation_name"=>"Control", "campaign_key"=>"DEV_TEST_162"}
4
- GOT_ELIGIBLE_CAMPAIGNS
5
- {"user_id"=>"Ashley", "variation_name"=>"Control", "campaign_key"=>"DEV_TEST_162"}
6
- GOT_ELIGIBLE_CAMPAIGNS
7
- {"user_id"=>"Ashley", "variation_name"=>"Control", "campaign_key"=>"DEV_TEST_162"}
8
- GOT_ELIGIBLE_CAMPAIGNS
9
- {"user_id"=>"Ashley", "variation_name"=>"Control", "campaign_key"=>"DEV_TEST_162"}
10
- GOT_ELIGIBLE_CAMPAIGNS
11
- {"user_id"=>"Ashley", "variation_name"=>"Control", "campaign_key"=>"DEV_TEST_162"}
12
- GOT_ELIGIBLE_CAMPAIGNS
13
- {"user_id"=>"Ashley", "variation_name"=>"Control", "campaign_key"=>"DEV_TEST_162"}
14
- GOT_ELIGIBLE_CAMPAIGNS
15
- {"user_id"=>"Ashley", "variation_name"=>"Control", "campaign_key"=>"DEV_TEST_162"}
16
- GOT_ELIGIBLE_CAMPAIGNS
17
- {"user_id"=>"Ashley", "variation_name"=>"Control", "campaign_key"=>"DEV_TEST_162"}
18
- GOT_ELIGIBLE_CAMPAIGNS
19
- {"user_id"=>"Ashley", "variation_name"=>"Control", "campaign_key"=>"DEV_TEST_162"}
20
- GOT_ELIGIBLE_CAMPAIGNS
21
- {"user_id"=>"Ashley", "variation_name"=>"Control", "campaign_key"=>"DEV_TEST_162"}
22
- GOT_ELIGIBLE_CAMPAIGNS
23
- {"user_id"=>"Ashley", "variation_name"=>"Control", "campaign_key"=>"DEV_TEST_162"}
24
- GOT_ELIGIBLE_CAMPAIGNS
25
- {"user_id"=>"Ashley", "variation_name"=>"Control", "campaign_key"=>"DEV_TEST_162"}
26
- GOT_ELIGIBLE_CAMPAIGNS
27
- {"user_id"=>"Ashley", "variation_name"=>"Control", "campaign_key"=>"DEV_TEST_162"}
28
- GOT_ELIGIBLE_CAMPAIGNS