Update Raven references to use Sentry

This commit is contained in:
Paul Chavard 2021-01-28 14:49:22 +01:00
parent 6ea44eefa9
commit 41c3a98d7d
8 changed files with 17 additions and 18 deletions

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

@ -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