Add lazy error context for Rails error reporter (#2014)

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.
This commit is contained in:
Jeremy Daer
2025-12-08 11:00:40 -08:00
committed by GitHub
parent c2380dc057
commit dcc005be34
2 changed files with 8 additions and 1 deletions
+7
View File
@@ -0,0 +1,7 @@
# 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