1
0
Fork 0

Configure Sentry error logger

This commit is contained in:
Alex Kotov 2018-11-29 19:57:40 +05:00
parent 1127a3cd05
commit 9adcefce02
No known key found for this signature in database
GPG key ID: 4E831250F47DE154
5 changed files with 23 additions and 1 deletions

View file

@ -71,6 +71,9 @@ gem 'simple_form', '~> 4.1'
# get, put, post, delete. # get, put, post, delete.
gem 'rest-client', '~> 2.0' gem 'rest-client', '~> 2.0'
# A gem that provides a client interface for the Sentry error logger.
gem 'sentry-raven'
group :development, :test do group :development, :test do
# factory_bot provides a framework and DSL for defining and using factories. # factory_bot provides a framework and DSL for defining and using factories.
gem 'factory_bot_rails', '~> 4.10' gem 'factory_bot_rails', '~> 4.10'

View file

@ -91,6 +91,8 @@ GEM
railties (>= 3.0.0) railties (>= 3.0.0)
faker (1.9.1) faker (1.9.1)
i18n (>= 0.7) i18n (>= 0.7)
faraday (0.15.4)
multipart-post (>= 1.2, < 3)
ffi (1.9.25) ffi (1.9.25)
font-awesome-sass (5.5.0.1) font-awesome-sass (5.5.0.1)
sassc (>= 1.11) sassc (>= 1.11)
@ -130,6 +132,7 @@ GEM
minitest (5.11.3) minitest (5.11.3)
msgpack (1.2.4) msgpack (1.2.4)
multi_json (1.13.1) multi_json (1.13.1)
multipart-post (2.0.0)
net-scp (1.2.1) net-scp (1.2.1)
net-ssh (>= 2.6.5) net-ssh (>= 2.6.5)
net-ssh (5.0.2) net-ssh (5.0.2)
@ -229,6 +232,8 @@ GEM
sassc (2.0.0) sassc (2.0.0)
ffi (~> 1.9.6) ffi (~> 1.9.6)
rake rake
sentry-raven (2.7.4)
faraday (>= 0.7.6, < 1.0)
shoulda-matchers (4.0.0.rc1) shoulda-matchers (4.0.0.rc1)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
simple_form (4.1.0) simple_form (4.1.0)
@ -306,6 +311,7 @@ DEPENDENCIES
rspec-rails (~> 3.8) rspec-rails (~> 3.8)
rubocop (~> 0.60.0) rubocop (~> 0.60.0)
sass-rails (~> 5.0) sass-rails (~> 5.0)
sentry-raven
shoulda-matchers (= 4.0.0.rc1) shoulda-matchers (= 4.0.0.rc1)
simple_form (~> 4.1) simple_form (~> 4.1)
simplecov (~> 0.16) simplecov (~> 0.16)

View file

@ -3,6 +3,8 @@
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
class NotAuthorizedError < RuntimeError; end class NotAuthorizedError < RuntimeError; end
before_action :set_raven_context
skip_before_action :verify_authenticity_token, if: :json_request? skip_before_action :verify_authenticity_token, if: :json_request?
rescue_from ActiveRecord::RecordNotFound, with: :not_found rescue_from ActiveRecord::RecordNotFound, with: :not_found
@ -10,6 +12,10 @@ class ApplicationController < ActionController::Base
private private
def set_raven_context
Raven.extra_context params: params.to_unsafe_h, url: request.url
end
def json_request? def json_request?
request.format.json? request.format.json?
end end

View file

@ -1 +1 @@
QtBlpQuGa0BjUXzdXxBXqXTp1qUF9xc4ULh4fJgAjWsShLAU62TwOmjiLw6gKeIGIZd9n1/hV6LcQRi8lPzq6kOHeLoBbKXub8+9lAZ/zsi+2LMvlgvlacZWw02BEpQMIoZuXrEojpzFSj+2b6Gx6ucC8ArSg6u64i+B7vl8i+MReQ7aKYn48J9TQ1NM4wwnpsSLC4VLlQ==--FuMPDqLpq9qRARv0--m/DxSG1WI+CMj/K3rtJAFw== i9dq5b23/WWVOHGT0oGn4az0IUsiiVxaKgALjdbjioR6mhG1jCbAgbLlM4B9RBD81bD9Ej6C1fP/09el7UqRHXF/2tDSUajqSshcJPw+IoyHqv75QC3DS8q/g8b8/C8Lq/Hdvf0tf1aL4/WWWPGx17QKnZ4pWIwS5Uwv3DW9Eu9L/4kF9aRrqIklu5BeAgbzkmJLCMWW1ibeMoqmQivzWtpgQB6dFuLTagSzNLnjBhS9115L7io39tpgHxB1OMagucUAD4HzDNlbbVxlMHjpdUm/1lGrdOmlO5KtVimk7Re35zzCGVWSwvZUD4hU2uxDpsj1h9wnlE0A4CnEOgc=--8xj8CLI7TZtxNsNg--FqcFVtzsNWWfQk7BnZg/oQ==

View file

@ -0,0 +1,7 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file.
Raven.configure do |config|
config.dsn = Rails.application.secrets.raven_dsn
end