Class: Exceptify::TeamsNotifier
- Inherits:
-
BaseNotifier
- Object
- BaseNotifier
- Exceptify::TeamsNotifier
- Includes:
- BacktraceCleaner
- Defined in:
- lib/exceptify/teams_notifier.rb
Defined Under Namespace
Classes: MissingController
Instance Attribute Summary collapse
-
#httparty ⇒ Object
Returns the value of attribute httparty.
Attributes inherited from BaseNotifier
Instance Method Summary collapse
- #call(exception, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ TeamsNotifier
constructor
A new instance of TeamsNotifier.
Methods included from BacktraceCleaner
Methods inherited from BaseNotifier
#_post_callback, #_pre_callback, #send_notice
Constructor Details
#initialize(options = {}) ⇒ TeamsNotifier
Returns a new instance of TeamsNotifier.
21 22 23 24 25 26 27 |
# File 'lib/exceptify/teams_notifier.rb', line 21 def initialize( = {}) = .dup @httparty = .delete(:http_client) || HTTParty super() self. = @default_options = end |
Instance Attribute Details
#httparty ⇒ Object
Returns the value of attribute httparty.
19 20 21 |
# File 'lib/exceptify/teams_notifier.rb', line 19 def httparty @httparty end |
Instance Method Details
#call(exception, options = {}) ⇒ Object
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 59 60 61 62 63 64 65 66 |
# File 'lib/exceptify/teams_notifier.rb', line 29 def call(exception, = {}) @options = .merge(@default_options) @exception = exception @backtrace = exception.backtrace ? clean_backtrace(exception) : nil @env = @options.delete(:env) @application_name = @options.delete(:app_name) || rails_app_name @gitlab_url = @options.delete(:git_url) @jira_url = @options.delete(:jira_url) @webhook_url = @options.delete(:webhook_url) raise ArgumentError, "You must provide 'webhook_url' parameter." unless @webhook_url if @env.nil? @controller = @request_items = nil else @controller = @env["action_controller.instance"] || MissingController.new @additional_exception_data = @env["exceptify.exception_data"] request = ActionDispatch::Request.new(@env) @request_items = {url: request.original_url, http_method: request.method, ip_address: request.remote_ip, parameters: request.filtered_parameters, timestamp: Time.current} end payload = @options[:body] = payload.to_json @options[:headers] ||= {} @options[:headers]["Content-Type"] = "application/json" @options[:debug_output] = $stdout @httparty.post(@webhook_url, @options) end |