I have a Rails app which is sending Airbrake notifications fine, but I want to add some user information to the notifications.
I'm using the airbrake gem, v5.7.1, which adds a middleware to capture uncaught exceptions and report them before re-raising.
I tried, as per the README, to add a filter, to an initializer:
class UserDetailsFilter
def call(notice)
if notice.stash.has_key?(:rack_request)
user_credentials = notice.stash[:rack_request].cookies["user_credentials"]
unless user_credentials.blank?
user_id = user_credentials.split(':').last
user = User.find(user_id)
notice[:params][:user_email] = user.email
notice[:params][:user_name] = "#{user.first_name} #{user.last_name}"
end
end
end
end
Airbrake.add_filter(UserDetailsFilter.new)
Using binding.pry
I can confirm that this code is run and that notice does have the :params
hash modified. However the params in the Airbrake UI only have action and controller information.
This was a bug in the Airbrake gem which has been fixed and was released in Airbrake 5.8.0.