The personal finance app for everyone
Add Sentry user context to authentication concern
Josh Pigford763e222cddb9
diff --git a/app/controllers/concerns/authentication.rb b/app/controllers/concerns/authentication.rbindex a66d1b3f..9dc23942 100644--- a/app/controllers/concerns/authentication.rb+++ b/app/controllers/concerns/authentication.rb@@ -4,11 +4,13 @@ module Authenticationincluded dobefore_action :set_request_detailsbefore_action :authenticate_user!+ before_action :set_sentry_userendclass_methods dodef skip_authentication(**options)skip_before_action :authenticate_user!, **options+ skip_before_action :set_sentry_user, **optionsendend@@ -43,4 +45,17 @@ module AuthenticationCurrent.user_agent = request.user_agentCurrent.ip_address = request.ipend++ def set_sentry_user+ return unless defined?(Sentry) && ENV["SENTRY_DSN"].present?++ if Current.user+ Sentry.set_user(+ id: Current.user.id,+ email: Current.user.email,+ username: Current.user.display_name,+ ip_address: Current.ip_address+ )+ end+ endend