Contract from the following https://sentry.io/signup/
You will create a project at the time of contract, and the setup method is written on the screen after creating the project, so there should be no problem if you proceed according to the procedure. Just in case, I will reorganize it like myself.
Gemfile
gem "sentry-raven"
$ bundle install
config/application.rb
module AppName
class Application < Rails::Application
#abridgement
Raven.configure do |config|
config.dsn = "https://#{ENV['SENTRY_KEY']}@#{ENV['SENTRY_SECRET']}.sentry.io/#{ENV['SENTRY_ID']}"
end
end
end
In the setup method displayed on the Sentry site, all the IDs etc. are written directly, so I put it in an environment variable.
app/controllers/application.rb
class ApplicationController < ActionController::Base
before_action :set_raven_context
private
def set_raven_context
Raven.user_context(id: session[:current_user_id]) # or anything else in session
Raven.extra_context(params: params.to_unsafe_h, url: request.url)
end
end
$ touch config/initializers/sentry.rb
config/initializers/sentry.rb
Raven.configure do |config|
config.sanitize_fields = Rails.application.config.filter_parameters.map(&:to_s)
end
By default, all development environment errors will be displayed in a list, so correct the settings.
Settings> Projects> Project name> Environments> hide
non-production environments
--Introducing Sentry to Rails application --Qiita
UI is really Slack lol
Recommended Posts