-
-
Save vovimayhem/0a49586e07727bf8306130a0a0f1bf50 to your computer and use it in GitHub Desktop.
Adding sentry to a rails app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ...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