Class: ExceptionNotifier::WebhookNotifier
- Inherits:
-
BaseNotifier
- Object
- BaseNotifier
- ExceptionNotifier::WebhookNotifier
- Defined in:
- lib/exception_notifier/webhook_notifier.rb
Instance Attribute Summary
Attributes inherited from BaseNotifier
Instance Method Summary collapse
- #call(exception, options = {}) ⇒ Object
-
#initialize(options) ⇒ WebhookNotifier
constructor
A new instance of WebhookNotifier.
Methods inherited from BaseNotifier
#_post_callback, #_pre_callback, #send_notice
Constructor Details
#initialize(options) ⇒ WebhookNotifier
Returns a new instance of WebhookNotifier.
6 7 8 9 |
# File 'lib/exception_notifier/webhook_notifier.rb', line 6 def initialize() super @default_options = end |
Instance Method Details
#call(exception, options = {}) ⇒ Object
11 12 13 14 15 16 17 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 |
# File 'lib/exception_notifier/webhook_notifier.rb', line 11 def call(exception, ={}) env = [:env] = .reverse_merge(@default_options) url = .delete(:url) http_method = .delete(:http_method) || :post [:body] ||= {} [:body][:server] = Socket.gethostname [:body][:process] = $$ if defined?(Rails) && Rails.respond_to?(:root) [:body][:rails_root] = Rails.root end [:body][:exception] = {:error_class => exception.class.to_s, :message => exception..inspect, :backtrace => exception.backtrace} [:body][:data] = (env && env['exception_notifier.exception_data'] || {}).merge([:data] || {}) unless env.nil? 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 } [:body][:request] = request_items [:body][:session] = request.session [:body][:environment] = request.filtered_env end send_notice(exception, , nil, @default_options) do |msg, opts| HTTParty.send(http_method, url, opts) end end |