dcc005be34
Register a middleware with Rails.error that adds identity_id and account_id from Current attributes. Only evaluated when an error is actually reported, avoiding the cost on successful requests.
8 lines
281 B
Ruby
8 lines
281 B
Ruby
# Lazily add identity and account context to error reports.
|
|
# Only evaluated when an error is actually reported.
|
|
Rails.error.add_middleware ->(error, context:, **) do
|
|
context.merge \
|
|
identity_id: Current.identity&.id,
|
|
account_id: Current.account&.external_account_id
|
|
end
|