I would like to add a custom Tab to bugsnag for all notifications generated by my rails app.
I cannot use :before_bugsnag_notify because the errors are sometimes generated by models which are being called from resque background jobs.
So, I settled on using middleware and I am running to some issues here:
so I went through this guide here: https://bugsnag.com/docs/notifiers/ruby#bugsnag-middleware
and added my middleware at app/middleware as follows:
class CustomMiddleware
def initialize(bugsnag)
@bugsnag = bugsnag
end
def call(notification)
puts "doing something"
@bugsnag.call(notification)
end
end
The config file for bugsnag is as follows:
in config/initializers/bugsnag.rb:
Bugsnag.configure do |config|
config.api_key = "#{ENV['BUGSNAG_API_KEY']}"
config.middleware.use "CustomMiddleWare"
end
Eventually, I would like to add a tab using add_tab() method before @bugsnag.call(), but now I keep running into the error that I cannot fix:
** [Bugsnag] Bugsnag middleware error: undefined method `new' for "CustomMiddleWare":String
Any ideas?
Edit: I had to put the method name is strings because of this: Where do you put your Rack middleware files and requires?