vwo-sdk 1.35.0 → 1.38.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: dfb56a7b9b42ecdd68adf08aec9d3730718f06e2524391cdd13e36b102f2a101
4
- data.tar.gz: 24c6d8e61d28e47af3d2e15c7d1bf359a4b0baf2a45db4c4ca6c020b65b937e7
3
+ metadata.gz: a0e08961757aa3ab300766b7c2fd27429d0c3edb97c8e2609d3b41fb8e9b3362
4
+ data.tar.gz: dda836f16065c27aed8102c2e7f666b47645c20fe38c9830c02f0c9c1a32b959
5
5
  SHA512:
6
- metadata.gz: 07b6bc00eb777b88e60a1adaa0faa186b214ae492b86af876c3118e9eecac6d598de0e1e60d9abc54d20877ded9c0236c0661d5be9f1d92a1ee5d7f902ad3b9e
7
- data.tar.gz: 80163a10745a7683a56dfa3717de522414a38110a54645e609bf8c4522451eca7c1175f5d02b1bfa3efe244aeffe6dfee523d6bf4a3b101bda789550fd967a3d
6
+ metadata.gz: cd96894eaf16020bddfc7246ee287ae7dbaaa9df40e9dc17ec09b0af31379a05a6d1b682665599f4f45d495ceecd5c66409cb753c7f4e59dd72d25e9037e3ef2
7
+ data.tar.gz: 56a9930a525ed16aab574920cffe787da6b2ecf8225d0a8bf03edea1ab67b331e433537da35af6b70715787c61abc132e9b04b032da1950a0bc39af085c9fce2
data/lib/vwo/constants.rb CHANGED
@@ -19,7 +19,7 @@ class VWO
19
19
  SEED_VALUE = 1
20
20
  MAX_TRAFFIC_PERCENT = 100
21
21
  MAX_TRAFFIC_VALUE = 10_000
22
- MAX_RANGE = 10000
22
+ MAX_RANGE = 10_000
23
23
  STATUS_RUNNING = 'RUNNING'
24
24
  # rubocop:disable Style/ExpandPathArguments
25
25
  LIBRARY_PATH = File.expand_path('../..', __FILE__)
@@ -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.35.0'
30
+ SDK_VERSION = '1.38.0'
31
31
  SDK_NAME = 'ruby'
32
32
  VWO_DELIMITER = '_vwo_'
33
33
  MAX_EVENTS_PER_REQUEST = 5000
@@ -31,7 +31,7 @@ class VWO
31
31
  # Source - https://stackoverflow.com/a/20766900/2494535
32
32
  U_MAX_32_BIT = 0xFFFFFFFF
33
33
  MAX_HASH_VALUE = 2**32
34
- FILE = FileNameEnum::Bucketer
34
+ FILE = FileNameEnum::BUCKETER
35
35
 
36
36
  def initialize
37
37
  @logger = VWO::Utils::Logger
@@ -49,16 +49,14 @@ class VWO
49
49
  LogLevelEnum::ERROR,
50
50
  'USER_ID_INVALID',
51
51
  {
52
- '{file}' => FILE,
53
- '{userId}' => user_id
52
+ '{file}' => FILE,
53
+ '{userId}' => user_id
54
54
  }
55
55
  )
56
56
  return false
57
57
  end
58
58
 
59
- if campaign.nil?
60
- return false
61
- end
59
+ return false if campaign.nil?
62
60
 
63
61
  traffic_allocation = campaign['percentTraffic']
64
62
  value_assigned_to_user = get_bucket_value_for_user(user_id, campaign, nil, disable_logs)
@@ -92,21 +90,17 @@ class VWO
92
90
  LogLevelEnum::ERROR,
93
91
  'USER_ID_INVALID',
94
92
  {
95
- '{file}' => FILE,
96
- '{userId}' => user_id
93
+ '{file}' => FILE,
94
+ '{userId}' => user_id
97
95
  }
98
96
  )
99
97
  return
100
98
  end
101
99
 
102
- unless campaign
103
- return
104
- end
100
+ return unless campaign
105
101
 
106
102
  user_id_for_hash_value = user_id
107
- if campaign['isBucketingSeedEnabled']
108
- user_id_for_hash_value = campaign['id'].to_s + "_" + user_id
109
- end
103
+ user_id_for_hash_value = "#{campaign['id']}_#{user_id}" if campaign['isBucketingSeedEnabled']
110
104
  hash_value = MurmurHash3::V32.str_hash(user_id_for_hash_value, SEED_VALUE) & U_MAX_32_BIT
111
105
  normalize = MAX_TRAFFIC_VALUE.to_f / campaign['percentTraffic']
112
106
  multiplier = normalize / 100
@@ -120,12 +114,12 @@ class VWO
120
114
  LogLevelEnum::DEBUG,
121
115
  'USER_CAMPAIGN_BUCKET_VALUES',
122
116
  {
123
- '{file}' => FILE,
124
- '{campaignKey}' => campaign['key'],
125
- '{userId}' => user_id,
126
- '{percentTraffic}' => campaign['percentTraffic'],
127
- '{hashValue}' => hash_value,
128
- '{bucketValue}' => bucket_value,
117
+ '{file}' => FILE,
118
+ '{campaignKey}' => campaign['key'],
119
+ '{userId}' => user_id,
120
+ '{percentTraffic}' => campaign['percentTraffic'],
121
+ '{hashValue}' => hash_value,
122
+ '{bucketValue}' => bucket_value
129
123
  },
130
124
  disable_logs
131
125
  )
@@ -156,9 +150,9 @@ class VWO
156
150
  def get_bucket_value_for_user(user_id, campaign = {}, group_id = nil, disable_logs = false)
157
151
  user_id_for_hash_value = user_id
158
152
  if group_id
159
- user_id_for_hash_value = group_id.to_s + "_" + user_id
153
+ user_id_for_hash_value = "#{group_id}_#{user_id}"
160
154
  elsif campaign['isBucketingSeedEnabled']
161
- user_id_for_hash_value = campaign['id'].to_s + "_" + user_id
155
+ user_id_for_hash_value = "#{campaign['id']}_#{user_id}"
162
156
  end
163
157
  hash_value = MurmurHash3::V32.str_hash(user_id_for_hash_value, SEED_VALUE) & U_MAX_32_BIT
164
158
  bucket_value = get_bucket_value(hash_value, MAX_TRAFFIC_PERCENT)
@@ -198,11 +192,9 @@ class VWO
198
192
  # @return[Hash|nil]
199
193
  #
200
194
  def get_campaign_using_range(range_for_campaigns, campaigns)
201
- range_for_campaigns = range_for_campaigns * 100
195
+ range_for_campaigns *= 100
202
196
  campaigns.each do |campaign|
203
- if campaign["max_range"] && campaign["max_range"] >= range_for_campaigns && campaign["min_range"] <= range_for_campaigns
204
- return campaign
205
- end
197
+ return campaign if campaign['max_range'] && campaign['max_range'] >= range_for_campaigns && campaign['min_range'] <= range_for_campaigns
206
198
  end
207
199
  nil
208
200
  end