Search code examples
ruby-on-railsrubyrubygemssentry

Missing piece in Sentry-raven to Sentry-ruby guide


I'm in the middle of migrating our existing application from Sentry-raven to Sentry-ruby. There appears to be a missing piece in the migration guide, however.

What do I do with #sanitize_fields?

The old config looked like this:

 Raven.configure do |config|
   config.sanitize_fields = filter_parameters
 end 

However, #sanitize_fields was removed and I don't see anywhere where the functionality was replaced.

We used this to ensure that passwords and confirmations were not sent to Sentry (bad day), so I need something to do that in using sentry-ruby.

Any help would be greatly appreciated.


Solution

  • Great suggestion from Sampat. To save future readers having to go through all the comments, the summary is:

    1. If you're using Rails you can use this snippet:
      filter = ActiveSupport::ParameterFilter.new(Rails.application.config.filter_parameters)
    
      config.before_send = lambda do |event, hint|
        filter.filter(event.to_hash)
      end
    
    1. Alternatively use this gem, developed to replace the previous sanitization functionality