kameleoon-client-ruby 3.17.0 → 3.17.1

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: a9254260f1962a3abfa79d2a583188660b28540faea927f0eb04efc1898dc4c0
4
- data.tar.gz: 231728dd53a2e4662b4b705fa63905a10a1b5598eb1875e1959a4124cf6334da
3
+ metadata.gz: 7fc2b3610def24ae9ceb3a3e11f8a1e6e360c12359631c47c1af18e7bdd67a2b
4
+ data.tar.gz: ebe8a7cd7920d0522c8cde5f09e02db0050b3ccbd81fe47ffde2452c1c40c136
5
5
  SHA512:
6
- metadata.gz: d90ed8a74b0e64bd244f85c79381bdaad76adff7103cd1c1afde6578d98b4838d53f8466040b6fa6537706e91eb6589d0c558193be892b0ddb6785d93e4894de
7
- data.tar.gz: 33dca1c8fcde8dcb441dd9eb001b329d4798a9900411c98a1a020331a832734d52f74d2e7b9204ffe5576f6c4cc8a0039610214e6b7fa1e9bd82ad6e12f2d8f1
6
+ metadata.gz: 2f4ec5f9d42e0260ad0646a837654c412b15e42583763992ab7df04167357e4d670874cfad5abfb017212cbcce224cef5828e4f7df10ae94305ee7efa1eb36ec
7
+ data.tar.gz: 2c562cccbdf690902f653fc13b961a3197ef493be9886253842e369943c2935d90fc50bac9e5aba98a4c1bff0171db1a6a663bf14c1b169a19bd418936d59f80
@@ -1058,11 +1058,19 @@ module Kameleoon
1058
1058
  holdout = @data_manager.data_file.holdout
1059
1059
  return true if holdout.nil?
1060
1060
 
1061
- in_holdout_variation_key = 'in-holdout'
1062
1061
  Logging::KameleoonLogger.debug(
1063
1062
  "CALL: KameleoonClient.visitor_not_in_holdout?(visitor, visitor_code: '%s', track: %s, save: %s, " \
1064
1063
  'bucketing_custom_data_index: %s)', visitor_code, track, save, bucketing_custom_data_index
1065
1064
  )
1065
+
1066
+ consent, blocking_behaviour = _get_consent_and_blocking_behaviour(visitor)
1067
+ if consent == DataManager::LegalConsent::NOT_GIVEN &&
1068
+ blocking_behaviour == Configuration::ConsentBlockingBehaviour::COMPLETELY_BLOCKED
1069
+ raise FeatureEnvironmentDisabled,
1070
+ "Evaluation for a holdout is blocked because visitor's consent was not provided."
1071
+ end
1072
+
1073
+ in_holdout_variation_key = 'in-holdout'
1066
1074
  is_not_in_holdout = true
1067
1075
  code_for_hash = get_code_for_hash(visitor, visitor_code, bucketing_custom_data_index)
1068
1076
  variation_hash = Utils::Hasher.obtain(code_for_hash, holdout.id)
@@ -1179,9 +1187,7 @@ module Kameleoon
1179
1187
  visitor_code, feature_flag
1180
1188
  )
1181
1189
  visitor = @visitor_manager.get_visitor(visitor_code)
1182
- datafile = @data_manager.data_file
1183
- consent = datafile.settings.is_consent_required ?
1184
- visitor&.legal_consent || DataManager::LegalConsent::UNKNOWN : DataManager::LegalConsent::GIVEN
1190
+ consent, blocking_behaviour = _get_consent_and_blocking_behaviour(visitor)
1185
1191
  code_for_hash = get_code_for_hash(visitor, visitor_code, feature_flag.bucketing_custom_data_index)
1186
1192
  # no rules -> return default_variation_key
1187
1193
  eval_exp = nil
@@ -1207,7 +1213,6 @@ module Kameleoon
1207
1213
  if hash_rule <= rule.exposition
1208
1214
  # Checking if the evaluation is blocked due to the consent policy
1209
1215
  if (consent == DataManager::LegalConsent::NOT_GIVEN) && rule.experimentation_type?
1210
- blocking_behaviour = datafile.settings.blocking_behaviour_if_consent_not_given
1211
1216
  break if blocking_behaviour == Configuration::ConsentBlockingBehaviour::PARTIALLY_BLOCKED
1212
1217
 
1213
1218
  # TODO: In the next major, create a new error type for the Completely Blocked by Consent error
@@ -1243,6 +1248,18 @@ module Kameleoon
1243
1248
  eval_exp
1244
1249
  end
1245
1250
 
1251
+ def _get_consent_and_blocking_behaviour(visitor)
1252
+ datafile = @data_manager.data_file
1253
+ behaviour = datafile.settings.blocking_behaviour_if_consent_not_given
1254
+
1255
+ consent = DataManager::LegalConsent::GIVEN
1256
+ if datafile.settings.is_consent_required
1257
+ consent = visitor&.legal_consent || DataManager::LegalConsent::UNKNOWN
1258
+ end
1259
+
1260
+ [consent, behaviour]
1261
+ end
1262
+
1246
1263
  def calculate_variation_key(eval_exp, default_value)
1247
1264
  Logging::KameleoonLogger.debug(
1248
1265
  "CALL: KameleoonClient.calculate_variation_key(eval_exp: %s, default_value: '%s') ", eval_exp, default_value
@@ -24,15 +24,16 @@ module Kameleoon
24
24
  @filter = filter
25
25
  @visit_number = 0
26
26
  current_visit = hash['currentVisit']
27
- parse_visit(current_visit, false) unless current_visit.nil?
27
+ parse_visit(current_visit, 0) unless current_visit.nil?
28
28
  previous_visits = hash['previousVisits']
29
29
  previous_visits = [] if previous_visits.nil?
30
30
 
31
31
  if previous_visits.size.positive?
32
32
  prev_visits = []
33
- previous_visits.each do |visit|
33
+ previous_visits.each_index do |i|
34
+ visit = previous_visits[i]
34
35
  prev_visits.push(VisitorVisits::Visit.new(visit['timeStarted'] || 0, visit['timeLastEvent']))
35
- parse_visit(visit, true)
36
+ parse_visit(visit, i + 1)
36
37
  end
37
38
  @visitor_visits = VisitorVisits.new(prev_visits, @visit_number)
38
39
  end
@@ -74,7 +75,7 @@ module Kameleoon
74
75
 
75
76
  private
76
77
 
77
- def parse_visit(hash, is_prev_visit)
78
+ def parse_visit(hash, visit_offset)
78
79
  @visitor_code = hash['visitorCode'] if @visitor_code.nil?
79
80
  custom_data_events = hash['customDataEvents']
80
81
  parse_custom_data(custom_data_events) if !custom_data_events.nil? && custom_data_events.size.positive?
@@ -88,7 +89,7 @@ module Kameleoon
88
89
  @geolocation = parse_geolocation(geolocation_events) if @geolocation.nil? && !geolocation_events.nil? && \
89
90
  geolocation_events.size.positive?
90
91
  static_data_events = hash['staticDataEvent']
91
- parse_static_data(static_data_events, is_prev_visit) unless static_data_events.nil?
92
+ parse_static_data(static_data_events, visit_offset) unless static_data_events.nil?
92
93
  personalization_events = hash['personalizationEvents']
93
94
  parse_personalizations(personalization_events) unless personalization_events.nil?
94
95
  end
@@ -146,11 +147,11 @@ module Kameleoon
146
147
  Geolocation.new(data['country'], data['region'], data['city'])
147
148
  end
148
149
 
149
- def parse_static_data(static_data_event, is_prev_visit)
150
+ def parse_static_data(static_data_event, visit_offset)
150
151
  data = static_data_event['data']
151
152
  if @visit_number.zero?
152
- @visit_number = data['visitNumber'] || 0
153
- @visit_number += 1 if is_prev_visit && @visit_number.positive?
153
+ remote_visit_number = data['visitNumber']
154
+ @visit_number = remote_visit_number + visit_offset unless remote_visit_number.nil?
154
155
  end
155
156
  if @filter.device && @device.nil?
156
157
  device_type = data['deviceType']
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kameleoon
4
- SDK_VERSION = '3.17.0'
4
+ SDK_VERSION = '3.17.1'
5
5
  SDK_NAME = 'RUBY'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kameleoon-client-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.17.0
4
+ version: 3.17.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kameleoon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-11-21 00:00:00.000000000 Z
11
+ date: 2025-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: em-http-request