Skip to content

Instantly share code, notes, and snippets.

@vovimayhem
Last active December 10, 2018 16:42
Show Gist options
  • Save vovimayhem/0a49586e07727bf8306130a0a0f1bf50 to your computer and use it in GitHub Desktop.
Save vovimayhem/0a49586e07727bf8306130a0a0f1bf50 to your computer and use it in GitHub Desktop.
Adding sentry to a rails app
# You can point the Sentry Client to another (i.e. self-hosted) instance by setting this environment variable:
SENTRY_DSN: http://[email protected]/[your_sentry_project_id]
class ApplicationController < ActionController::Base
before_action :set_raven_context
# ...middle of the file ommitted for clarity
private
def set_raven_context
Raven.user_context(id: current_user&.id) # or anything else in session
Raven.extra_context(params: params.to_unsafe_h, url: request.url)
end
end
Raven.configure do |config|
config.sanitize_fields = Rails.application.config.filter_parameters.map(&:to_s)
config.ssl_verification = false
config.tags = { app: :your_app_name, env: Rails.env }
end
# ...start of file ommitted for clarity...
# Provides a client interface for the Sentry error logger
gem 'sentry-raven', '~> 2.7', '>= 2.7.4'
# ...end of file ommitted for clarity...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment