kameleoon-client-ruby 3.2.0 → 3.3.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: b8dea61e52fdfa38f0fc3d2161711fe169940de6053d9d372fef06b30e70975f
4
- data.tar.gz: 201acbdb7b3597d4637207c6f599c04dc9bbf0984de60fb93904569193152230
3
+ metadata.gz: '019ae7a1fe145f50f68beea1eb05bcae993d4061a2b1bdb2fe4324fc4215aa39'
4
+ data.tar.gz: fe9637047ba81b006c1b19a4c85e82fa5641a4d3f666fe14cb28ee243076b6ac
5
5
  SHA512:
6
- metadata.gz: d3ecf83261db7d1ed52d231c141521df16ea5f2d0e42240c80db684537dd5ab32f5047430446fe1779f40485357b37ea455416369d5dce0f748c76ed7b132103
7
- data.tar.gz: f5e1641dd1311bac6620c6db63f396fbe7d46f96eecab69713eef49e9e81f67a24c5644f68b7fdff4dd99455a5c480be57ab26e7372947b02eefec3033d310fc
6
+ metadata.gz: 5455718dd4a68c584c280e4004ff1c96e28b35d7bfcd9bd8299c68b9d0f3930bd064e16057ce71bbfc386911f106839f54a6398165e6966cad5ce5a4388ccbe9
7
+ data.tar.gz: 7a2e231a4625c642a56354615999543c26d7e882d8fc7a2c743f7f4f045d01bc88d5dafd227757fd88f308053610f22f21bfa6cbadd79eafe2b7f2bc3a5e03b7
@@ -7,7 +7,8 @@ require 'kameleoon/configuration/custom_data_info'
7
7
  module Kameleoon
8
8
  module Configuration
9
9
  class DataFile
10
- attr_reader :settings, :feature_flags, :has_any_targeted_delivery_rule, :feature_flag_by_id, :rule_by_segment_id, :variation_by_id, :custom_data_info
10
+ attr_reader :settings, :feature_flags, :has_any_targeted_delivery_rule, :feature_flag_by_id, :rule_by_segment_id,
11
+ :variation_by_id, :custom_data_info
11
12
 
12
13
  def initialize(environment, log_func = nil)
13
14
  @settings = Settings.new
@@ -50,10 +51,10 @@ module Kameleoon
50
51
  @variation_by_id = {}
51
52
 
52
53
  @feature_flags.each_value do |feature_flag|
54
+ @feature_flag_by_id[feature_flag.id] = feature_flag
53
55
  next if feature_flag.rules.nil?
54
56
 
55
57
  feature_flag.rules.each do |rule|
56
- @feature_flag_by_id[feature_flag.id] = feature_flag
57
58
  @rule_by_segment_id[rule.segment_id] = rule
58
59
  rule.variation_by_exposition.each do |variation|
59
60
  @variation_by_id[variation.variation_id] = variation
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kameleoon
4
+ class KcsHeat
5
+ attr_reader :values
6
+
7
+ def initialize(values)
8
+ @values = values
9
+ @values.freeze
10
+ end
11
+ end
12
+ end
@@ -18,7 +18,8 @@ module Kameleoon
18
18
  # Visitor is a container of all data assigned to a visitor.
19
19
  # It is thread-safe
20
20
  class Visitor
21
- attr_reader :last_activity_time, :user_agent, :device, :browser, :geolocation, :operating_system, :cookie, :visitor_visits
21
+ attr_reader :last_activity_time, :user_agent, :device, :browser, :geolocation, :operating_system, :cookie,
22
+ :kcs_heat, :visitor_visits
22
23
  attr_accessor :legal_consent, :mapping_identifier
23
24
 
24
25
  def initialize
@@ -101,6 +102,8 @@ module Kameleoon
101
102
  set_operating_system(data, overwrite)
102
103
  when Kameleoon::Geolocation
103
104
  set_geolocation(data, overwrite)
105
+ when Kameleoon::KcsHeat
106
+ set_kcs_heat(data)
104
107
  when Kameleoon::VisitorVisits
105
108
  set_visitor_visits(data)
106
109
  else
@@ -184,6 +187,10 @@ module Kameleoon
184
187
  @operating_system = operating_system if overwrite || @operating_system == nil
185
188
  end
186
189
 
190
+ def set_kcs_heat(kcs_heat)
191
+ @kcs_heat = kcs_heat
192
+ end
193
+
187
194
  def set_visitor_visits(visitor_visits)
188
195
  @visitor_visits = visitor_visits
189
196
  end
@@ -8,6 +8,13 @@ module Kameleoon
8
8
  @previous_visit_timestamps = previous_visit_timestamps
9
9
  @previous_visit_timestamps.freeze
10
10
  end
11
+
12
+ def self.get_previous_visit_timestamps(visitor_visits)
13
+ visitor_visits.is_a?(VisitorVisits) ? visitor_visits.previous_visit_timestamps : []
14
+ end
15
+
16
+ def self.visitor_visits?(obj)
17
+ obj.nil? || obj.is_a?(VisitorVisits)
18
+ end
11
19
  end
12
20
  end
13
-
@@ -353,7 +353,10 @@ module Kameleoon
353
353
  # @raise [Kameleoon::Exception::VisitorCodeInvalid] If the visitor code is empty or longer than 255 chars
354
354
  #
355
355
  # @return [Array] array of active feature flag keys for a visitor
356
+ #
357
+ # DEPRECATED. Please use `get_active_features` instead.
356
358
  def get_active_feature_list_for_visitor(visitor_code)
359
+ warn '[DEPRECATION] `get_active_feature_list_for_visitor` is deprecated. Please use `get_active_features` instead.'
357
360
  Utils::VisitorCode.validate(visitor_code)
358
361
  list_keys = []
359
362
  @data_file.feature_flags.each do |feature_key, feature_flag|
@@ -366,6 +369,50 @@ module Kameleoon
366
369
  list_keys
367
370
  end
368
371
 
372
+ ##
373
+ # Returns a Hash that contains the assigned variations of the active features using the keys
374
+ # of the corresponding active features.
375
+ #
376
+ # @param [String] visitor_code unique identifier of a visitor.
377
+ #
378
+ # @raise [Kameleoon::Exception::VisitorCodeInvalid] If the visitor code is empty or longer than 255 chars or is nil
379
+ #
380
+ # @return [Hash] Hash of active features for a visitor
381
+ def get_active_features(visitor_code)
382
+ Utils::VisitorCode.validate(visitor_code)
383
+ map_active_features = {}
384
+
385
+ @data_file.feature_flags.each_value do |feature_flag|
386
+ next unless feature_flag.environment_enabled
387
+
388
+ var_by_exp, rule = _calculate_variation_key_for_feature(visitor_code, feature_flag)
389
+ variation_key = _get_variation_key(var_by_exp, rule, feature_flag)
390
+
391
+ next if variation_key == Configuration::VariationType::VARIATION_OFF
392
+
393
+ variation = feature_flag.get_variation_key(variation_key)
394
+ variables = {}
395
+
396
+ variation&.variables&.each do |variable|
397
+ variables[variable.key] = Kameleoon::Types::Variable.new(
398
+ variable.key,
399
+ variable.type,
400
+ _parse_feature_variable(variable)
401
+ )
402
+ end
403
+
404
+ variables.freeze
405
+ map_active_features[feature_flag.feature_key] = Kameleoon::Types::Variation.new(
406
+ variation_key,
407
+ var_by_exp ? var_by_exp.variation_id : nil,
408
+ rule ? rule.experiment_id : nil,
409
+ variables
410
+ )
411
+ end
412
+
413
+ map_active_features.freeze
414
+ end
415
+
369
416
  ##
370
417
  # The `on_update_configuration()` method allows you to handle the event when configuration
371
418
  # has updated data. It takes one input parameter: callable **handler**. The handler
@@ -6,7 +6,6 @@ require 'kameleoon/types/remote_visitor_data_filter'
6
6
  module Kameleoon
7
7
  module Managers
8
8
  module RemoteData
9
-
10
9
  class RemoteDataManager
11
10
  attr_reader :network_manager, :visitor_manger, :log_func
12
11
 
@@ -36,7 +35,6 @@ module Kameleoon
36
35
  data_to_return
37
36
  end
38
37
 
39
-
40
38
  ##
41
39
  # helper method used by `get_remote_visitor_data`
42
40
  def parse_custom_data_array(visitor_code, response)
@@ -54,4 +52,4 @@ module Kameleoon
54
52
  end
55
53
  end
56
54
  end
57
- end
55
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- #
2
+
3
3
  require 'kameleoon/data/manager/page_view_visit'
4
4
  require 'kameleoon/data/manager/assigned_variation'
5
5
  require 'kameleoon/data/visitor_visits'
@@ -8,13 +8,15 @@ require 'kameleoon/data/device'
8
8
  require 'kameleoon/data/conversion'
9
9
  require 'kameleoon/data/custom_data'
10
10
  require 'kameleoon/data/geolocation'
11
+ require 'kameleoon/data/kcs_heat'
11
12
  require 'kameleoon/data/page_view'
12
13
 
13
14
  module Kameleoon
14
15
  module Managers
15
16
  module RemoteData
16
17
  class RemoteVisitorData
17
- attr_reader :custom_data_dict, :page_view_visits, :conversions, :experiments, :device, :browser, :operating_system, :geolocation, :previous_visitor_visits
18
+ attr_reader :custom_data_dict, :page_view_visits, :conversions, :experiments, :device, :browser,
19
+ :operating_system, :geolocation, :previous_visitor_visits, :kcs_heat
18
20
 
19
21
  def initialize(hash)
20
22
  current_visit = hash['currentVisit']
@@ -30,12 +32,14 @@ module Kameleoon
30
32
  end
31
33
  @previous_visitor_visits = VisitorVisits.new(times_started)
32
34
  end
35
+ @kcs_heat = parse_kcs_heat(hash['kcs'])
33
36
  end
34
37
 
35
38
  def collect_data_to_add
36
39
  data_to_add = []
37
40
  data_to_add.concat(@custom_data_dict.values) unless @custom_data_dict.nil?
38
41
  data_to_add.push(@previous_visitor_visits) unless @previous_visitor_visits.nil?
42
+ data_to_add.push(@kcs_heat) unless @kcs_heat.nil?
39
43
  data_to_add.concat(@page_view_visits.values) unless @page_view_visits.nil?
40
44
  data_to_add.concat(@experiments.values) unless @experiments.nil?
41
45
  data_to_add.concat(conversions_single_objects)
@@ -95,7 +99,7 @@ module Kameleoon
95
99
  page_view_visit = @page_view_visits[href]
96
100
  if page_view_visit.nil?
97
101
  page_view = PageView.new(href, page_event['data']['title'])
98
- @page_view_visits[href] = Kameleoon::DataManager::PageViewVisit.new(page_view, 1, page_event['time'])
102
+ @page_view_visits[href] = DataManager::PageViewVisit.new(page_view, 1, page_event['time'])
99
103
  else
100
104
  page_view_visit.increase_page_visits
101
105
  end
@@ -108,7 +112,10 @@ module Kameleoon
108
112
  id = experiment_event['data']['id']
109
113
  variation = @experiments[id]
110
114
  if variation.nil?
111
- variation = Kameleoon::DataManager::AssignedVariation.new(id, experiment_event['data']['variationId'], Kameleoon::Configuration::RuleType::UNKNOWN, assignment_time: experiment_event['time'])
115
+ variation = DataManager::AssignedVariation.new(
116
+ id, experiment_event['data']['variationId'],
117
+ Configuration::RuleType::UNKNOWN, assignment_time: experiment_event['time']
118
+ )
112
119
  @experiments[id] = variation
113
120
  end
114
121
  end
@@ -130,33 +137,52 @@ module Kameleoon
130
137
 
131
138
  def parse_static_data(static_data_event)
132
139
  return if @device != nil && @browser != nil && @operating_system != nil
140
+
133
141
  data = static_data_event['data']
134
- if @device == nil
142
+ if @device.nil?
135
143
  device_type = data['deviceType']
136
- @device = Device.new(device_type) if device_type != nil
144
+ @device = Device.new(device_type) unless device_type.nil?
137
145
  end
138
- if @browser == nil
139
- browser_type = Kameleoon::BrowserType.from_name(data['browser'])
140
- @browser = Browser.new(browser_type, data['browserVersion']) if browser_type != nil
146
+ if @browser.nil?
147
+ browser_type = BrowserType.from_name(data['browser'])
148
+ @browser = Browser.new(browser_type, data['browserVersion']) unless browser_type.nil?
141
149
  end
142
- if @operating_system == nil
143
- operating_system_type = Kameleoon::OperatingSystemType.from_name(data['os'])
144
- @operating_system = OperatingSystem.new(operating_system_type) if operating_system_type != nil
150
+ if @operating_system.nil?
151
+ operating_system_type = OperatingSystemType.from_name(data['os'])
152
+ @operating_system = OperatingSystem.new(operating_system_type) unless operating_system_type.nil?
145
153
  end
146
154
  end
147
155
 
148
156
  def conversions_single_objects
149
157
  objects = []
150
- unless @conversions.nil?
151
- objects += @conversions
152
- end
158
+ objects += @conversions unless @conversions.nil?
153
159
  objects.push(@device) unless @device.nil?
154
160
  objects.push(@browser) unless @browser.nil?
155
161
  objects.push(@operating_system) unless @operating_system.nil?
156
162
  objects.push(@geolocation) unless @geolocation.nil?
157
163
  objects
158
164
  end
165
+
166
+ def parse_kcs_heat(kcs)
167
+ return nil if kcs.nil?
168
+
169
+ value_map = {}
170
+ kcs.each do |str_key_moment_id, goal_scores|
171
+ next unless str_key_moment_id.is_a?(String) && goal_scores.is_a?(Hash)
172
+
173
+ goal_score_map = {}
174
+ goal_scores.each do |str_goal_id, score|
175
+ next unless str_goal_id.is_a?(String) && (score.is_a?(Float) || score.is_a?(Integer))
176
+
177
+ goal_id = str_goal_id.to_i
178
+ goal_score_map[goal_id] = score
179
+ end
180
+ key_moment_id = str_key_moment_id.to_i
181
+ value_map[key_moment_id] = goal_score_map
182
+ end
183
+ KcsHeat.new(value_map)
184
+ end
159
185
  end
160
186
  end
161
187
  end
162
- end
188
+ end
@@ -52,12 +52,13 @@ module Kameleoon
52
52
  params[is_unique_identifier ? :mappingValue : :visitorCode] = visitor_code
53
53
  params[:maxNumberPreviousVisits] = filter.previous_visit_amount
54
54
  params[:version] = 0
55
- params[:currentVisit] = filter.current_visit if filter.current_visit
56
- params[:customData] = filter.custom_data if filter.custom_data
57
- params[:conversion] = filter.conversions if filter.conversions
58
- params[:geolocation] = filter.geolocation if filter.geolocation
59
- params[:experiment] = filter.experiments if filter.experiments
60
- params[:page] = filter.page_views if filter.page_views
55
+ params[:kcs] = true if filter.kcs
56
+ params[:currentVisit] = true if filter.current_visit
57
+ params[:customData] = true if filter.custom_data
58
+ params[:conversion] = true if filter.conversions
59
+ params[:geolocation] = true if filter.geolocation
60
+ params[:experiment] = true if filter.experiments
61
+ params[:page] = true if filter.page_views
61
62
  params[:staticData] = true if filter.device || filter.browser || filter.operating_system
62
63
  "https://#{@data_api_domain}#{VISITOR_DATA_PATH}?#{UriHelper.encode_query(params)}"
63
64
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'kameleoon/exceptions'
3
4
 
4
5
  module Kameleoon
@@ -26,6 +27,7 @@ module Kameleoon
26
27
  VISITS = 'VISITS'
27
28
  SAME_DAY_VISITS = 'SAME_DAY_VISITS'
28
29
  NEW_VISITORS = 'NEW_VISITORS'
30
+ HEAT_SLICE = 'HEAT_SLICE'
29
31
  end
30
32
 
31
33
  module Operator
@@ -11,6 +11,7 @@ require_relative 'conditions/conversion_condition'
11
11
  require_relative 'conditions/browser_condition'
12
12
  require_relative 'conditions/sdk_language_condition'
13
13
  require_relative 'conditions/geolocation_condition'
14
+ require_relative 'conditions/kcs_heat_range_condition'
14
15
  require_relative 'conditions/operating_system_condition'
15
16
  require_relative 'conditions/cookie_condition'
16
17
  require_relative 'conditions/segment_condition'
@@ -67,6 +68,8 @@ module Kameleoon
67
68
  VisitorNewReturnCondition.new(condition_json)
68
69
  when ConditionType::FIRST_VISIT, ConditionType::LAST_VISIT
69
70
  TimeElapsedSinceVisitCondition.new(condition_json)
71
+ when ConditionType::HEAT_SLICE
72
+ KcsHeatRangeCondition.new(condition_json)
70
73
  else
71
74
  UnknownCondition.new(condition_json)
72
75
  end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'kameleoon/data/device'
4
+
5
+ module Kameleoon
6
+ # @api private
7
+ module Targeting
8
+ # KcsHeatRangeCondition is a condition for checking KCS heat
9
+ class KcsHeatRangeCondition < Condition
10
+ def initialize(json_condition)
11
+ super(json_condition)
12
+ @goal_id = json_condition['goalId'] || -1
13
+ @key_moment_id = json_condition['keyMomentId'] || -1
14
+ @lower_bound = json_condition['lowerBound'] || Float::MAX
15
+ @upper_bound = json_condition['upperBound'] || Float::MIN
16
+ end
17
+
18
+ def check(kcs_heat)
19
+ kcs_heat.is_a?(Kameleoon::KcsHeat) && check_targeting(kcs_heat)
20
+ end
21
+
22
+ private
23
+
24
+ def check_targeting(kcs_heat)
25
+ return false unless kcs_heat.values.is_a?(Hash)
26
+
27
+ goal_scores = kcs_heat.values[@key_moment_id]
28
+ return false unless goal_scores.is_a?(Hash)
29
+
30
+ score = goal_scores[@goal_id]
31
+ return false unless score.is_a?(Float) || score.is_a?(Integer)
32
+
33
+ (score >= @lower_bound) && (score <= @upper_bound)
34
+ end
35
+ end
36
+ end
37
+ end
@@ -20,20 +20,19 @@ module Kameleoon
20
20
 
21
21
  def check(data)
22
22
  return false unless data.is_a?(Kameleoon::Targeting::TargetFeatureFlagInfo) && data.variations_storage.size != 0
23
- get_rules(data).any? {|rule| check_rule(data, rule)}
23
+
24
+ get_rules(data).any? { |rule| check_rule(data, rule) }
24
25
  end
25
26
 
26
27
  private def check_rule(data, rule)
27
- return false if !rule.is_a?(Kameleoon::Configuration::Rule) || rule.experiment_id == nil
28
+ return false if !rule.is_a?(Kameleoon::Configuration::Rule) || rule.experiment_id.nil?
28
29
 
29
- if @condition_rule_id != nil
30
- return false if @condition_rule_id != rule.id
31
- end
30
+ return false if !@condition_rule_id.nil? && (@condition_rule_id != rule.id)
32
31
 
33
32
  variation = data.variations_storage.get(rule.experiment_id)
34
- return false if variation == nil
33
+ return false if variation.nil?
35
34
 
36
- return true if @condition_variation_key == nil
35
+ return true if @condition_variation_key.nil?
37
36
 
38
37
  variation = data.data_file.variation_by_id[variation.variation_id]
39
38
 
@@ -44,10 +43,7 @@ module Kameleoon
44
43
 
45
44
  def get_rules(data)
46
45
  feature_flag = data.data_file.feature_flag_by_id[@feature_flag_id]
47
- if feature_flag != nil
48
- return feature_flag.rules
49
- end
50
- []
46
+ feature_flag&.rules || []
51
47
  end
52
48
  end
53
49
 
@@ -6,7 +6,6 @@ require 'kameleoon/data/visitor_visits'
6
6
  module Kameleoon
7
7
  # @api private
8
8
  module Targeting
9
-
10
9
  class TimeElapsedSinceVisitCondition < NumberCondition
11
10
  def initialize(json_condition)
12
11
  count_in_millis = json_condition['countInMillis']
@@ -15,7 +14,7 @@ module Kameleoon
15
14
  end
16
15
 
17
16
  def check(data)
18
- return false unless data.is_a?(Kameleoon::VisitorVisits) && @condition_value != nil
17
+ return false unless data.is_a?(Kameleoon::VisitorVisits) && !@condition_value.nil?
19
18
 
20
19
  previous_visits_count = data.previous_visit_timestamps.count
21
20
  if previous_visits_count >= 1
@@ -6,7 +6,6 @@ require 'time'
6
6
  module Kameleoon
7
7
  # @api private
8
8
  module Targeting
9
-
10
9
  class VisitNumberTodayCondition < NumberCondition
11
10
  def initialize(json_condition)
12
11
  visit_count = json_condition['visitCount']
@@ -14,10 +13,11 @@ module Kameleoon
14
13
  end
15
14
 
16
15
  def check(data)
17
- return false unless data.is_a?(Kameleoon::VisitorVisits) && @condition_value != nil
16
+ return false unless VisitorVisits.visitor_visits?(data) && !@condition_value.nil?
17
+
18
18
  number_of_visits_today = 0
19
- start_of_day = (Time.new.to_date.to_time.to_f * 1000).to_i # ... * 1000 for convert seconds to milliseconds
20
- for timestamp in data.previous_visit_timestamps
19
+ start_of_day = (Time.new.to_date.to_time.to_f * 1000).to_i # ... * 1000 to convert seconds to milliseconds
20
+ for timestamp in VisitorVisits.get_previous_visit_timestamps(data)
21
21
  break if timestamp < start_of_day
22
22
  number_of_visits_today += 1
23
23
  end
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'kameleoon/data/visitor_visits'
3
4
  require 'kameleoon/targeting/conditions/number_condition'
4
5
 
5
6
  module Kameleoon
6
7
  # @api private
7
8
  module Targeting
8
-
9
9
  class VisitNumberTotalCondition < NumberCondition
10
10
  def initialize(json_condition)
11
11
  visit_count = json_condition['visitCount']
@@ -13,8 +13,10 @@ module Kameleoon
13
13
  end
14
14
 
15
15
  def check(data)
16
- return false unless data.is_a?(Kameleoon::VisitorVisits) && @condition_value != nil
17
- check_targeting(data.previous_visit_timestamps.size + 1) # +1 for current visit
16
+ return false unless VisitorVisits.visitor_visits?(data) && !@condition_value.nil?
17
+
18
+ previous_visit_timestamps = VisitorVisits.get_previous_visit_timestamps(data)
19
+ check_targeting(previous_visit_timestamps.size + 1) # +1 for current visit
18
20
  end
19
21
  end
20
22
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'kameleoon/data/cookie'
4
- require 'kameleoon/version'
3
+ require 'kameleoon/data/visitor_visits'
5
4
 
6
5
  module Kameleoon
7
6
  # @api private
@@ -18,14 +17,16 @@ module Kameleoon
18
17
  end
19
18
 
20
19
  def check(data)
21
- return false unless data.is_a?(Kameleoon::VisitorVisits)
20
+ return false unless VisitorVisits.visitor_visits?(data)
21
+
22
+ previous_visit_timestamps = VisitorVisits.get_previous_visit_timestamps(data)
22
23
  case @visitor_type
23
24
  when VisitorType::NEW
24
- return data.previous_visit_timestamps.size == 0
25
+ previous_visit_timestamps.empty?
25
26
  when VisitorType::RETURNING
26
- return data.previous_visit_timestamps.size > 0
27
+ !previous_visit_timestamps.empty?
27
28
  else
28
- return false
29
+ false
29
30
  end
30
31
  end
31
32
  end
@@ -58,6 +58,8 @@ module Kameleoon
58
58
  condition_data = ExclusiveFeatureFlagInfo.new(campaign_id, visitor&.variations)
59
59
  when ConditionType::FIRST_VISIT, ConditionType::LAST_VISIT, ConditionType::VISITS, ConditionType::SAME_DAY_VISITS, ConditionType::NEW_VISITORS
60
60
  condition_data = visitor.visitor_visits unless visitor.nil?
61
+ when Kameleoon::Targeting::ConditionType::HEAT_SLICE
62
+ condition_data = visitor&.kcs_heat
61
63
  end
62
64
  condition_data
63
65
  end
@@ -3,11 +3,15 @@
3
3
  module Kameleoon
4
4
  # Module which contains all internal data of SDK
5
5
  module Types
6
-
7
6
  class RemoteVisitorDataFilter
8
- attr_reader :previous_visit_amount, :current_visit, :custom_data, :page_views, :geolocation, :device, :browser, :operating_system, :conversions, :experiments
7
+ attr_reader :previous_visit_amount, :current_visit, :custom_data, :page_views, :geolocation, :device, :browser,
8
+ :operating_system, :conversions, :experiments, :kcs
9
9
 
10
- def initialize(previous_visit_amount: 1, current_visit: true, custom_data: true, page_views: false, geolocation: false, device: false, browser: false, operating_system: false, conversions: false, experiments: false)
10
+ def initialize(
11
+ previous_visit_amount: 1, current_visit: true, custom_data: true, page_views: false,
12
+ geolocation: false, device: false, browser: false, operating_system: false, conversions: false,
13
+ experiments: false, kcs: false
14
+ )
11
15
  @previous_visit_amount = previous_visit_amount
12
16
  @current_visit = current_visit
13
17
  @custom_data = custom_data
@@ -18,6 +22,7 @@ module Kameleoon
18
22
  @operating_system = operating_system
19
23
  @conversions = conversions
20
24
  @experiments = experiments
25
+ @kcs = kcs
21
26
  end
22
27
  end
23
28
  end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kameleoon
4
+ # Module which contains all internal data of SDK
5
+ module Types
6
+ # Variable
7
+ class Variable
8
+ attr_reader :key, :type, :value
9
+
10
+ def initialize(key, type, value)
11
+ @key = key
12
+ @type = type
13
+ @value = value
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kameleoon
4
+ # Module which contains all internal data of SDK
5
+ module Types
6
+ # Variation
7
+ class Variation
8
+ attr_reader :key, :id, :experiment_id, :variables
9
+
10
+ def initialize(key, id, experiment_id, variables)
11
+ @key = key
12
+ @id = id
13
+ @experiment_id = experiment_id
14
+ @variables = variables
15
+ end
16
+ end
17
+ end
18
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Kameleoon
4
4
  SDK_NAME = 'RUBY'
5
- SDK_VERSION = '3.2.0'
5
+ SDK_VERSION = '3.3.0'
6
6
 
7
7
  # SdkManager is a helper method for fetching / obtaining version of SDK from string
8
8
  class SdkVersion
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.2.0
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kameleoon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-22 00:00:00.000000000 Z
11
+ date: 2024-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: em-http-request
@@ -91,6 +91,7 @@ files:
91
91
  - lib/kameleoon/data/data.rb
92
92
  - lib/kameleoon/data/device.rb
93
93
  - lib/kameleoon/data/geolocation.rb
94
+ - lib/kameleoon/data/kcs_heat.rb
94
95
  - lib/kameleoon/data/manager/assigned_variation.rb
95
96
  - lib/kameleoon/data/manager/data_array_storage.rb
96
97
  - lib/kameleoon/data/manager/data_map_storage.rb
@@ -136,6 +137,7 @@ files:
136
137
  - lib/kameleoon/targeting/conditions/device_condition.rb
137
138
  - lib/kameleoon/targeting/conditions/exclusive_feature_flag_condition.rb
138
139
  - lib/kameleoon/targeting/conditions/geolocation_condition.rb
140
+ - lib/kameleoon/targeting/conditions/kcs_heat_range_condition.rb
139
141
  - lib/kameleoon/targeting/conditions/number_condition.rb
140
142
  - lib/kameleoon/targeting/conditions/operating_system_condition.rb
141
143
  - lib/kameleoon/targeting/conditions/page_title_condition.rb
@@ -156,6 +158,8 @@ files:
156
158
  - lib/kameleoon/targeting/targeting_manager.rb
157
159
  - lib/kameleoon/targeting/tree_builder.rb
158
160
  - lib/kameleoon/types/remote_visitor_data_filter.rb
161
+ - lib/kameleoon/types/variable.rb
162
+ - lib/kameleoon/types/variation.rb
159
163
  - lib/kameleoon/utils.rb
160
164
  - lib/kameleoon/version.rb
161
165
  homepage: https://developers.kameleoon.com/ruby-sdk.html