amplitude-experiment 1.6.0 → 1.7.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/amplitude/processor.rb +1 -1
- data/lib/amplitude/timeline.rb +1 -1
- data/lib/experiment/local/client.rb +1 -6
- data/lib/experiment/local/config.rb +21 -3
- data/lib/experiment/remote/client.rb +1 -6
- data/lib/experiment/remote/config.rb +24 -4
- data/lib/experiment/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c510533f1277e5400d2b4b82e43703668676cef6f0077c0894e8f7e502f112a0
|
|
4
|
+
data.tar.gz: cfe5c55993a65b66807ad3c67f0856f077fc0b7c70a9ac7a69ee0b6d26e52b72
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 34857d29d97eadbe26fa887fe26b4ee75f7ca358a9508dc5af3221af184e516e027f467d1726ec67734f842b5dd9e9dded521245aaed9e8c2d1f84a2e99708c2
|
|
7
|
+
data.tar.gz: 9cde9399703105c0b971a3596e58a817c10046dce2ce52468286608bf3bfc4ef9428710be0bc0a8e706bda692a185e44ce1cd5d2965edd786542ed07454d6972
|
data/lib/amplitude/processor.rb
CHANGED
|
@@ -87,7 +87,7 @@ module AmplitudeAnalytics
|
|
|
87
87
|
@configuration.callback.call(event, code, message) if @configuration.callback.respond_to?(:call)
|
|
88
88
|
event.callback(code, message)
|
|
89
89
|
rescue StandardError => e
|
|
90
|
-
@configuration.logger.
|
|
90
|
+
@configuration.logger.error("Error callback for event #{event}: #{e.message}")
|
|
91
91
|
end
|
|
92
92
|
end
|
|
93
93
|
|
data/lib/amplitude/timeline.rb
CHANGED
|
@@ -49,7 +49,7 @@ module AmplitudeAnalytics
|
|
|
49
49
|
@plugins[PluginType::DESTINATION].each do |destination|
|
|
50
50
|
destination_futures << destination.flush
|
|
51
51
|
rescue StandardError
|
|
52
|
-
logger.
|
|
52
|
+
logger.error('Error for flush events')
|
|
53
53
|
end
|
|
54
54
|
end
|
|
55
55
|
destination_futures
|
|
@@ -14,14 +14,9 @@ module AmplitudeExperiment
|
|
|
14
14
|
def initialize(api_key, config = nil)
|
|
15
15
|
@api_key = api_key
|
|
16
16
|
@config = config || LocalEvaluationConfig.new
|
|
17
|
+
@logger = @config.logger
|
|
17
18
|
@flags = nil
|
|
18
19
|
@flags_mutex = Mutex.new
|
|
19
|
-
@logger = Logger.new($stdout)
|
|
20
|
-
@logger.level = if @config.debug
|
|
21
|
-
Logger::DEBUG
|
|
22
|
-
else
|
|
23
|
-
Logger::INFO
|
|
24
|
-
end
|
|
25
20
|
raise ArgumentError, 'Experiment API key is empty' if @api_key.nil? || @api_key.empty?
|
|
26
21
|
|
|
27
22
|
@engine = Evaluation::Engine.new
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require 'logger'
|
|
2
|
+
|
|
1
3
|
module AmplitudeExperiment
|
|
2
4
|
module ServerZone
|
|
3
5
|
US = 'US'.freeze
|
|
@@ -9,11 +11,17 @@ module AmplitudeExperiment
|
|
|
9
11
|
# Default server url
|
|
10
12
|
DEFAULT_SERVER_URL = 'https://api.lab.amplitude.com'.freeze
|
|
11
13
|
EU_SERVER_URL = 'https://flag.lab.eu.amplitude.com'.freeze
|
|
14
|
+
DEFAULT_LOGDEV = $stdout
|
|
15
|
+
DEFAULT_LOG_LEVEL = Logger::ERROR
|
|
12
16
|
|
|
13
17
|
# Set to true to log some extra information to the console.
|
|
14
18
|
# @return [Boolean] the value of debug
|
|
15
19
|
attr_accessor :debug
|
|
16
20
|
|
|
21
|
+
# Set the client logger to a user defined [Logger]
|
|
22
|
+
# @return [Logger] the logger instance of the client
|
|
23
|
+
attr_accessor :logger
|
|
24
|
+
|
|
17
25
|
# The server endpoint from which to request variants.
|
|
18
26
|
# @return [String] the value of server url
|
|
19
27
|
attr_accessor :server_url
|
|
@@ -35,16 +43,26 @@ module AmplitudeExperiment
|
|
|
35
43
|
attr_accessor :cohort_sync_config
|
|
36
44
|
|
|
37
45
|
# @param [Boolean] debug Set to true to log some extra information to the console.
|
|
46
|
+
# @param [Logger] logger instance to be used for all client logging behavior
|
|
38
47
|
# @param [String] server_url The server endpoint from which to request variants.
|
|
39
48
|
# @param [String] server_zone Location of the Amplitude data center to get flags and cohorts from, US or EU
|
|
40
49
|
# @param [Hash] bootstrap The value of bootstrap.
|
|
41
50
|
# @param [long] flag_config_polling_interval_millis The value of flag config polling interval in million seconds.
|
|
42
51
|
# @param [AssignmentConfig] assignment_config Configuration for automatically tracking assignment events after an evaluation.
|
|
43
52
|
# @param [CohortSyncConfig] cohort_sync_config Configuration for downloading cohorts required for flag evaluation
|
|
44
|
-
def initialize(server_url: DEFAULT_SERVER_URL,
|
|
45
|
-
|
|
53
|
+
def initialize(server_url: DEFAULT_SERVER_URL,
|
|
54
|
+
server_zone: ServerZone::US,
|
|
55
|
+
bootstrap: {},
|
|
56
|
+
flag_config_polling_interval_millis: 30_000,
|
|
57
|
+
debug: false,
|
|
58
|
+
logger: nil,
|
|
59
|
+
assignment_config: nil,
|
|
46
60
|
cohort_sync_config: nil)
|
|
47
|
-
@
|
|
61
|
+
@logger = logger
|
|
62
|
+
if logger.nil?
|
|
63
|
+
@logger = Logger.new(DEFAULT_LOGDEV)
|
|
64
|
+
@logger.level = debug ? Logger::DEBUG : DEFAULT_LOG_LEVEL
|
|
65
|
+
end
|
|
48
66
|
@server_url = server_url
|
|
49
67
|
@server_zone = server_zone
|
|
50
68
|
@cohort_sync_config = cohort_sync_config
|
|
@@ -13,12 +13,7 @@ module AmplitudeExperiment
|
|
|
13
13
|
def initialize(api_key, config = nil)
|
|
14
14
|
@api_key = api_key
|
|
15
15
|
@config = config || RemoteEvaluationConfig.new
|
|
16
|
-
@logger =
|
|
17
|
-
@logger.level = if @config.debug
|
|
18
|
-
Logger::DEBUG
|
|
19
|
-
else
|
|
20
|
-
Logger::INFO
|
|
21
|
-
end
|
|
16
|
+
@logger = @config.logger
|
|
22
17
|
endpoint = "#{@config.server_url}/sdk/v2/vardata?v=0"
|
|
23
18
|
@uri = URI(endpoint)
|
|
24
19
|
raise ArgumentError, 'Experiment API key is empty' if @api_key.nil? || @api_key.empty?
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
+
require 'logger'
|
|
2
|
+
|
|
1
3
|
module AmplitudeExperiment
|
|
2
4
|
# Configuration
|
|
3
5
|
class RemoteEvaluationConfig
|
|
4
6
|
# Default server url
|
|
5
7
|
DEFAULT_SERVER_URL = 'https://api.lab.amplitude.com'.freeze
|
|
8
|
+
DEFAULT_LOGDEV = $stdout
|
|
9
|
+
DEFAULT_LOG_LEVEL = Logger::ERROR
|
|
6
10
|
|
|
7
11
|
# Set to true to log some extra information to the console.
|
|
8
12
|
# @return [Boolean] the value of debug
|
|
9
13
|
attr_accessor :debug
|
|
10
14
|
|
|
15
|
+
# Set the client logger to a user defined [Logger]
|
|
16
|
+
# @return [Logger] the logger instance of the client
|
|
17
|
+
attr_accessor :logger
|
|
18
|
+
|
|
11
19
|
# The server endpoint from which to request variants.
|
|
12
20
|
# @return [Boolean] the value of server url
|
|
13
21
|
attr_accessor :server_url
|
|
@@ -43,6 +51,7 @@ module AmplitudeExperiment
|
|
|
43
51
|
attr_accessor :fetch_retry_timeout_millis
|
|
44
52
|
|
|
45
53
|
# @param [Boolean] debug Set to true to log some extra information to the console.
|
|
54
|
+
# @param [Logger] logger instance to be used for all client logging behavior
|
|
46
55
|
# @param [String] server_url The server endpoint from which to request variants.
|
|
47
56
|
# @param [Integer] connect_timeout_millis The request connection open timeout, in milliseconds, used when
|
|
48
57
|
# fetching variants triggered by calling start() or setUser().
|
|
@@ -55,10 +64,21 @@ module AmplitudeExperiment
|
|
|
55
64
|
# greater than the max, the max is used for all subsequent retries.
|
|
56
65
|
# @param [Float] fetch_retry_backoff_scalar Scales the minimum backoff exponentially.
|
|
57
66
|
# @param [Integer] fetch_retry_timeout_millis The request timeout for retrying fetch requests.
|
|
58
|
-
def initialize(debug: false,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
67
|
+
def initialize(debug: false,
|
|
68
|
+
logger: nil,
|
|
69
|
+
server_url: DEFAULT_SERVER_URL,
|
|
70
|
+
connect_timeout_millis: 60_000,
|
|
71
|
+
fetch_timeout_millis: 10_000,
|
|
72
|
+
fetch_retries: 0,
|
|
73
|
+
fetch_retry_backoff_min_millis: 500,
|
|
74
|
+
fetch_retry_backoff_max_millis: 10_000,
|
|
75
|
+
fetch_retry_backoff_scalar: 1.5,
|
|
76
|
+
fetch_retry_timeout_millis: 10_000)
|
|
77
|
+
@logger = logger
|
|
78
|
+
if logger.nil?
|
|
79
|
+
@logger = Logger.new(DEFAULT_LOGDEV)
|
|
80
|
+
@logger.level = debug ? Logger::DEBUG : DEFAULT_LOG_LEVEL
|
|
81
|
+
end
|
|
62
82
|
@server_url = server_url
|
|
63
83
|
@connect_timeout_millis = connect_timeout_millis
|
|
64
84
|
@fetch_timeout_millis = fetch_timeout_millis
|
data/lib/experiment/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: amplitude-experiment
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Amplitude
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-
|
|
11
|
+
date: 2025-11-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: concurrent-ruby
|