Merge pull request #5820 from tchak/update-sentry

This commit is contained in:
Pierre de La Morinerie 2021-02-02 14:43:12 +01:00 committed by GitHub
commit 16e860e00c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 101 additions and 91 deletions

View file

@ -70,7 +70,8 @@ gem 'rqrcode'
gem 'ruby-saml-idp'
gem 'sanitize-url'
gem 'sassc-rails' # Use SCSS for stylesheets
gem 'sentry-raven'
gem 'sentry-rails'
gem 'sentry-ruby'
gem 'sib-api-v3-sdk'
gem 'skylight'
gem 'smart_listing'

View file

@ -22,38 +22,38 @@ GEM
specs:
aasm (5.1.1)
concurrent-ruby (~> 1.0)
actioncable (6.0.3.3)
actionpack (= 6.0.3.3)
actioncable (6.0.3.4)
actionpack (= 6.0.3.4)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.0.3.3)
actionpack (= 6.0.3.3)
activejob (= 6.0.3.3)
activerecord (= 6.0.3.3)
activestorage (= 6.0.3.3)
activesupport (= 6.0.3.3)
actionmailbox (6.0.3.4)
actionpack (= 6.0.3.4)
activejob (= 6.0.3.4)
activerecord (= 6.0.3.4)
activestorage (= 6.0.3.4)
activesupport (= 6.0.3.4)
mail (>= 2.7.1)
actionmailer (6.0.3.3)
actionpack (= 6.0.3.3)
actionview (= 6.0.3.3)
activejob (= 6.0.3.3)
actionmailer (6.0.3.4)
actionpack (= 6.0.3.4)
actionview (= 6.0.3.4)
activejob (= 6.0.3.4)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.0.3.3)
actionview (= 6.0.3.3)
activesupport (= 6.0.3.3)
actionpack (6.0.3.4)
actionview (= 6.0.3.4)
activesupport (= 6.0.3.4)
rack (~> 2.0, >= 2.0.8)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.0.3.3)
actionpack (= 6.0.3.3)
activerecord (= 6.0.3.3)
activestorage (= 6.0.3.3)
activesupport (= 6.0.3.3)
actiontext (6.0.3.4)
actionpack (= 6.0.3.4)
activerecord (= 6.0.3.4)
activestorage (= 6.0.3.4)
activesupport (= 6.0.3.4)
nokogiri (>= 1.8.5)
actionview (6.0.3.3)
activesupport (= 6.0.3.3)
actionview (6.0.3.4)
activesupport (= 6.0.3.4)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
@ -68,25 +68,25 @@ GEM
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
active_storage_validations (0.9.0)
rails (>= 5.2.0)
activejob (6.0.3.3)
activesupport (= 6.0.3.3)
activejob (6.0.3.4)
activesupport (= 6.0.3.4)
globalid (>= 0.3.6)
activemodel (6.0.3.3)
activesupport (= 6.0.3.3)
activerecord (6.0.3.3)
activemodel (= 6.0.3.3)
activesupport (= 6.0.3.3)
activestorage (6.0.3.3)
actionpack (= 6.0.3.3)
activejob (= 6.0.3.3)
activerecord (= 6.0.3.3)
activemodel (6.0.3.4)
activesupport (= 6.0.3.4)
activerecord (6.0.3.4)
activemodel (= 6.0.3.4)
activesupport (= 6.0.3.4)
activestorage (6.0.3.4)
actionpack (= 6.0.3.4)
activejob (= 6.0.3.4)
activerecord (= 6.0.3.4)
marcel (~> 0.3.1)
activestorage-openstack (1.4.1)
fog-openstack (~> 1.0)
marcel
mime-types
rails (>= 5.2.2)
activesupport (6.0.3.3)
activesupport (6.0.3.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
@ -182,7 +182,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.1.7)
concurrent-ruby (1.1.8)
connection_pool (2.2.3)
crack (0.4.4)
crass (1.0.6)
@ -237,7 +237,7 @@ GEM
http_parser.rb (~> 0.6.0)
encryptor (3.0.0)
equalizer (0.0.11)
erubi (1.9.0)
erubi (1.10.0)
erubis (2.7.0)
et-orbi (1.2.4)
tzinfo
@ -248,8 +248,11 @@ GEM
execjs (2.7.0)
factory_bot (5.1.2)
activesupport (>= 4.2.0)
faraday (1.0.1)
faraday (1.3.0)
faraday-net_http (~> 1.0)
multipart-post (>= 1.2, < 3)
ruby2_keywords
faraday-net_http (1.0.1)
ffi (1.13.1)
ffi-geos (2.1.0)
ffi (>= 1.0.0)
@ -356,7 +359,7 @@ GEM
http_accept_language (2.1.1)
http_parser.rb (0.6.0)
httpclient (2.8.3)
i18n (1.8.5)
i18n (1.8.7)
concurrent-ruby (~> 1.0)
iban-tools (1.1.0)
ice_nine (0.11.2)
@ -409,7 +412,7 @@ GEM
railties (>= 4)
request_store (~> 1.0)
logstash-event (1.2.02)
loofah (2.7.0)
loofah (2.9.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
lumberjack (1.2.4)
@ -429,7 +432,7 @@ GEM
mini_magick (4.11.0)
mini_mime (1.0.2)
mini_portile2 (2.5.0)
minitest (5.14.2)
minitest (5.14.3)
momentjs-rails (2.20.1)
railties (>= 3.1)
multi_json (1.15.0)
@ -513,20 +516,20 @@ GEM
rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (6.0.3.3)
actioncable (= 6.0.3.3)
actionmailbox (= 6.0.3.3)
actionmailer (= 6.0.3.3)
actionpack (= 6.0.3.3)
actiontext (= 6.0.3.3)
actionview (= 6.0.3.3)
activejob (= 6.0.3.3)
activemodel (= 6.0.3.3)
activerecord (= 6.0.3.3)
activestorage (= 6.0.3.3)
activesupport (= 6.0.3.3)
rails (6.0.3.4)
actioncable (= 6.0.3.4)
actionmailbox (= 6.0.3.4)
actionmailer (= 6.0.3.4)
actionpack (= 6.0.3.4)
actiontext (= 6.0.3.4)
actionview (= 6.0.3.4)
activejob (= 6.0.3.4)
activemodel (= 6.0.3.4)
activerecord (= 6.0.3.4)
activestorage (= 6.0.3.4)
activesupport (= 6.0.3.4)
bundler (>= 1.3.0)
railties (= 6.0.3.3)
railties (= 6.0.3.4)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
@ -545,14 +548,14 @@ GEM
rails-i18n (6.0.0)
i18n (>= 0.7, < 2)
railties (>= 6.0.0, < 7)
railties (6.0.3.3)
actionpack (= 6.0.3.3)
activesupport (= 6.0.3.3)
railties (6.0.3.4)
actionpack (= 6.0.3.4)
activesupport (= 6.0.3.4)
method_source
rake (>= 0.8.7)
thor (>= 0.20.3, < 2.0)
rainbow (3.0.0)
rake (13.0.1)
rake (13.0.3)
rake-progressbar (0.0.5)
rb-fsevent (0.10.4)
rb-inotify (0.10.1)
@ -646,7 +649,7 @@ GEM
ruby-saml-idp (0.3.5)
ruby-vips (2.0.17)
ffi (~> 1.9)
ruby2_keywords (0.0.2)
ruby2_keywords (0.0.4)
ruby_parser (3.15.0)
sexp_processor (~> 4.9)
rubyzip (2.3.0)
@ -671,8 +674,16 @@ GEM
childprocess (>= 0.5, < 4.0)
rubyzip (>= 1.2.2)
semantic_range (2.3.0)
sentry-raven (3.1.0)
sentry-rails (4.1.6)
rails (>= 5.0)
sentry-ruby-core (~> 4.1.2)
sentry-ruby (4.1.5)
concurrent-ruby (~> 1.0, >= 1.0.2)
faraday (>= 1.0)
sentry-ruby-core (= 4.1.5)
sentry-ruby-core (4.1.5)
concurrent-ruby
faraday
sexp_processor (4.15.1)
shellany (0.0.1)
shoulda-matchers (4.4.1)
@ -718,14 +729,14 @@ GEM
httpclient (>= 2.4)
sysexits (1.2.0)
temple (0.8.2)
thor (1.0.1)
thor (1.1.0)
thread_safe (0.3.6)
tilt (2.0.10)
timecop (0.9.1)
ttfunk (1.6.2.1)
typhoeus (1.4.0)
ethon (>= 0.9.0)
tzinfo (1.2.7)
tzinfo (1.2.9)
thread_safe (~> 0.1)
unf (0.1.4)
unf_ext
@ -774,7 +785,7 @@ GEM
nokogiri (~> 1.8)
xray-rails (0.3.2)
rails (>= 3.1.0)
zeitwerk (2.4.0)
zeitwerk (2.4.2)
zip_tricks (5.3.1)
zipline (1.2.1)
rails (>= 3.2.1, < 6.1)
@ -884,7 +895,8 @@ DEPENDENCIES
sanitize-url
sassc-rails
scss_lint
sentry-raven
sentry-rails
sentry-ruby
shoulda-matchers
sib-api-v3-sdk
simple_xlsx_reader

View file

@ -61,7 +61,7 @@ class API::V2::GraphqlController < API::V2::BaseController
def handle_error_in_production(exception)
id = SecureRandom.uuid
Raven.capture_exception(exception, extra: { exception_id: id })
Sentry.capture_exception(exception, extra: { exception_id: id })
render json: {
errors: [

View file

@ -10,7 +10,7 @@ class ApplicationController < ActionController::Base
protect_from_forgery with: :exception, if: -> { !Rails.env.test? }
before_action :set_current_roles
before_action :load_navbar_left_pannel_partial_url
before_action :set_raven_context
before_action :set_sentry_user
before_action :redirect_if_untrusted
before_action :reject, if: -> { feature_enabled?(:maintenance_mode) }
before_action :configure_permitted_parameters, if: :devise_controller?
@ -149,8 +149,8 @@ class ApplicationController < ActionController::Base
end
end
def set_raven_context
Raven.user_context(sentry_user)
def set_sentry_user
Sentry.set_user(sentry_user)
end
# private method called by rails fwk

View file

@ -12,7 +12,7 @@ class ApplicationJob < ActiveJob::Base
end
def error(job, exception)
Raven.capture_exception(exception)
Sentry.capture_exception(exception)
end
def max_attempts

View file

@ -13,7 +13,7 @@ class Cron::AutoArchiveProcedureJob < Cron::CronJob
procedure.close!
rescue StandardError => e
Raven.capture_exception(e, extra: { procedure_id: procedure.id })
Sentry.capture_exception(e, extra: { procedure_id: procedure.id })
end
end
end

View file

@ -25,8 +25,7 @@ class ApplicationMailer < ActionMailer::Base
rescue StandardError => e
# A problem occured when reading logo, maybe the logo is missing and we should clean the procedure to remove logo reference ?
Raven.extra_context(procedure_id: procedure.id)
Raven.capture_exception(e)
Sentry.capture_exception(e, extra: { procedure_id: procedure.id })
nil
end
end

View file

@ -35,7 +35,7 @@ class AssignTo < ApplicationRecord
# a bug somewhere else that we need to fix.
errors = procedure_presentation.errors
Raven.capture_message(
Sentry.capture_message(
"Destroying invalid ProcedurePresentation",
extra: { procedure_presentation: procedure_presentation.as_json }
)

View file

@ -76,7 +76,7 @@ class ProcedureExportService
# transliterate: convert to ASCII characters
# to ensure truncate respects 30 bytes
# /\*?[] are invalid Excel worksheet characters
options[:sheet_name] = I18n.transliterate(options[:sheet_name], '', locale: :en)
options[:sheet_name] = I18n.transliterate(options[:sheet_name], locale: :en)
.delete('/\*?[]')
.truncate(30, omission: '')

View file

@ -1,8 +0,0 @@
if ENV['SENTRY_ENABLED'] == 'enabled'
require 'raven'
Raven.configure do |config|
config.dsn = ENV['SENTRY_DSN_RAILS']
config.environments = ['production', 'staging']
end
end

View file

@ -0,0 +1,6 @@
Sentry.init do |config|
config.dsn = ENV['SENTRY_ENABLED'] == 'enabled' ? ENV['SENTRY_DSN_RAILS'] : nil
config.send_default_pii = false
config.enabled_environments = ['production']
config.breadcrumbs_logger = [:active_support_logger]
end

View file

@ -1,17 +1,17 @@
describe ApplicationController, type: :controller do
describe 'before_action: set_raven_context' do
describe 'before_action: set_sentry_user' do
it 'is present' do
before_actions = ApplicationController
._process_action_callbacks
.filter { |process_action_callbacks| process_action_callbacks.kind == :before }
.map(&:filter)
expect(before_actions).to include(:set_raven_context)
expect(before_actions).to include(:set_sentry_user)
expect(before_actions).to include(:redirect_if_untrusted)
end
end
describe 'set_raven_context and append_info_to_payload' do
describe 'set_sentry_user and append_info_to_payload' do
let(:current_user) { nil }
let(:current_instructeur) { nil }
let(:current_administrateur) { nil }
@ -24,15 +24,15 @@ describe ApplicationController, type: :controller do
expect(@controller).to receive(:current_instructeur).and_return(current_instructeur)
expect(@controller).to receive(:current_administrateur).and_return(current_administrateur)
expect(@controller).to receive(:current_super_admin).and_return(current_super_admin)
allow(Raven).to receive(:user_context)
allow(Sentry).to receive(:set_user)
@controller.send(:set_raven_context)
@controller.send(:set_sentry_user)
@controller.send(:append_info_to_payload, payload)
end
context 'when no one is logged in' do
it do
expect(Raven).to have_received(:user_context)
expect(Sentry).to have_received(:set_user)
.with({ id: 'Guest' })
end
@ -53,7 +53,7 @@ describe ApplicationController, type: :controller do
let(:current_user) { create(:user) }
it do
expect(Raven).to have_received(:user_context)
expect(Sentry).to have_received(:set_user)
.with({ id: "User##{current_user.id}" })
end
@ -79,7 +79,7 @@ describe ApplicationController, type: :controller do
let(:current_super_admin) { create(:super_admin) }
it do
expect(Raven).to have_received(:user_context)
expect(Sentry).to have_received(:set_user)
.with({ id: "User##{current_user.id}" })
end

View file

@ -72,7 +72,7 @@ RSpec.describe Cron::AutoArchiveProcedureJob, type: :job do
error = StandardError.new('nop')
expect(buggy_procedure).to receive(:close!).and_raise(error)
expect(job).to receive(:procedures_to_close).and_return([buggy_procedure, procedure_hier])
expect(Raven).to receive(:capture_exception).with(error, extra: { procedure_id: buggy_procedure.id })
expect(Sentry).to receive(:capture_exception).with(error, extra: { procedure_id: buggy_procedure.id })
subject
end