Class: Path::Reporting::Analytics::Configuration
- Inherits:
-
Object
- Object
- Path::Reporting::Analytics::Configuration
- Defined in:
- lib/path/reporting/analytics/configuration.rb
Overview
Configuration for analytics reporting. Generally this is for configuring amplitude and/or a logger that analytics should be reported to
Instance Attribute Summary collapse
-
#amplitude_config ⇒ Hash
Set the configuration for the AmplitudeAPI gem.
-
#logger ⇒ #info
The logger for the console logging analytics reporter.
Instance Method Summary collapse
-
#amplitude_enabled? ⇒ Boolean
Check if Amplitude has been configured and is available for use.
-
#console_enabled? ⇒ Boolean
Check if the logger has been configured and is available for use.
-
#initialize ⇒ Configuration
constructor
New Configuration with all reporting off by default.
Constructor Details
#initialize ⇒ Configuration
New Configuration with all reporting off by default
22 23 24 25 26 27 |
# File 'lib/path/reporting/analytics/configuration.rb', line 22 def initialize @console_enabled = false @logger = nil @amplitude_enabled = false @amplitude_config = nil end |
Instance Attribute Details
#amplitude_config ⇒ Hash
Set the configuration for the AmplitudeAPI gem
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/path/reporting/analytics/configuration.rb', line 18 class Configuration attr_reader :amplitude_config, :logger # New Configuration with all reporting off by default def initialize @console_enabled = false @logger = nil @amplitude_enabled = false @amplitude_config = nil end def logger=(logger) @console_enabled = !logger.nil? @logger = logger end alias console= logger= # Check if the logger has been configured and is available for use # @return [Boolean] if logger is available for use def console_enabled? @console_enabled && @logger end # Set the configuration for the AmplitudeAPI gem # @param conf [Hash] configuration options for amplitude # @return [Hash] amplitude configuration options as passed along to the amplitude-api gem # @see https://www.rubydoc.info/gems/amplitude-api/AmplitudeAPI/Config AmplitudeAPI::Config def amplitude_config=(conf) @amplitude_enabled = !(conf.nil? || conf.empty?) @amplitude_config = conf end alias amplitude= amplitude_config= # Check if Amplitude has been configured and is available for use # @return [Boolean] if Amplitude is available for use def amplitude_enabled? @amplitude_enabled && @amplitude_config end end |
#logger ⇒ #info
The logger for the console logging analytics reporter
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/path/reporting/analytics/configuration.rb', line 18 class Configuration attr_reader :amplitude_config, :logger # New Configuration with all reporting off by default def initialize @console_enabled = false @logger = nil @amplitude_enabled = false @amplitude_config = nil end def logger=(logger) @console_enabled = !logger.nil? @logger = logger end alias console= logger= # Check if the logger has been configured and is available for use # @return [Boolean] if logger is available for use def console_enabled? @console_enabled && @logger end # Set the configuration for the AmplitudeAPI gem # @param conf [Hash] configuration options for amplitude # @return [Hash] amplitude configuration options as passed along to the amplitude-api gem # @see https://www.rubydoc.info/gems/amplitude-api/AmplitudeAPI/Config AmplitudeAPI::Config def amplitude_config=(conf) @amplitude_enabled = !(conf.nil? || conf.empty?) @amplitude_config = conf end alias amplitude= amplitude_config= # Check if Amplitude has been configured and is available for use # @return [Boolean] if Amplitude is available for use def amplitude_enabled? @amplitude_enabled && @amplitude_config end end |
Instance Method Details
#amplitude_enabled? ⇒ Boolean
Check if Amplitude has been configured and is available for use
55 56 57 |
# File 'lib/path/reporting/analytics/configuration.rb', line 55 def amplitude_enabled? @amplitude_enabled && @amplitude_config end |
#console_enabled? ⇒ Boolean
Check if the logger has been configured and is available for use
38 39 40 |
# File 'lib/path/reporting/analytics/configuration.rb', line 38 def console_enabled? @console_enabled && @logger end |