Skip to content

Commit

Permalink
Bit more Sentry context
Browse files Browse the repository at this point in the history
  • Loading branch information
TomNaessens committed May 26, 2024
1 parent 3d2f283 commit fccf57a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ class ApplicationController < ActionController::Base
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception

include SentryUserContext

after_action :store_location

def store_location
Expand Down
25 changes: 25 additions & 0 deletions app/controllers/concerns/sentry_user_context.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

module SentryUserContext
extend ActiveSupport::Concern

included do
before_action :set_sentry_context
end

private

def sentry_user_context
{}.tap do |user|
next unless current_user

user[:id] = current_user.id
user[:email] = current_user.cas_mail
user[:name] = current_user.username
end
end

def set_sentry_context
Sentry.set_user(sentry_user_context)
end
end

0 comments on commit fccf57a

Please sign in to comment.