kameleoon-client-ruby 2.3.0 → 3.0.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/kameleoon/client_readiness.rb +40 -0
- data/lib/kameleoon/configuration/data_file.rb +41 -0
- data/lib/kameleoon/configuration/feature_flag.rb +3 -2
- data/lib/kameleoon/configuration/rule.rb +18 -3
- data/lib/kameleoon/configuration/settings.rb +3 -1
- data/lib/kameleoon/configuration/variable.rb +0 -2
- data/lib/kameleoon/configuration/variation_exposition.rb +0 -2
- data/lib/kameleoon/data/browser.rb +1 -1
- data/lib/kameleoon/data/conversion.rb +1 -1
- data/lib/kameleoon/data/custom_data.rb +10 -14
- data/lib/kameleoon/data/data.rb +22 -3
- data/lib/kameleoon/data/device.rb +2 -1
- data/lib/kameleoon/data/manager/assigned_variation.rb +38 -0
- data/lib/kameleoon/data/manager/data_array_storage.rb +43 -0
- data/lib/kameleoon/data/manager/data_map_storage.rb +43 -0
- data/lib/kameleoon/data/manager/page_view_visit.rb +19 -0
- data/lib/kameleoon/data/manager/visitor.rb +142 -0
- data/lib/kameleoon/data/manager/visitor_manager.rb +71 -0
- data/lib/kameleoon/data/page_view.rb +2 -1
- data/lib/kameleoon/exceptions.rb +30 -35
- data/lib/kameleoon/hybrid/manager.rb +13 -31
- data/lib/kameleoon/{client.rb → kameleoon_client.rb} +164 -336
- data/lib/kameleoon/kameleoon_client_config.rb +91 -0
- data/lib/kameleoon/kameleoon_client_factory.rb +42 -0
- data/lib/kameleoon/network/activity_event.rb +6 -3
- data/lib/kameleoon/network/cookie/cookie_manager.rb +84 -0
- data/lib/kameleoon/network/net_provider.rb +5 -37
- data/lib/kameleoon/network/network_manager.rb +8 -7
- data/lib/kameleoon/network/request.rb +3 -2
- data/lib/kameleoon/network/response.rb +0 -8
- data/lib/kameleoon/network/url_provider.rb +5 -3
- data/lib/kameleoon/targeting/conditions/browser_condition.rb +2 -3
- data/lib/kameleoon/targeting/conditions/conversion_condition.rb +12 -4
- data/lib/kameleoon/targeting/conditions/custom_datum.rb +19 -13
- data/lib/kameleoon/targeting/conditions/device_condition.rb +3 -4
- data/lib/kameleoon/targeting/conditions/exclusive_experiment.rb +2 -1
- data/lib/kameleoon/targeting/conditions/page_title_condition.rb +11 -4
- data/lib/kameleoon/targeting/conditions/page_url_condition.rb +18 -4
- data/lib/kameleoon/targeting/conditions/string_value_condition.rb +2 -0
- data/lib/kameleoon/targeting/conditions/target_experiment.rb +11 -6
- data/lib/kameleoon/utils.rb +41 -4
- data/lib/kameleoon/version.rb +1 -1
- data/lib/kameleoon.rb +4 -2
- metadata +14 -10
- data/lib/kameleoon/client_config.rb +0 -44
- data/lib/kameleoon/configuration/experiment.rb +0 -42
- data/lib/kameleoon/cookie.rb +0 -88
- data/lib/kameleoon/factory.rb +0 -43
- data/lib/kameleoon/network/experiment_event.rb +0 -35
- data/lib/kameleoon/storage/variation_storage.rb +0 -42
- data/lib/kameleoon/storage/visitor_variation.rb +0 -20
data/lib/kameleoon/exceptions.rb
CHANGED
@@ -16,66 +16,61 @@ module Kameleoon
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
#
|
20
|
-
class
|
21
|
-
def initialize(
|
22
|
-
super("
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
# Experiment Configuration Not Found
|
27
|
-
class ExperimentConfigurationNotFound < NotFound
|
28
|
-
def initialize(id = '')
|
29
|
-
super("Experiment #{id}")
|
19
|
+
# Feature Error
|
20
|
+
class FeatureError < KameleoonError
|
21
|
+
def initialize(msg)
|
22
|
+
super("Feature Error: #{msg}")
|
30
23
|
end
|
31
24
|
end
|
32
25
|
|
33
|
-
# Feature
|
34
|
-
class
|
26
|
+
# Feature Not Found
|
27
|
+
class FeatureNotFound < FeatureError
|
35
28
|
def initialize(id = '')
|
36
29
|
super("Feature flag #{id}")
|
37
30
|
end
|
38
31
|
end
|
39
32
|
|
40
33
|
# Feature Variable Not Found
|
41
|
-
class FeatureVariableNotFound <
|
34
|
+
class FeatureVariableNotFound < FeatureError
|
42
35
|
def initialize(key = '')
|
43
36
|
super("Feature variable #{key}")
|
44
37
|
end
|
45
38
|
end
|
46
39
|
|
47
|
-
#
|
48
|
-
class
|
49
|
-
def initialize
|
50
|
-
super(
|
40
|
+
# Feature Variation Not Found
|
41
|
+
class FeatureVariationNotFound < FeatureError
|
42
|
+
def initialize(id = '')
|
43
|
+
super("Variation #{id}")
|
51
44
|
end
|
52
45
|
end
|
53
46
|
|
54
|
-
#
|
55
|
-
class
|
56
|
-
def initialize(
|
57
|
-
|
47
|
+
# Feature Environment Disabled
|
48
|
+
class FeatureEnvironmentDisabled < FeatureError
|
49
|
+
def initialize(feature_key, environment = nil)
|
50
|
+
environment = environment.nil? ? 'default' : "'#{environment}'"
|
51
|
+
super("Feature '#{feature_key}' is disabled for #{environment} environment'")
|
58
52
|
end
|
59
53
|
end
|
60
54
|
|
61
|
-
#
|
62
|
-
class
|
63
|
-
def initialize(
|
64
|
-
super("
|
55
|
+
# Config Error
|
56
|
+
class ConfigError < KameleoonError
|
57
|
+
def initialize(msg)
|
58
|
+
super("Config Error: #{msg}")
|
65
59
|
end
|
66
60
|
end
|
67
61
|
|
68
|
-
#
|
69
|
-
class
|
70
|
-
|
71
|
-
|
72
|
-
|
62
|
+
# Config Credentials Invalid
|
63
|
+
class ConfigCredentialsInvalid < ConfigError
|
64
|
+
end
|
65
|
+
|
66
|
+
# Site Code is Empty
|
67
|
+
class SiteCodeIsEmpty < KameleoonError
|
73
68
|
end
|
74
69
|
|
75
|
-
#
|
76
|
-
class
|
77
|
-
def initialize(
|
78
|
-
super("
|
70
|
+
# Visitor Code Not Valid (empty or length > 255)
|
71
|
+
class VisitorCodeInvalid < KameleoonError
|
72
|
+
def initialize(visitor_code)
|
73
|
+
super("Visitor code '#{visitor_code}' is not valid")
|
79
74
|
end
|
80
75
|
end
|
81
76
|
end
|
@@ -10,50 +10,32 @@ module Kameleoon
|
|
10
10
|
# Will be useful for Ruby 3.0
|
11
11
|
# Abstract Manager class (interface)
|
12
12
|
class Manager
|
13
|
-
def
|
14
|
-
raise 'Abstract method `add` called'
|
15
|
-
end
|
16
|
-
|
17
|
-
def get_engine_tracking_code(_visitor)
|
13
|
+
def get_engine_tracking_code(_visitor_variations)
|
18
14
|
raise 'Abstract method `get_engine_tracking_code` called'
|
19
15
|
end
|
20
16
|
end
|
21
17
|
|
22
18
|
# Implementation of Cache with auto cleaning feature
|
23
19
|
class ManagerImpl < Manager
|
24
|
-
def initialize(expiration_time,
|
20
|
+
def initialize(expiration_time, log_func)
|
25
21
|
super()
|
26
|
-
# synchronization is necessary for adding same visitor_code from different threads
|
27
|
-
@mutex = Mutex.new
|
28
22
|
@expiration_time = expiration_time
|
29
|
-
@cache_factory = cache_factory
|
30
23
|
@log = log_func
|
31
|
-
# it's recommend to use cleaning_interval 3-4 times more than experiation_time for more performance
|
32
|
-
# in this case on every cleaning iteration storage will be cleaned 2/3 - 3/4 of volume
|
33
|
-
@cache = cache_factory.create(expiration_time, cleaning_interval)
|
34
24
|
@log.call('Hybrid Manager was successfully initialized')
|
35
25
|
end
|
36
26
|
|
37
|
-
def
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
def get_engine_tracking_code(visitor_code)
|
49
|
-
tracking_code = TC_INIT
|
50
|
-
visitor_cache = @cache.get(visitor_code)
|
51
|
-
return tracking_code if visitor_cache.nil?
|
52
|
-
|
53
|
-
visitor_cache.active_items.each_pair do |key, value|
|
54
|
-
tracking_code += format(TC_ASSIGN_VARIATION_TRIGGER_FORMAT, key, value, key)
|
27
|
+
def get_engine_tracking_code(visitor_variations)
|
28
|
+
tracking_code = [TC_INIT]
|
29
|
+
unless visitor_variations.nil?
|
30
|
+
expired_time = (Time.now - @expiration_time).to_i
|
31
|
+
visitor_variations.enumerate do |v|
|
32
|
+
if v.assignment_time > expired_time
|
33
|
+
v_code = format(TC_ASSIGN_VARIATION_TRIGGER_FORMAT, v.experiment_id, v.variation_id, v.experiment_id)
|
34
|
+
tracking_code.push(v_code)
|
35
|
+
end
|
36
|
+
end
|
55
37
|
end
|
56
|
-
tracking_code
|
38
|
+
tracking_code.join
|
57
39
|
end
|
58
40
|
end
|
59
41
|
end
|