To be honest, following the sentry
documentation was pretty straightforward.
Change gems
1
2
| # Old
gem "sentry-raven"
|
1
2
3
| # New
gem "sentry-ruby"
gem "sentry-rails"
|
Change initialization
1
2
3
| Raven.configure do |config|
config.dsn = "DSN"
end
|
1
2
3
4
| # New
Sentry.init do |config|
config.dsn = "DSN"
end
|
Change Raven to Sentry
1
2
| # Old
Raven.capture_message("test", extra: { debug: true })
|
1
2
| # New
Sentry.capture_message("test", extra: { debug: true })
|
The only thing I had to check was related to a key called sanitize_fields
that was removed in this new SDK (sentry-ruby) but they implemented at least three new options:
- Use the new key called
send_default_pii = true
already filter the params. - Use a filtering method in the initialization config.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| Copied
Sentry.init do |config|
#...
# this example uses Rails' parameter filter to sanitize the event payload
# for Rails 6+
filter = ActiveSupport::ParameterFilter.new(Rails.application.config.filter_parameters)
# for Rails 5
filter = ActionDispatch::Http::ParameterFilter.new(Rails.application.config.filter_parameters)
config.before_send = lambda do |event, hint|
filter.filter(event.to_hash)
end
end
|
Feel free to pick one, we picked the second one.
more info about sanitize fields