vwo-sdk 1.40.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ad81c9f35c3bc9861b2b50ada2572381fcbf28d154087332cfcd161c50245e8
4
- data.tar.gz: e1b4c2b51b2b483134d99f13189d01065b9dc8bbbd21c8fd419bd49f2b88dcae
3
+ metadata.gz: 2cb87cff89342e4af9dcea2a923b32353c8603c5f1eb536ff886c70f51b6fbce
4
+ data.tar.gz: fc5138f9a838a7515a736ba51026a7c5626911ad16cd46b25580dadeb80c710f
5
5
  SHA512:
6
- metadata.gz: 3be9f5a83e3f47cc67085ca4ae55414b4c6ab667d5d4e2e3089bffa1858258b11cc6c619687c82a29ec05e22aafa6e9e01cc5446fa7433d75a68c7ee46b39abf
7
- data.tar.gz: a2f569868697c7b07215c300e2cfe304b80469ade7b38ba2853492359652e6f465c26428bce8faf6744659c5eaaf6eb2adf57af5c6ade7ff50f481466e7f8ddd
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.40.0'
30
+ SDK_VERSION = '1.42.0'
31
31
  SDK_NAME = 'ruby'
32
32
  VWO_DELIMITER = '_vwo_'
33
33
  MAX_EVENTS_PER_REQUEST = 5000
@@ -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
- user_id_for_hash_value = "#{campaign['id']}_#{user_id}" if campaign['isBucketingSeedEnabled']
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
 
data/lib/vwo/enums.rb CHANGED
@@ -21,6 +21,10 @@ class VWO
21
21
  WILDCARD = 'wildcard'
22
22
  LOWER = 'lower'
23
23
  EQUALS = 'equals'
24
+ GREATER_THAN="gt"
25
+ LESS_THAN="lt"
26
+ GREATER_THAN_EQUAL_TO="gte"
27
+ LESS_THAN_EQUAL_TO="lte"
24
28
  end
25
29
 
26
30
  module OperandValueTypes
@@ -30,6 +34,10 @@ class VWO
30
34
  ENDS_WITH = 'ends_with'
31
35
  REGEX = 'regex'
32
36
  EQUALS = 'equals'
37
+ LESS_THAN = 'less_than'
38
+ GREATER_THAN = 'greater_than'
39
+ LESS_THAN_EQUAL_TO = 'less_than_equal_to'
40
+ GREATER_THAN_EQUAL_TO = 'greater_than_equal_to'
33
41
  end
34
42
 
35
43
  module OperatorTypes
@@ -83,6 +83,43 @@ class VWO
83
83
  custom_variables_value == operand_value
84
84
  end
85
85
 
86
+ # Checks if custom_variables_value matches the regex specified by operand_value
87
+ #
88
+ # @param [String] operand_value Leaf value from the segments
89
+ # @param [Numeric] custom_variables_value Value from the custom_variables
90
+ # @return [Boolean] True or False
91
+ def less_than?(operand_value, custom_variables_value)
92
+ custom_variables_value.to_f < operand_value.to_f
93
+ end
94
+
95
+ # Checks if custom_variable_value is greater than operand_value
96
+ #
97
+ # @param [String] operand_value Leaf value from the segments
98
+ # @param [Numeric] custom_variables_value Value from the custom_variables
99
+ # @return [Boolean] True or False
100
+ def greater_than?(operand_value, custom_variables_value)
101
+ custom_variables_value.to_f > operand_value.to_f
102
+ end
103
+
104
+ # Checks if custom_variable_value is less than or equal to operand_value
105
+ #
106
+ # @param [String] operand_value Leaf value from the segments
107
+ # @param [Numeric] custom_variables_value Value from the custom_variables
108
+ # @return [Boolean] True or False
109
+ def less_than_equal_to?(operand_value, custom_variables_value)
110
+ custom_variables_value.to_f <= operand_value.to_f
111
+ end
112
+
113
+ # Checks if custom_variable_value is greater than or equal to operand_value
114
+ #
115
+ # @param [String] operand_value Leaf value from the segments
116
+ # @param [Numeric] custom_variables_value Value from the custom_variables
117
+ # @return [Boolean] True or False
118
+ def greater_than_equal_to?(operand_value, custom_variables_value)
119
+ custom_variables_value.to_f >= operand_value.to_f
120
+ end
121
+
122
+
86
123
  # Identifies the condition stated in the leaf node and evaluates the result
87
124
  #
88
125
  # @param [String] :operand_value Leaf value from the segments
@@ -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
@@ -101,6 +101,14 @@ class VWO
101
101
  else
102
102
  OperandValueTypes::EQUALS
103
103
  end
104
+ elsif operand_type_name == OperandValueTypesName::GREATER_THAN
105
+ operand_type = OperandValueTypes::GREATER_THAN
106
+ elsif operand_type_name == OperandValueTypesName::LESS_THAN
107
+ operand_type = OperandValueTypes::LESS_THAN
108
+ elsif operand_type_name == OperandValueTypesName::GREATER_THAN_EQUAL_TO
109
+ operand_type = OperandValueTypes::GREATER_THAN_EQUAL_TO
110
+ elsif operand_type_name == OperandValueTypesName::LESS_THAN_EQUAL_TO
111
+ operand_type = OperandValueTypes::LESS_THAN_EQUAL_TO
104
112
  end
105
113
 
106
114
  # In case there is an abnormal patter, it would have passed all the above if cases, which means it
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.40.0
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: 2024-04-08 00:00:00.000000000 Z
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