vwo-sdk 1.36.0 → 1.37.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: 43fec6e51e5bb0377e3714ca0fa90bc1cd11c26c29c99af86e0b8fec858af4b1
4
- data.tar.gz: 6b63f796cc23e812e65a731cfeefddfcee46c1bb1d24ece33b9bdecbc619bc62
3
+ metadata.gz: ea72e150de33227c3e911fd61478a8815fb8f42f788df4a65a6751a1da7c25fb
4
+ data.tar.gz: c88b275817a6ef0ca80efc03287e57fd1488be9390e7a028a4dc812cca93abc0
5
5
  SHA512:
6
- metadata.gz: 0357c8d8c220348265463a1adaabd0480c9424cf8082d05541643c6ccdbdfbf2692e603a08acfd1b71d4762d31649ba1e5fd5469707f1e01251d96329509a6e2
7
- data.tar.gz: e30bd9f514a53da482f5e7d38dda6a3ced309fa027afe4d9148cfb464fff6acf3da0e012574dbf38712390ab24daa0148a42ce76f83fb8d264ecfb88c8bfb84a
6
+ metadata.gz: 294fab2cbb559b6869e547dd0f55b9bb5ac54910ba61d497f9d205fd37c405bc206b6264912bc0600306dd0986d875c034be0e4342260f3d0aa8a647ad0a67e3
7
+ data.tar.gz: d25b2e2642a1e178eeeba2b0f7f7e82188040df6116a6a14bb13abfba7cf8e0b2ee28c5161936cc9773663f55cdca9d371b72deea94393ac1c9d6a20cf9f383b
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.36.0'
30
+ SDK_VERSION = '1.37.1'
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