Module: AmplitudeAnalytics
- Defined in:
- lib/amplitude/utils.rb,
lib/amplitude/event.rb,
lib/amplitude/client.rb,
lib/amplitude/config.rb,
lib/amplitude/plugin.rb,
lib/amplitude/storage.rb,
lib/amplitude/workers.rb,
lib/amplitude/timeline.rb,
lib/amplitude/constants.rb,
lib/amplitude/exception.rb,
lib/amplitude/processor.rb,
lib/amplitude/http_client.rb
Overview
Amplitude
Defined Under Namespace
Classes: Amplitude, AmplitudeDestinationPlugin, BaseEvent, Config, ContextPlugin, DestinationPlugin, EventOptions, EventPlugin, HttpClient, HttpStatus, InMemoryStorage, InMemoryStorageProvider, IngestionMetadata, InvalidAPIKeyError, InvalidEventError, Plugin, PluginType, Response, ResponseProcessor, Storage, StorageProvider, Timeline, Workers
Constant Summary collapse
- SDK_LIBRARY =
'amplitude-experiment-ruby'.freeze
- SDK_VERSION =
'1.1.5'.freeze
- EU_ZONE =
'EU'.freeze
- DEFAULT_ZONE =
'US'.freeze
- BATCH =
'batch'.freeze
- HTTP_V2 =
'v2'.freeze
- SERVER_URL =
{ EU_ZONE => { BATCH => 'https://api.eu.amplitude.com/batch', HTTP_V2 => 'https://api.eu.amplitude.com/2/httpapi' }, DEFAULT_ZONE => { BATCH => 'https://api2.amplitude.com/batch', HTTP_V2 => 'https://api2.amplitude.com/2/httpapi' } }.freeze
- LOGGER_NAME =
'amplitude'.freeze
- MAX_PROPERTY_KEYS =
1024
- MAX_STRING_LENGTH =
1024
- FLUSH_QUEUE_SIZE =
200
- FLUSH_INTERVAL_MILLIS =
10_000
- FLUSH_MAX_RETRIES =
12
- CONNECTION_TIMEOUT =
seconds float
10.0
- MAX_BUFFER_CAPACITY =
20_000
- JSON_HEADER =
{ 'Content-Type': 'application/json; charset=UTF-8', Accept: '*/*' }.freeze
Class Method Summary collapse
Class Method Details
.current_milliseconds ⇒ Object
10 11 12 |
# File 'lib/amplitude/utils.rb', line 10 def self.current_milliseconds (Time.now.to_f * 1000).to_i end |
.logger ⇒ Object
6 7 8 |
# File 'lib/amplitude/utils.rb', line 6 def self.logger @logger ||= Logger.new($stdout, progname: LOGGER_NAME) end |
.truncate(obj) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/amplitude/utils.rb', line 14 def self.truncate(obj) case obj when Hash if obj.length > MAX_PROPERTY_KEYS logger.error("Too many properties. #{MAX_PROPERTY_KEYS} maximum.") return {} end obj.each { |key, value| obj[key] = truncate(value) } when Array obj.map! { |element| truncate(element) } when String obj = obj[0, MAX_STRING_LENGTH] end obj end |