Module: StandardId::SentryContext
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/controllers/concerns/standard_id/sentry_context.rb
Overview
Sets Sentry user context from the current authenticated account.
This is a standalone concern that host apps can include in their ApplicationController to automatically set Sentry user context for each request. It eliminates the need for apps to write their own SentryContext boilerplate.
Safe to include even when the Sentry gem is not installed – the callback is a no-op if ‘Sentry` is not defined.
Extra fields can be added via the ‘sentry_context` config option:
StandardId.configure do |c|
c.sentry_context = ->(account, session) {
{ email: account.email, username: account.try(:display_name) }
}
end
The lambda must return a Hash (nil and non-Hash returns are ignored). Base keys (id, session_id) always take precedence and cannot be overridden by the lambda. Exceptions raised by the lambda are not caught — they will propagate to surface misconfiguration immediately.