Class: AmplitudeAnalytics::Config
- Inherits:
-
Object
- Object
- AmplitudeAnalytics::Config
- Defined in:
- lib/amplitude/config.rb
Overview
Config
Direct Known Subclasses
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#callback ⇒ Object
Returns the value of attribute callback.
-
#flush_interval_millis ⇒ Object
Returns the value of attribute flush_interval_millis.
-
#flush_max_retries ⇒ Object
Returns the value of attribute flush_max_retries.
-
#ingestion_metadata ⇒ Object
Returns the value of attribute ingestion_metadata.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#min_id_length ⇒ Object
Returns the value of attribute min_id_length.
-
#opt_out ⇒ Object
Returns the value of attribute opt_out.
-
#server_zone ⇒ Object
Returns the value of attribute server_zone.
-
#storage_provider ⇒ Object
Returns the value of attribute storage_provider.
-
#use_batch ⇒ Object
Returns the value of attribute use_batch.
Instance Method Summary collapse
- #flush_queue_size ⇒ Object
- #flush_queue_size=(size) ⇒ Object
- #increase_flush_divider ⇒ Object
-
#initialize(api_key: nil, flush_queue_size: FLUSH_QUEUE_SIZE, flush_interval_millis: FLUSH_INTERVAL_MILLIS, flush_max_retries: FLUSH_MAX_RETRIES, logger: Logger.new($stdout, progname: LOGGER_NAME, level: Logger::ERROR), min_id_length: nil, callback: nil, server_zone: DEFAULT_ZONE, use_batch: false, server_url: nil, storage_provider: InMemoryStorageProvider.new, ingestion_metadata: nil) ⇒ Config
constructor
A new instance of Config.
- #min_id_length_valid? ⇒ Boolean
- #options ⇒ Object
- #reset_flush_divider ⇒ Object
- #server_url ⇒ Object
- #server_url=(url) ⇒ Object
- #storage ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(api_key: nil, flush_queue_size: FLUSH_QUEUE_SIZE, flush_interval_millis: FLUSH_INTERVAL_MILLIS, flush_max_retries: FLUSH_MAX_RETRIES, logger: Logger.new($stdout, progname: LOGGER_NAME, level: Logger::ERROR), min_id_length: nil, callback: nil, server_zone: DEFAULT_ZONE, use_batch: false, server_url: nil, storage_provider: InMemoryStorageProvider.new, ingestion_metadata: nil) ⇒ Config
Returns a new instance of Config.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/amplitude/config.rb', line 9 def initialize(api_key: nil, flush_queue_size: FLUSH_QUEUE_SIZE, flush_interval_millis: FLUSH_INTERVAL_MILLIS, flush_max_retries: FLUSH_MAX_RETRIES, logger: Logger.new($stdout, progname: LOGGER_NAME, level: Logger::ERROR), min_id_length: nil, callback: nil, server_zone: DEFAULT_ZONE, use_batch: false, server_url: nil, storage_provider: InMemoryStorageProvider.new, ingestion_metadata: nil) @api_key = api_key @flush_queue_size = flush_queue_size @flush_size_divider = 1 @flush_interval_millis = flush_interval_millis @flush_max_retries = flush_max_retries @logger = logger @min_id_length = min_id_length @callback = callback @server_zone = server_zone @use_batch = use_batch @server_url = server_url @storage_provider = storage_provider @opt_out = false @ingestion_metadata = end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
5 6 7 |
# File 'lib/amplitude/config.rb', line 5 def api_key @api_key end |
#callback ⇒ Object
Returns the value of attribute callback.
5 6 7 |
# File 'lib/amplitude/config.rb', line 5 def callback @callback end |
#flush_interval_millis ⇒ Object
Returns the value of attribute flush_interval_millis.
5 6 7 |
# File 'lib/amplitude/config.rb', line 5 def flush_interval_millis @flush_interval_millis end |
#flush_max_retries ⇒ Object
Returns the value of attribute flush_max_retries.
5 6 7 |
# File 'lib/amplitude/config.rb', line 5 def flush_max_retries @flush_max_retries end |
#ingestion_metadata ⇒ Object
Returns the value of attribute ingestion_metadata.
5 6 7 |
# File 'lib/amplitude/config.rb', line 5 def @ingestion_metadata end |
#logger ⇒ Object
Returns the value of attribute logger.
5 6 7 |
# File 'lib/amplitude/config.rb', line 5 def logger @logger end |
#min_id_length ⇒ Object
Returns the value of attribute min_id_length.
5 6 7 |
# File 'lib/amplitude/config.rb', line 5 def min_id_length @min_id_length end |
#opt_out ⇒ Object
Returns the value of attribute opt_out.
5 6 7 |
# File 'lib/amplitude/config.rb', line 5 def opt_out @opt_out end |
#server_zone ⇒ Object
Returns the value of attribute server_zone.
5 6 7 |
# File 'lib/amplitude/config.rb', line 5 def server_zone @server_zone end |
#storage_provider ⇒ Object
Returns the value of attribute storage_provider.
5 6 7 |
# File 'lib/amplitude/config.rb', line 5 def storage_provider @storage_provider end |
#use_batch ⇒ Object
Returns the value of attribute use_batch.
5 6 7 |
# File 'lib/amplitude/config.rb', line 5 def use_batch @use_batch end |
Instance Method Details
#flush_queue_size ⇒ Object
44 45 46 |
# File 'lib/amplitude/config.rb', line 44 def flush_queue_size [@flush_queue_size / @flush_size_divider, 1].max end |
#flush_queue_size=(size) ⇒ Object
48 49 50 51 |
# File 'lib/amplitude/config.rb', line 48 def flush_queue_size=(size) @flush_queue_size = size @flush_size_divider = 1 end |
#increase_flush_divider ⇒ Object
70 71 72 |
# File 'lib/amplitude/config.rb', line 70 def increase_flush_divider @flush_size_divider += 1 end |
#min_id_length_valid? ⇒ Boolean
40 41 42 |
# File 'lib/amplitude/config.rb', line 40 def min_id_length_valid? @min_id_length.nil? || (@min_id_length.is_a?(Integer) && @min_id_length > 0) end |
#options ⇒ Object
66 67 68 |
# File 'lib/amplitude/config.rb', line 66 def { 'min_id_length' => @min_id_length } if min_id_length_valid? && @min_id_length end |
#reset_flush_divider ⇒ Object
74 75 76 |
# File 'lib/amplitude/config.rb', line 74 def reset_flush_divider @flush_size_divider = 1 end |
#server_url ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/amplitude/config.rb', line 53 def server_url @url || ( if use_batch SERVER_URL[@server_zone][BATCH] else SERVER_URL[@server_zone][HTTP_V2] end) end |
#server_url=(url) ⇒ Object
62 63 64 |
# File 'lib/amplitude/config.rb', line 62 def server_url=(url) @url = url end |
#storage ⇒ Object
32 33 34 |
# File 'lib/amplitude/config.rb', line 32 def storage @storage_provider.storage end |
#valid? ⇒ Boolean
36 37 38 |
# File 'lib/amplitude/config.rb', line 36 def valid? @api_key && @flush_queue_size > 0 && @flush_interval_millis > 0 && min_id_length_valid? end |