From c2a6a3a4fe7af7c9340acaeee5a38dce9e23912b Mon Sep 17 00:00:00 2001 From: anubhav8421 Date: Wed, 7 Aug 2019 18:25:18 +0530 Subject: [PATCH] #8 - Add configuration for sentry --- Gemfile | 1 + Gemfile.lock | 7 ++++++- app/controllers/application_controller.rb | 7 +++++++ config/initializers/sentry.rb | 4 ++++ 4 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 config/initializers/sentry.rb diff --git a/Gemfile b/Gemfile index 36491c7..dab0632 100644 --- a/Gemfile +++ b/Gemfile @@ -27,6 +27,7 @@ gem 'uglifier', '>= 1.0.3' gem 'byebug', '~>11.0.1' gem 'puma', '~> 4.0.1' gem 'twitter', '~> 6.2.0' +gem 'sentry-raven', '~> 2.11' #gem 'jquery-rails' gem "devise", "~> 4.6.2" gem "omniauth", "~>1.9.0" diff --git a/Gemfile.lock b/Gemfile.lock index 27fde3d..90ee532 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -88,13 +88,15 @@ GEM erubi (1.8.0) erubis (2.7.0) execjs (2.7.0) + faraday (0.15.4) + multipart-post (>= 1.2, < 3) ffi (1.11.1) formtastic (3.1.5) actionpack (>= 3.2.13) formtastic_i18n (0.6.0) globalid (0.4.2) activesupport (>= 4.2.0) - haml (5.1.1) + haml (5.1.2) temple (>= 0.8.0) tilt haml-rails (2.0.1) @@ -244,6 +246,8 @@ GEM sprockets (> 3.0) sprockets-rails tilt + sentry-raven (2.11.0) + faraday (>= 0.7.6, < 1.0) sexp_processor (4.12.1) simple_oauth (0.3.1) sprockets (3.7.2) @@ -310,6 +314,7 @@ DEPENDENCIES pygmentize (~> 0.0.3) rails (= 5.2.3) redcarpet (~> 1.17.2) + sentry-raven (~> 2.11) twitter (~> 6.2.0) twitter-bootstrap-rails (~> 4.0.0) uglifier (>= 1.0.3) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 45eef3a..79ecd4b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,4 +1,11 @@ class ApplicationController < ActionController::Base protect_from_forgery + before_action :set_raven_context + + private + def set_raven_context + Raven.user_context(id: session[:current_user_id]) + Raven.extra_context(params: params.to_unsafe_h, url: request.url) + end end diff --git a/config/initializers/sentry.rb b/config/initializers/sentry.rb new file mode 100644 index 0000000..b504df8 --- /dev/null +++ b/config/initializers/sentry.rb @@ -0,0 +1,4 @@ +Raven.configure do |config| + config.dsn = ENV['SENTRY_DSN'] + config.sanitize_fields = Rails.application.config.filter_parameters.map(&:to_s) +end