diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 17380a028..6b9a32921 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -53,25 +53,29 @@ def store_region_on_thread extra[:fingerprint] = [error.original_exception.class.name, *trace] end ensure - e = Sentry.capture_exception(error, extra) - puts Oj.dump({ event_id: e.event_id }) + @sentry_event = Sentry.capture_exception(error, **extra) end + end - before_action :tag_sentry_context + before_action :tag_sentry_context - def tag_sentry_context - user = current_user&.resource_owner - Sentry.set_user( - id: user&.id, - name: user&.name, - ip_address: request.remote_ip + def tag_sentry_context + user = current_user&.resource_owner + Sentry.set_user( + id: user&.id, + name: user&.name, + ip_address: request.remote_ip + ) + Sentry.configure_scope do |scope| + scope.set_context( + 'feature flags', + Flipper.preload_all.to_h { |f| [f.name, f.enabled?(user)] } ) - Sentry.configure_scope do |scope| - scope.set_context( - 'feature flags', - Flipper.preload_all.to_h { |f| [f.name, f.enabled?(user)] } - ) - end end end + + def append_info_to_payload(payload) + super + payload[:sentry_event] = @sentry_event + end end diff --git a/config/application.rb b/config/application.rb index 32a8a2c5e..300f62c73 100644 --- a/config/application.rb +++ b/config/application.rb @@ -58,8 +58,9 @@ class Application < Rails::Application config.lograge.custom_options = ->(event) do { params: event.payload[:request].query_parameters, - request_id: event.payload[:headers]['action_dispatch.request_id'] - } + request_id: event.payload[:headers]['action_dispatch.request_id'], + sentry_event_id: event.payload[:sentry_event]&.event_id + }.compact end # Normally we wanna be API-only, but we mount some admin panels in, so... :(