Class: RailsInformant::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_informant/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rails_informant/configuration.rb', line 15

def initialize
  @before_record_callbacks = []
  @api_token = ENV["INFORMANT_API_TOKEN"]
  @app_name = ENV["INFORMANT_APP_NAME"]
  @capture_errors = ENV.fetch("INFORMANT_CAPTURE_ERRORS", "true") != "false"
  @capture_user_email = false
  @custom_notifiers = []
  @ignored_exceptions = ENV["INFORMANT_IGNORED_EXCEPTIONS"]&.split(",")&.map(&:strip) || []
  @ignored_paths = ENV["INFORMANT_IGNORED_PATHS"]&.split(",")&.map(&:strip) || []
  @job_attempt_threshold = ENV["INFORMANT_JOB_ATTEMPT_THRESHOLD"]&.to_i
  @retention_days = ENV["INFORMANT_RETENTION_DAYS"]&.to_i
  @spike_protection = nil
  @slack_webhook_url = ENV["INFORMANT_SLACK_WEBHOOK_URL"]
  @webhook_url = ENV["INFORMANT_WEBHOOK_URL"]
end

Instance Attribute Details

#api_tokenObject

Returns the value of attribute api_token.



3
4
5
# File 'lib/rails_informant/configuration.rb', line 3

def api_token
  @api_token
end

#app_nameObject



31
32
33
# File 'lib/rails_informant/configuration.rb', line 31

def app_name
  @app_name.presence || detect_app_name
end

#capture_errorsObject

Returns the value of attribute capture_errors.



3
4
5
# File 'lib/rails_informant/configuration.rb', line 3

def capture_errors
  @capture_errors
end

#capture_user_emailObject

Returns the value of attribute capture_user_email.



3
4
5
# File 'lib/rails_informant/configuration.rb', line 3

def capture_user_email
  @capture_user_email
end

#ignored_exceptionsObject

Returns the value of attribute ignored_exceptions.



3
4
5
# File 'lib/rails_informant/configuration.rb', line 3

def ignored_exceptions
  @ignored_exceptions
end

#ignored_pathsObject

Returns the value of attribute ignored_paths.



3
4
5
# File 'lib/rails_informant/configuration.rb', line 3

def ignored_paths
  @ignored_paths
end

#job_attempt_thresholdObject

Returns the value of attribute job_attempt_threshold.



3
4
5
# File 'lib/rails_informant/configuration.rb', line 3

def job_attempt_threshold
  @job_attempt_threshold
end

#retention_daysObject

Returns the value of attribute retention_days.



3
4
5
# File 'lib/rails_informant/configuration.rb', line 3

def retention_days
  @retention_days
end

#slack_webhook_urlObject

Returns the value of attribute slack_webhook_url.



3
4
5
# File 'lib/rails_informant/configuration.rb', line 3

def slack_webhook_url
  @slack_webhook_url
end

#spike_protectionObject

Returns the value of attribute spike_protection.



46
47
48
# File 'lib/rails_informant/configuration.rb', line 46

def spike_protection
  @spike_protection
end

#webhook_urlObject

Returns the value of attribute webhook_url.



3
4
5
# File 'lib/rails_informant/configuration.rb', line 3

def webhook_url
  @webhook_url
end

Instance Method Details

#add_notifier(notifier) ⇒ Object

Register a custom notifier. Must respond to #notify and #should_notify?.



41
42
43
44
# File 'lib/rails_informant/configuration.rb', line 41

def add_notifier(notifier)
  @custom_notifiers << notifier
  @_notifiers = nil
end

#before_record(&block) ⇒ Object



55
56
57
58
# File 'lib/rails_informant/configuration.rb', line 55

def before_record(&block)
  @before_record_callbacks << block
  @_frozen_callbacks = nil
end

#before_record_callbacksObject



60
61
62
# File 'lib/rails_informant/configuration.rb', line 60

def before_record_callbacks
  @_frozen_callbacks ||= @before_record_callbacks.dup.freeze
end

#notifiersObject

Returns all notifiers: built-in (auto-registered from config) + custom.



36
37
38
# File 'lib/rails_informant/configuration.rb', line 36

def notifiers
  @_notifiers ||= built_in_notifiers + @custom_notifiers
end

#reset_notifiers!Object



64
65
66
# File 'lib/rails_informant/configuration.rb', line 64

def reset_notifiers!
  @_notifiers = nil
end