vwo-sdk 1.41.0 → 1.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/vwo/constants.rb +1 -1
- data/lib/vwo/core/bucketer.rb +30 -3
- data/lib/vwo/utils/get_account_flags.rb +57 -0
- data/lib/vwo.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2cb87cff89342e4af9dcea2a923b32353c8603c5f1eb536ff886c70f51b6fbce
|
4
|
+
data.tar.gz: fc5138f9a838a7515a736ba51026a7c5626911ad16cd46b25580dadeb80c710f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2ff4704e49b08f46f46c70e47b99a0bdd4113f0086feb9faf511c120ad93f95ccd2e113bdfe32191f4ac2d74992b0e59a7aa84f4347612f2a9a3606a0d4f81d
|
7
|
+
data.tar.gz: a0fe763ee6ad8a6e040d379d9f463c46e0962289a096cc94b6942805fd0dd4e5c6deac9e1cb205f60a70634b9f13166a1f43d4edd26e69fb67dd2a317f024a41
|
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.
|
30
|
+
SDK_VERSION = '1.42.0'
|
31
31
|
SDK_NAME = 'ruby'
|
32
32
|
VWO_DELIMITER = '_vwo_'
|
33
33
|
MAX_EVENTS_PER_REQUEST = 5000
|
data/lib/vwo/core/bucketer.rb
CHANGED
@@ -17,6 +17,7 @@ require_relative '../enums'
|
|
17
17
|
require_relative '../utils/validations'
|
18
18
|
require_relative '../utils/log_message'
|
19
19
|
require_relative '../constants'
|
20
|
+
require_relative '../utils/get_account_flags'
|
20
21
|
|
21
22
|
class VWO
|
22
23
|
module Core
|
@@ -99,11 +100,29 @@ class VWO
|
|
99
100
|
|
100
101
|
return unless campaign
|
101
102
|
|
103
|
+
isNBv2 = VWO::Utils::GetAccountFlags.get_instance.get_isNbv2_flag
|
104
|
+
isNB = VWO::Utils::GetAccountFlags.get_instance.get_isNB_flag
|
105
|
+
account_id = VWO::Utils::GetAccountFlags.get_instance.get_account_id
|
106
|
+
|
102
107
|
user_id_for_hash_value = user_id
|
103
|
-
|
108
|
+
multiplier = MAX_TRAFFIC_VALUE.to_f / campaign['percentTraffic'] / 100
|
109
|
+
|
110
|
+
if ((!isNB && !isNBv2) || (isNB && campaign['isOB'])) && campaign['percentTraffic']
|
111
|
+
# Old bucketing logic if feature flag is OFF or
|
112
|
+
# Feature flag is ON and campaign is old i.e. created before feature flag was turned ON
|
113
|
+
user_id_for_hash_value = "#{campaign['id']}_#{user_id}" if campaign['isBucketingSeedEnabled']
|
114
|
+
multiplier = MAX_TRAFFIC_VALUE.to_f / campaign['percentTraffic'] / 100
|
115
|
+
elsif ((isNB && !campaign['isOB'] && !isNBv2) || (isNBv2 && campaign['isOBv2']))
|
116
|
+
# New bucketing logic if feature flag is ON and campaign is new i.e. created after feature flag was turned ON
|
117
|
+
user_id_for_hash_value = user_id
|
118
|
+
multiplier = 1
|
119
|
+
else
|
120
|
+
# new bucketing V2 Logic
|
121
|
+
user_id_for_hash_value = "#{campaign['id']}_#{account_id}_#{user_id}"
|
122
|
+
multiplier = 1
|
123
|
+
end
|
124
|
+
|
104
125
|
hash_value = MurmurHash3::V32.str_hash(user_id_for_hash_value, SEED_VALUE) & U_MAX_32_BIT
|
105
|
-
normalize = MAX_TRAFFIC_VALUE.to_f / campaign['percentTraffic']
|
106
|
-
multiplier = normalize / 100
|
107
126
|
bucket_value = get_bucket_value(
|
108
127
|
hash_value,
|
109
128
|
MAX_TRAFFIC_VALUE,
|
@@ -154,6 +173,14 @@ class VWO
|
|
154
173
|
elsif campaign['isBucketingSeedEnabled']
|
155
174
|
user_id_for_hash_value = "#{campaign['id']}_#{user_id}"
|
156
175
|
end
|
176
|
+
|
177
|
+
isNBv2 = VWO::Utils::GetAccountFlags.get_instance.get_isNbv2_flag
|
178
|
+
isNB = VWO::Utils::GetAccountFlags.get_instance.get_isNB_flag
|
179
|
+
|
180
|
+
if isNBv2 || isNB || campaign['isBucketingSeedEnabled']
|
181
|
+
user_id_for_hash_value = "#{campaign['id']}_#{user_id}"
|
182
|
+
end
|
183
|
+
|
157
184
|
hash_value = MurmurHash3::V32.str_hash(user_id_for_hash_value, SEED_VALUE) & U_MAX_32_BIT
|
158
185
|
bucket_value = get_bucket_value(hash_value, MAX_TRAFFIC_PERCENT)
|
159
186
|
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# Copyright 2019-2022 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_relative '../constants'
|
16
|
+
|
17
|
+
# Utility module for generating uuid
|
18
|
+
class VWO
|
19
|
+
module Utils
|
20
|
+
class GetAccountFlags
|
21
|
+
@@instance = nil
|
22
|
+
|
23
|
+
def self.get_instance
|
24
|
+
@@instance = new if @@instance.nil?
|
25
|
+
@@instance
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_isNbv2_flag
|
29
|
+
isNBv2 = false
|
30
|
+
if @settings && @settings.key?('isNBv2') && @settings['isNBv2']
|
31
|
+
isNBv2 = @settings['isNBv2']
|
32
|
+
end
|
33
|
+
return isNBv2
|
34
|
+
end
|
35
|
+
|
36
|
+
def get_isNB_flag
|
37
|
+
isNB = false
|
38
|
+
if @settings && @settings.key?('isNB') && @settings['isNB']
|
39
|
+
isNB = @settings['isNB']
|
40
|
+
end
|
41
|
+
return isNB
|
42
|
+
end
|
43
|
+
|
44
|
+
def get_account_id
|
45
|
+
account_id = nil
|
46
|
+
if @settings && @settings.key?('accountId') && @settings['accountId']
|
47
|
+
account_id = @settings['accountId']
|
48
|
+
end
|
49
|
+
return account_id
|
50
|
+
end
|
51
|
+
|
52
|
+
def set_settings(settings)
|
53
|
+
@settings = settings
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/lib/vwo.rb
CHANGED
@@ -133,7 +133,7 @@ class VWO
|
|
133
133
|
@config.process_settings_file
|
134
134
|
@settings_file = @config.get_settings_file
|
135
135
|
DataLocationManager.get_instance.set_settings(@settings_file)
|
136
|
-
|
136
|
+
GetAccountFlags.get_instance.set_settings(@settings_file)
|
137
137
|
@usage_stats = VWO::Services::UsageStats.new(usage_stats, @is_development_mode)
|
138
138
|
|
139
139
|
if options.key?(:batch_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.
|
4
|
+
version: 1.42.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- VWO
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: codecov
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- lib/vwo/utils/data_location_manager.rb
|
124
124
|
- lib/vwo/utils/feature.rb
|
125
125
|
- lib/vwo/utils/function.rb
|
126
|
+
- lib/vwo/utils/get_account_flags.rb
|
126
127
|
- lib/vwo/utils/impression.rb
|
127
128
|
- lib/vwo/utils/log_message.rb
|
128
129
|
- lib/vwo/utils/request.rb
|