Module: Aptabase
- Defined in:
- lib/aptabase.rb,
lib/aptabase/event.rb,
lib/aptabase/client.rb,
lib/aptabase/errors.rb,
lib/aptabase/railtie.rb,
lib/aptabase/session.rb,
lib/aptabase/version.rb,
lib/aptabase/transport.rb,
lib/aptabase/system_properties.rb,
lib/generators/aptabase/install_generator.rb
Overview
Defined Under Namespace
Modules: Generators Classes: Client, ConfigurationError, Error, Event, NetworkError, Railtie, Session, SystemProperties, Transport, ValidationError
Constant Summary collapse
- VERSION =
"0.1.0"
Class Attribute Summary collapse
-
.client ⇒ Object
readonly
Returns the value of attribute client.
-
.default_logger ⇒ Object
Logger used when ‘init` is not given an explicit one.
Class Method Summary collapse
-
.flush ⇒ Object
Synchronously send all queued events.
-
.init(app_key, **options) ⇒ Object
Initialize the global client.
-
.stop ⇒ Object
Stop the global client, flushing any remaining events.
-
.track(event_name, props = nil) ⇒ Object
Track an event on the global client.
Class Attribute Details
.client ⇒ Object (readonly)
Returns the value of attribute client.
20 21 22 |
# File 'lib/aptabase.rb', line 20 def client @client end |
.default_logger ⇒ Object
Logger used when ‘init` is not given an explicit one. Set to Rails.logger automatically by the railtie in Rails apps.
24 25 26 |
# File 'lib/aptabase.rb', line 24 def default_logger @default_logger end |
Class Method Details
.flush ⇒ Object
Synchronously send all queued events.
48 49 50 51 |
# File 'lib/aptabase.rb', line 48 def flush @client&.flush nil end |
.init(app_key, **options) ⇒ Object
Initialize the global client. Replaces (and stops) any previous one. Queued events are flushed automatically when the process exits.
28 29 30 31 32 33 34 |
# File 'lib/aptabase.rb', line 28 def init(app_key, **) @client&.stop [:logger] = default_logger if default_logger && !.key?(:logger) @client = Client.new(app_key, **) register_at_exit @client end |
.stop ⇒ Object
Stop the global client, flushing any remaining events.
54 55 56 57 |
# File 'lib/aptabase.rb', line 54 def stop @client&.stop @client = nil end |
.track(event_name, props = nil) ⇒ Object
Track an event on the global client. Warns (once) and discards the event if ‘Aptabase.init` has not been called.
38 39 40 41 42 43 44 45 |
# File 'lib/aptabase.rb', line 38 def track(event_name, props = nil) client = @client if client.nil? warn_not_initialized return end client.track(event_name, props) end |