{ "html": "
In Rails, all uncaught exceptions will be automatically reported.
\nWe support Rails 3 and newer.
\nInstall the SDK via Rubygems by adding it to your Gemfile
:
gem "sentry-raven"\n
Open up config/application.rb
and configure the DSN, and any other settings\nyou need:
Raven.configure do |config|\n config.dsn = '___DSN___'\nend\n
If you have added items to Rails’ log filtering,\nyou can also make sure that those items are not sent to Sentry:
\n# in your application.rb:\nconfig.filter_parameters << :password\n\n# in an initializer, like sentry.rb\nRaven.configure do |config|\n config.sanitize_fields = Rails.application.config.filter_parameters.map(&:to_s)\nend\n
class ApplicationController < ActionController::Base\n before_action :set_raven_context\n\n private\n\n def set_raven_context\n Raven.user_context(id: session[:current_user_id]) # or anything else in session\n Raven.extra_context(params: params.to_unsafe_h, url: request.url)\n end\nend\n
When using Authlogic for authentication, you can provide user context by\nbinding to session after_persisting
and after_destroy
events in\nuser_session.rb
:
class UserSession < Authlogic::Session::Base\n # events binding\n after_persisting :raven_set_user_context\n after_destroy :raven_clear_user_context\n\n def raven_set_user_context\n Raven.user_context({\n 'id' => self.user.id,\n 'email' => self.user.email,\n 'username' => self.user.username\n })\n end\n\n def raven_clear_user_context\n Raven.user_context({})\n end\nend\n