Class: TgErrorNotifier::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/tg_error_notifier/configuration.rb', line 31

def initialize
  @enabled = true
  @bot_token = ENV["TELEGRAM_BOT_TOKEN"]
  @chat_id = ENV["TELEGRAM_ERRORS_CHAT_ID"]
  @api_base = "https://api.telegram.org"
  @environment = ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development"
  @app_name = ENV["TELEGRAM_ERRORS_APP_NAME"] || "Rails App"
  @max_backtrace_lines = 20
  @ignored_exceptions = [
    "ActionController::RoutingError",
    "ActiveRecord::RecordNotFound",
    "ActionController::UnknownFormat"
  ]
  @ignored_environments = ["test"]
  @open_timeout = 2
  @read_timeout = 5
  @logger = nil
  @include_backtrace = true
  @active_job_enabled = true
  @proxy_addr = nil
  @proxy_port = nil
  @proxy_user = nil
  @proxy_pass = nil
  @grouping_enabled = false
  @grouping_window = 60
  @topics_enabled = false
  @topic_icon_color = nil
  # Persistent storage for named topics (created via capture_message topic:).
  # Without a store each process/restart would create a duplicate forum topic.
  #   topic_store_read  = ->(name) { ... }        # returns thread_id or nil
  #   topic_store_write = ->(name, thread_id) { ... }
  @topic_store_read = nil
  @topic_store_write = nil
  # Inline keyboard attached under the message. The gem does not interpret
  # the buttons: whatever the host returns goes to Telegram as is, so the
  # host is free to use url buttons, callback_data or web_app.
  #
  #   config.buttons = lambda do |kind:, source:, context:, fingerprint:, exception: nil, message: nil|
  #     [[{ text: "To the board", url: "https://example.com/e/#{token}" }]]
  #   end
  #
  # Return value: array of rows, each row an array of button hashes.
  # A flat array of buttons is accepted too and becomes a single row.
  # Return nil or [] for no keyboard. Errors raised inside are logged and
  # the message is still delivered, without the keyboard.
  @buttons = nil
end

Instance Attribute Details

#active_job_enabledObject

Returns the value of attribute active_job_enabled.



5
6
7
# File 'lib/tg_error_notifier/configuration.rb', line 5

def active_job_enabled
  @active_job_enabled
end

#api_baseObject

Returns the value of attribute api_base.



5
6
7
# File 'lib/tg_error_notifier/configuration.rb', line 5

def api_base
  @api_base
end

#app_nameObject

Returns the value of attribute app_name.



5
6
7
# File 'lib/tg_error_notifier/configuration.rb', line 5

def app_name
  @app_name
end

#bot_tokenObject

Returns the value of attribute bot_token.



5
6
7
# File 'lib/tg_error_notifier/configuration.rb', line 5

def bot_token
  @bot_token
end

#buttonsObject

Returns the value of attribute buttons.



5
6
7
# File 'lib/tg_error_notifier/configuration.rb', line 5

def buttons
  @buttons
end

#chat_idObject

Returns the value of attribute chat_id.



5
6
7
# File 'lib/tg_error_notifier/configuration.rb', line 5

def chat_id
  @chat_id
end

#enabledObject

Returns the value of attribute enabled.



5
6
7
# File 'lib/tg_error_notifier/configuration.rb', line 5

def enabled
  @enabled
end

#environmentObject

Returns the value of attribute environment.



5
6
7
# File 'lib/tg_error_notifier/configuration.rb', line 5

def environment
  @environment
end

#grouping_enabledObject

Returns the value of attribute grouping_enabled.



5
6
7
# File 'lib/tg_error_notifier/configuration.rb', line 5

def grouping_enabled
  @grouping_enabled
end

#grouping_windowObject

Returns the value of attribute grouping_window.



5
6
7
# File 'lib/tg_error_notifier/configuration.rb', line 5

def grouping_window
  @grouping_window
end

#ignored_environmentsObject

Returns the value of attribute ignored_environments.



5
6
7
# File 'lib/tg_error_notifier/configuration.rb', line 5

def ignored_environments
  @ignored_environments
end

#ignored_exceptionsObject

Returns the value of attribute ignored_exceptions.



5
6
7
# File 'lib/tg_error_notifier/configuration.rb', line 5

def ignored_exceptions
  @ignored_exceptions
end

#include_backtraceObject

Returns the value of attribute include_backtrace.



5
6
7
# File 'lib/tg_error_notifier/configuration.rb', line 5

def include_backtrace
  @include_backtrace
end

#loggerObject

Returns the value of attribute logger.



5
6
7
# File 'lib/tg_error_notifier/configuration.rb', line 5

def logger
  @logger
end

#max_backtrace_linesObject

Returns the value of attribute max_backtrace_lines.



5
6
7
# File 'lib/tg_error_notifier/configuration.rb', line 5

def max_backtrace_lines
  @max_backtrace_lines
end

#open_timeoutObject

Returns the value of attribute open_timeout.



5
6
7
# File 'lib/tg_error_notifier/configuration.rb', line 5

def open_timeout
  @open_timeout
end

#proxy_addrObject

Returns the value of attribute proxy_addr.



5
6
7
# File 'lib/tg_error_notifier/configuration.rb', line 5

def proxy_addr
  @proxy_addr
end

#proxy_passObject

Returns the value of attribute proxy_pass.



5
6
7
# File 'lib/tg_error_notifier/configuration.rb', line 5

def proxy_pass
  @proxy_pass
end

#proxy_portObject

Returns the value of attribute proxy_port.



5
6
7
# File 'lib/tg_error_notifier/configuration.rb', line 5

def proxy_port
  @proxy_port
end

#proxy_userObject

Returns the value of attribute proxy_user.



5
6
7
# File 'lib/tg_error_notifier/configuration.rb', line 5

def proxy_user
  @proxy_user
end

#read_timeoutObject

Returns the value of attribute read_timeout.



5
6
7
# File 'lib/tg_error_notifier/configuration.rb', line 5

def read_timeout
  @read_timeout
end

#topic_icon_colorObject

Returns the value of attribute topic_icon_color.



5
6
7
# File 'lib/tg_error_notifier/configuration.rb', line 5

def topic_icon_color
  @topic_icon_color
end

#topic_store_readObject

Returns the value of attribute topic_store_read.



5
6
7
# File 'lib/tg_error_notifier/configuration.rb', line 5

def topic_store_read
  @topic_store_read
end

#topic_store_writeObject

Returns the value of attribute topic_store_write.



5
6
7
# File 'lib/tg_error_notifier/configuration.rb', line 5

def topic_store_write
  @topic_store_write
end

#topics_enabledObject

Returns the value of attribute topics_enabled.



5
6
7
# File 'lib/tg_error_notifier/configuration.rb', line 5

def topics_enabled
  @topics_enabled
end

Instance Method Details

#proxy?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/tg_error_notifier/configuration.rb', line 79

def proxy?
  proxy_addr.present? && proxy_port.present?
end