Skip to content

Commit a28d080

Browse files
committed
Track user IDs in Sentry
When sending errors to Sentry this allows us to track which user was logged in at the time of the error, helping us to investigate issues. Only the anonymised user ID will be sent to Sentry rather than any personally identifiable information.
1 parent 1e08edc commit a28d080

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

app/controllers/application_controller.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class ApplicationController < ActionController::Base
1414
before_action :set_service_guide_url
1515
before_action :set_show_navigation
1616
before_action :set_privacy_policy_url
17+
before_action :set_sentry_user
1718
before_action :authenticate_basic
1819

1920
after_action :verify_policy_scoped, if: -> { Rails.env.local? }
@@ -75,4 +76,8 @@ def set_service_guide_url
7576
def set_privacy_policy_url
7677
@privacy_policy_url = nil
7778
end
79+
80+
def set_sentry_user
81+
Sentry.set_user(id: current_user&.id)
82+
end
7883
end

0 commit comments

Comments
 (0)