kameleoon-client-ruby 2.3.0 → 3.1.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 +5 -0
- 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} +194 -334
- data/lib/kameleoon/kameleoon_client_config.rb +91 -0
- data/lib/kameleoon/kameleoon_client_factory.rb +42 -0
- data/lib/kameleoon/managers/warehouse/warehouse_manager.rb +33 -0
- data/lib/kameleoon/network/access_token_source.rb +109 -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 +25 -58
- data/lib/kameleoon/network/network_manager.rb +65 -43
- data/lib/kameleoon/network/request.rb +7 -2
- data/lib/kameleoon/network/response.rb +0 -8
- data/lib/kameleoon/network/url_provider.rb +30 -12
- data/lib/kameleoon/real_time/sse_client.rb +2 -0
- 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 +16 -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
@@ -5,16 +5,21 @@ module Kameleoon
|
|
5
5
|
##
|
6
6
|
# Request represents HTTP request.
|
7
7
|
class Request
|
8
|
-
attr_reader :method, :url, :content_type, :timeout, :user_agent, :data
|
8
|
+
attr_reader :method, :url, :content_type, :timeout, :user_agent, :extra_headers, :data, :access_token
|
9
9
|
|
10
|
-
def initialize(method, url, content_type, timeout, user_agent
|
10
|
+
def initialize(method, url, content_type, timeout, user_agent: nil, extra_headers: nil, data: nil)
|
11
11
|
@method = method
|
12
12
|
@url = url
|
13
13
|
@content_type = content_type
|
14
14
|
@timeout = timeout
|
15
15
|
@user_agent = user_agent
|
16
|
+
@extra_headers = extra_headers
|
16
17
|
@data = !data.nil? && data.is_a?(String) ? data.encode('UTF-8') : data
|
17
18
|
end
|
19
|
+
|
20
|
+
def authorize(access_token)
|
21
|
+
@access_token = access_token
|
22
|
+
end
|
18
23
|
end
|
19
24
|
end
|
20
25
|
end
|
@@ -12,17 +12,29 @@ module Kameleoon
|
|
12
12
|
VISITOR_DATA_PATH = '/visit/visitor'
|
13
13
|
GET_DATA_PATH = '/map/map'
|
14
14
|
POST_DATA_PATH = '/map/maps'
|
15
|
-
|
16
|
-
RT_CONFIGURATION_URL = 'https://events.kameleoon.com:8110/sse'
|
15
|
+
ACCESS_TOKEN_PATH = '/oauth/token'
|
17
16
|
|
18
|
-
|
19
|
-
|
17
|
+
CONFIGURATION_API_URL_FORMAT = 'https://sdk-config.kameleoon.eu/%s'
|
18
|
+
RT_CONFIGURATION_URL = 'https://events.kameleoon.com:8110/sse'
|
19
|
+
DEFAULT_DATA_API_DOMAIN = 'data.kameleoon.io'
|
20
|
+
TEST_DATA_API_DOMAIN = 'data.kameleoon.net'
|
21
|
+
DEFAULT_AUTOMATION_API_DOMAIN = 'api.kameleoon.com'
|
22
|
+
TEST_AUTOMATION_API_DOMAIN = 'api.kameleoon.net'
|
20
23
|
|
21
|
-
attr_reader :site_code, :
|
24
|
+
attr_reader :site_code, :data_api_domain, :automation_api_domain
|
22
25
|
|
23
|
-
def initialize(
|
26
|
+
def initialize(
|
27
|
+
site_code,
|
28
|
+
data_api_domain = DEFAULT_DATA_API_DOMAIN,
|
29
|
+
automation_api_domain = DEFAULT_AUTOMATION_API_DOMAIN
|
30
|
+
)
|
24
31
|
@site_code = site_code
|
25
|
-
@
|
32
|
+
@data_api_domain = data_api_domain
|
33
|
+
@automation_api_domain = automation_api_domain
|
34
|
+
end
|
35
|
+
|
36
|
+
def apply_data_api_domain(domain)
|
37
|
+
@data_api_domain = domain if domain.is_a?(String)
|
26
38
|
end
|
27
39
|
|
28
40
|
def make_tracking_url(visitor_code)
|
@@ -32,7 +44,7 @@ module Kameleoon
|
|
32
44
|
siteCode: @site_code,
|
33
45
|
visitorCode: visitor_code
|
34
46
|
}
|
35
|
-
"
|
47
|
+
"https://#{@data_api_domain}#{TRACKING_PATH}?#{UriHelper.encode_query(params)}"
|
36
48
|
end
|
37
49
|
|
38
50
|
def make_visitor_data_get_url(visitor_code)
|
@@ -44,7 +56,7 @@ module Kameleoon
|
|
44
56
|
customData: true,
|
45
57
|
version: 0
|
46
58
|
}
|
47
|
-
"
|
59
|
+
"https://#{@data_api_domain}#{VISITOR_DATA_PATH}?#{UriHelper.encode_query(params)}"
|
48
60
|
end
|
49
61
|
|
50
62
|
def make_api_data_get_request_url(key)
|
@@ -52,20 +64,26 @@ module Kameleoon
|
|
52
64
|
siteCode: @site_code,
|
53
65
|
key: key
|
54
66
|
}
|
55
|
-
"
|
67
|
+
"https://#{@data_api_domain}#{GET_DATA_PATH}?#{UriHelper.encode_query(params)}"
|
56
68
|
end
|
57
69
|
|
58
70
|
def make_configuration_url(environment = nil, timestamp = nil)
|
59
|
-
|
71
|
+
url = format(CONFIGURATION_API_URL_FORMAT, @site_code)
|
72
|
+
params = {}
|
60
73
|
params[:environment] = environment unless environment.nil?
|
61
74
|
params[:ts] = timestamp unless timestamp.nil?
|
62
|
-
"#{
|
75
|
+
url = "#{url}?#{UriHelper.encode_query(params)}" unless params.empty?
|
76
|
+
url
|
63
77
|
end
|
64
78
|
|
65
79
|
def make_real_time_url
|
66
80
|
params = { siteCode: @site_code }
|
67
81
|
"#{RT_CONFIGURATION_URL}?#{UriHelper.encode_query(params)}"
|
68
82
|
end
|
83
|
+
|
84
|
+
def make_access_token_url
|
85
|
+
"https://#{@automation_api_domain}#{ACCESS_TOKEN_PATH}"
|
86
|
+
end
|
69
87
|
end
|
70
88
|
end
|
71
89
|
end
|
@@ -22,9 +22,8 @@ module Kameleoon
|
|
22
22
|
@version_match_type = json_condition['versionMatchType']
|
23
23
|
end
|
24
24
|
|
25
|
-
def check(
|
26
|
-
browser
|
27
|
-
browser && check_targeting(browser)
|
25
|
+
def check(browser)
|
26
|
+
browser.is_a?(Kameleoon::Browser) && check_targeting(browser)
|
28
27
|
end
|
29
28
|
|
30
29
|
private
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'kameleoon/data/
|
3
|
+
require 'kameleoon/data/conversion'
|
4
|
+
require 'kameleoon/data/manager/data_array_storage'
|
4
5
|
|
5
6
|
module Kameleoon
|
6
7
|
# @api private
|
@@ -12,9 +13,16 @@ module Kameleoon
|
|
12
13
|
@goal_id = json_condition['goalId']
|
13
14
|
end
|
14
15
|
|
15
|
-
def check(
|
16
|
-
|
17
|
-
|
16
|
+
def check(conversion_storage)
|
17
|
+
return false unless conversion_storage.is_a?(Kameleoon::DataManager::DataArrayStorage)
|
18
|
+
return true if @goal_id.nil?
|
19
|
+
|
20
|
+
is_targeted = false
|
21
|
+
conversion_storage.enumerate do |conversion|
|
22
|
+
is_targeted = conversion.is_a?(Kameleoon::Conversion) && (@goal_id == conversion.goal_id)
|
23
|
+
break if is_targeted
|
24
|
+
end
|
25
|
+
is_targeted
|
18
26
|
end
|
19
27
|
end
|
20
28
|
end
|
@@ -12,6 +12,10 @@ module Kameleoon
|
|
12
12
|
include Kameleoon::Exception
|
13
13
|
|
14
14
|
class << self
|
15
|
+
def op_undefined(values, value)
|
16
|
+
false
|
17
|
+
end
|
18
|
+
|
15
19
|
def op_match(values, value)
|
16
20
|
re = Regexp.new(value.to_s)
|
17
21
|
values.any? { |v| re.match(v) }
|
@@ -26,7 +30,8 @@ module Kameleoon
|
|
26
30
|
end
|
27
31
|
|
28
32
|
def op_equal(values, value)
|
29
|
-
|
33
|
+
epsilon = 1e-9
|
34
|
+
values.any? { |v| (v.to_f - value.to_f).abs < epsilon }
|
30
35
|
end
|
31
36
|
|
32
37
|
def op_greater(values, value)
|
@@ -52,6 +57,7 @@ module Kameleoon
|
|
52
57
|
end
|
53
58
|
|
54
59
|
@@op = {
|
60
|
+
Operator::UNDEFINED => method(:op_undefined),
|
55
61
|
Operator::REGULAR_EXPRESSION => method(:op_match),
|
56
62
|
Operator::CONTAINS => method(:op_contains),
|
57
63
|
Operator::EXACT => method(:op_exact),
|
@@ -71,24 +77,24 @@ module Kameleoon
|
|
71
77
|
end
|
72
78
|
|
73
79
|
@type = ConditionType::CUSTOM_DATUM
|
74
|
-
@index = json_condition['customDataIndex']
|
80
|
+
@index = json_condition['customDataIndex'].to_i
|
75
81
|
@operator = json_condition['valueMatchType']
|
82
|
+
@operation = @@op[@operator]
|
76
83
|
@value = json_condition['value']
|
77
84
|
end
|
78
85
|
|
79
|
-
def check(
|
80
|
-
is_targeted =
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
86
|
+
def check(custom_data_storage)
|
87
|
+
is_targeted = nil
|
88
|
+
if custom_data_storage.is_a?(Kameleoon::DataManager::DataMapStorage)
|
89
|
+
custom_data = custom_data_storage.get(@index)
|
90
|
+
if custom_data.is_a?(Kameleoon::CustomData)
|
91
|
+
unless @operation
|
92
|
+
raise KameleoonError.new("Undefined operator #{@operator}"), "Undefined operator #{@operator}"
|
93
|
+
end
|
94
|
+
is_targeted = @operation.call(custom_data.values, @value)
|
88
95
|
end
|
89
|
-
|
90
|
-
is_targeted = @operation.call(custom_data.values, @value)
|
91
96
|
end
|
97
|
+
is_targeted = (@operator == Operator::UNDEFINED.to_s) if is_targeted.nil?
|
92
98
|
is_targeted
|
93
99
|
end
|
94
100
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'kameleoon/data/
|
3
|
+
require 'kameleoon/data/device'
|
4
4
|
|
5
5
|
module Kameleoon
|
6
6
|
# @api private
|
@@ -12,9 +12,8 @@ module Kameleoon
|
|
12
12
|
@device_type = json_condition['device']
|
13
13
|
end
|
14
14
|
|
15
|
-
def check(
|
16
|
-
device
|
17
|
-
device && @device_type == device.device_type
|
15
|
+
def check(device)
|
16
|
+
device.is_a?(Kameleoon::Device) && @device_type == device.device_type
|
18
17
|
end
|
19
18
|
end
|
20
19
|
end
|
@@ -10,7 +10,8 @@ module Kameleoon
|
|
10
10
|
def check(data)
|
11
11
|
experiment_id = data.experiment_id
|
12
12
|
storage = data.storage
|
13
|
-
storage.
|
13
|
+
storage.is_a?(Kameleoon::DataManager::DataMapStorage) &&
|
14
|
+
(storage.size.zero? || ((storage.size == 1) && !storage.get(experiment_id).nil?))
|
14
15
|
end
|
15
16
|
end
|
16
17
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'kameleoon/data/
|
3
|
+
require 'kameleoon/data/manager/data_map_storage'
|
4
|
+
require 'kameleoon/data/manager/page_view_visit'
|
4
5
|
require_relative 'string_value_condition'
|
5
6
|
|
6
7
|
module Kameleoon
|
@@ -12,9 +13,15 @@ module Kameleoon
|
|
12
13
|
super(json_condition, json_condition['title'])
|
13
14
|
end
|
14
15
|
|
15
|
-
def check(
|
16
|
-
|
17
|
-
|
16
|
+
def check(page_view_visit_storage)
|
17
|
+
return false unless page_view_visit_storage.is_a?(Kameleoon::DataManager::DataMapStorage)
|
18
|
+
|
19
|
+
is_targeted = false
|
20
|
+
page_view_visit_storage.enumerate do |visit|
|
21
|
+
is_targeted = visit.is_a?(Kameleoon::DataManager::PageViewVisit) && check_targeting(visit.page_view.title)
|
22
|
+
break if is_targeted
|
23
|
+
end
|
24
|
+
is_targeted
|
18
25
|
end
|
19
26
|
end
|
20
27
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'kameleoon/data/
|
3
|
+
require 'kameleoon/data/manager/data_map_storage'
|
4
|
+
require 'kameleoon/data/manager/page_view_visit'
|
4
5
|
require_relative 'string_value_condition'
|
5
6
|
|
6
7
|
module Kameleoon
|
@@ -12,9 +13,22 @@ module Kameleoon
|
|
12
13
|
super(json_condition, json_condition['url'])
|
13
14
|
end
|
14
15
|
|
15
|
-
def check(
|
16
|
-
|
17
|
-
|
16
|
+
def check(page_view_visit_storage)
|
17
|
+
return false unless page_view_visit_storage.is_a?(Kameleoon::DataManager::DataMapStorage)
|
18
|
+
return !page_view_visit_storage.get(condition_value).nil? if operator == Operator::EXACT
|
19
|
+
|
20
|
+
is_targeted = false
|
21
|
+
page_view_visit_storage.enumerate do |visit|
|
22
|
+
is_targeted = check_page_view_visit(visit)
|
23
|
+
break if is_targeted
|
24
|
+
end
|
25
|
+
is_targeted
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def check_page_view_visit(visit)
|
31
|
+
visit.is_a?(Kameleoon::DataManager::PageViewVisit) && check_targeting(visit.page_view.url)
|
18
32
|
end
|
19
33
|
end
|
20
34
|
end
|
@@ -24,16 +24,21 @@ module Kameleoon
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def check(variation_storage)
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
return false unless variation_storage.is_a?(Kameleoon::DataManager::DataMapStorage) &&
|
28
|
+
variation_storage.size.positive?
|
29
|
+
|
30
|
+
variation = variation_storage.get(@experiment)
|
31
|
+
return false unless variation.is_a?(Kameleoon::DataManager::AssignedVariation)
|
32
|
+
|
30
33
|
case @operator
|
31
34
|
when Operator::EXACT
|
32
|
-
|
35
|
+
variation = variation_storage.get(@experiment)
|
36
|
+
variation.variation_id == @variation
|
33
37
|
when Operator::ANY
|
34
|
-
|
38
|
+
true
|
39
|
+
else
|
40
|
+
false
|
35
41
|
end
|
36
|
-
is_targeted
|
37
42
|
end
|
38
43
|
end
|
39
44
|
end
|
data/lib/kameleoon/utils.rb
CHANGED
@@ -1,16 +1,53 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'fiber'
|
4
|
+
require 'bigdecimal'
|
5
|
+
require 'kameleoon/utils'
|
6
|
+
require 'kameleoon/exceptions'
|
7
|
+
|
3
8
|
module Kameleoon
|
4
9
|
# Utils is a helper module for project
|
5
10
|
module Utils
|
6
11
|
ALPHA_NUMERIC_CHARS = 'ABCDEF0123456789'
|
7
12
|
|
8
|
-
def self.in_seconds(days)
|
9
|
-
days * 60 * 60 * 24
|
10
|
-
end
|
11
|
-
|
12
13
|
def self.generate_random_string(length)
|
13
14
|
(1..length).map { ALPHA_NUMERIC_CHARS[rand(ALPHA_NUMERIC_CHARS.length)] }.join
|
14
15
|
end
|
16
|
+
|
17
|
+
module VisitorCode
|
18
|
+
VISITOR_CODE_MAX_LENGTH = 255
|
19
|
+
VISITOR_CODE_LENGTH = 16
|
20
|
+
|
21
|
+
def self.validate(visitor_code)
|
22
|
+
raise Kameleoon::Exception::VisitorCodeInvalid, 'Empty visitor Code' if visitor_code&.empty?
|
23
|
+
if visitor_code.size > VISITOR_CODE_MAX_LENGTH
|
24
|
+
raise Kameleoon::Exception::VisitorCodeInvalid, "Visitor Code is longer than #{VISITOR_CODE_MAX_LENGTH} chars"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.generate
|
29
|
+
Utils.generate_random_string(VISITOR_CODE_LENGTH)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
module HashDouble
|
34
|
+
def self.obtain(visitor_code, respool_times = {}, container_id = '')
|
35
|
+
obtain_helper(visitor_code, respool_times, container_id, '')
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.obtain_rule(visitor_code, container_id = '', suffix = '')
|
39
|
+
obtain_helper(visitor_code, {}, container_id, suffix)
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def self.obtain_helper(visitor_code, respool_times, container_id, suffix)
|
45
|
+
identifier = visitor_code.to_s
|
46
|
+
identifier += container_id.to_s
|
47
|
+
identifier += suffix.to_s
|
48
|
+
identifier += respool_times.sort.to_h.values.join.to_s if !respool_times.nil? && !respool_times.empty?
|
49
|
+
(Digest::SHA256.hexdigest(identifier.encode('UTF-8')).to_i(16) / (BigDecimal('2')**BigDecimal('256'))).round(16)
|
50
|
+
end
|
51
|
+
end
|
15
52
|
end
|
16
53
|
end
|
data/lib/kameleoon/version.rb
CHANGED
data/lib/kameleoon.rb
CHANGED
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:
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kameleoon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: em-http-request
|
@@ -75,29 +75,37 @@ extra_rdoc_files: []
|
|
75
75
|
files:
|
76
76
|
- README.md
|
77
77
|
- lib/kameleoon.rb
|
78
|
-
- lib/kameleoon/
|
79
|
-
- lib/kameleoon/
|
80
|
-
- lib/kameleoon/configuration/experiment.rb
|
78
|
+
- lib/kameleoon/client_readiness.rb
|
79
|
+
- lib/kameleoon/configuration/data_file.rb
|
81
80
|
- lib/kameleoon/configuration/feature_flag.rb
|
82
81
|
- lib/kameleoon/configuration/rule.rb
|
83
82
|
- lib/kameleoon/configuration/settings.rb
|
84
83
|
- lib/kameleoon/configuration/variable.rb
|
85
84
|
- lib/kameleoon/configuration/variation.rb
|
86
85
|
- lib/kameleoon/configuration/variation_exposition.rb
|
87
|
-
- lib/kameleoon/cookie.rb
|
88
86
|
- lib/kameleoon/data/browser.rb
|
89
87
|
- lib/kameleoon/data/conversion.rb
|
90
88
|
- lib/kameleoon/data/custom_data.rb
|
91
89
|
- lib/kameleoon/data/data.rb
|
92
90
|
- lib/kameleoon/data/device.rb
|
91
|
+
- lib/kameleoon/data/manager/assigned_variation.rb
|
92
|
+
- lib/kameleoon/data/manager/data_array_storage.rb
|
93
|
+
- lib/kameleoon/data/manager/data_map_storage.rb
|
94
|
+
- lib/kameleoon/data/manager/page_view_visit.rb
|
95
|
+
- lib/kameleoon/data/manager/visitor.rb
|
96
|
+
- lib/kameleoon/data/manager/visitor_manager.rb
|
93
97
|
- lib/kameleoon/data/page_view.rb
|
94
98
|
- lib/kameleoon/data/user_agent.rb
|
95
99
|
- lib/kameleoon/exceptions.rb
|
96
|
-
- lib/kameleoon/factory.rb
|
97
100
|
- lib/kameleoon/hybrid/manager.rb
|
101
|
+
- lib/kameleoon/kameleoon_client.rb
|
102
|
+
- lib/kameleoon/kameleoon_client_config.rb
|
103
|
+
- lib/kameleoon/kameleoon_client_factory.rb
|
104
|
+
- lib/kameleoon/managers/warehouse/warehouse_manager.rb
|
105
|
+
- lib/kameleoon/network/access_token_source.rb
|
98
106
|
- lib/kameleoon/network/activity_event.rb
|
99
107
|
- lib/kameleoon/network/content_type.rb
|
100
|
-
- lib/kameleoon/network/
|
108
|
+
- lib/kameleoon/network/cookie/cookie_manager.rb
|
101
109
|
- lib/kameleoon/network/method.rb
|
102
110
|
- lib/kameleoon/network/net_provider.rb
|
103
111
|
- lib/kameleoon/network/network_manager.rb
|
@@ -112,8 +120,6 @@ files:
|
|
112
120
|
- lib/kameleoon/real_time/sse_request.rb
|
113
121
|
- lib/kameleoon/storage/cache.rb
|
114
122
|
- lib/kameleoon/storage/cache_factory.rb
|
115
|
-
- lib/kameleoon/storage/variation_storage.rb
|
116
|
-
- lib/kameleoon/storage/visitor_variation.rb
|
117
123
|
- lib/kameleoon/targeting/condition.rb
|
118
124
|
- lib/kameleoon/targeting/condition_factory.rb
|
119
125
|
- lib/kameleoon/targeting/conditions/browser_condition.rb
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Kameleoon
|
4
|
-
# Client configuration which can be used instead of an external configuration file
|
5
|
-
class ClientConfig
|
6
|
-
CONFIGURATION_UPDATE_INTERVAL = 60
|
7
|
-
VISITOR_DATA_MAXIMUM_SIZE = 500
|
8
|
-
DEFAULT_TIMEOUT = 2000 # milli-seconds
|
9
|
-
|
10
|
-
attr_reader :client_id, :client_secret, :data_refresh_interval, :default_timeout, :configuration_refresh_interval,
|
11
|
-
:visitor_data_maximum_size, :environment, :verbose_mode
|
12
|
-
|
13
|
-
def initialize(
|
14
|
-
client_id: nil,
|
15
|
-
client_secret: nil,
|
16
|
-
configuration_refresh_interval: CONFIGURATION_UPDATE_INTERVAL,
|
17
|
-
default_timeout: DEFAULT_TIMEOUT,
|
18
|
-
visitor_data_maximum_size: VISITOR_DATA_MAXIMUM_SIZE,
|
19
|
-
environment: nil,
|
20
|
-
verbose_mode: false
|
21
|
-
)
|
22
|
-
@client_id = client_id
|
23
|
-
@client_secret = client_secret
|
24
|
-
@configuration_refresh_interval = configuration_refresh_interval || CONFIGURATION_UPDATE_INTERVAL
|
25
|
-
@default_timeout = default_timeout || DEFAULT_TIMEOUT
|
26
|
-
@visitor_data_maximum_size = visitor_data_maximum_size || VISITOR_DATA_MAXIMUM_SIZE
|
27
|
-
@environment = environment
|
28
|
-
@verbose_mode = verbose_mode || false
|
29
|
-
end
|
30
|
-
|
31
|
-
def self.make_from_yaml(yaml)
|
32
|
-
yaml ||= {}
|
33
|
-
ClientConfig.new(
|
34
|
-
client_id: yaml['client_id'],
|
35
|
-
client_secret: yaml['client_secret'],
|
36
|
-
configuration_refresh_interval: yaml['actions_configuration_refresh_interval'],
|
37
|
-
default_timeout: yaml['default_timeout'],
|
38
|
-
visitor_data_maximum_size: yaml['visitor_data_maximum_size'],
|
39
|
-
environment: yaml['environment'],
|
40
|
-
verbose_mode: yaml['verbose_mode']
|
41
|
-
)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'kameleoon/targeting/models'
|
4
|
-
|
5
|
-
module Kameleoon
|
6
|
-
# Module which contains all internal data of SDK
|
7
|
-
module Configuration
|
8
|
-
# Class for manage all experiments and old feature flags
|
9
|
-
class Experiment
|
10
|
-
attr_accessor :id, :status, :site_enabled, :deviations, :respool_time, :variations, :targeting_segment
|
11
|
-
|
12
|
-
def self.create_from_array(array)
|
13
|
-
array&.map { |it| Experiment.new(it) }
|
14
|
-
end
|
15
|
-
|
16
|
-
def initialize(experiment_hash)
|
17
|
-
@id = experiment_hash['id']
|
18
|
-
@status = experiment_hash['status']
|
19
|
-
@site_enabled = experiment_hash['siteEnabled']
|
20
|
-
unless experiment_hash['deviations'].nil?
|
21
|
-
@deviations =
|
22
|
-
Hash[*experiment_hash['deviations'].map do |it|
|
23
|
-
[it['variationId'] == 'origin' ? '0' : it['variationId'], it['value']]
|
24
|
-
end.flatten]
|
25
|
-
end
|
26
|
-
unless experiment_hash['respoolTime'].nil?
|
27
|
-
@respool_time =
|
28
|
-
Hash[*experiment_hash['respoolTime'].map do |it|
|
29
|
-
[it['variationId'] == 'origin' ? '0' : it['variationId'], it['value']]
|
30
|
-
end.flatten]
|
31
|
-
end
|
32
|
-
unless experiment_hash['variations'].nil?
|
33
|
-
@variations =
|
34
|
-
experiment_hash['variations'].map do |it|
|
35
|
-
{ 'id' => it['id'].to_i, 'customJson' => it['customJson'] }
|
36
|
-
end
|
37
|
-
end
|
38
|
-
@targeting_segment = Kameleoon::Targeting::Segment.new((experiment_hash['segment'])) if experiment_hash['segment']
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|