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:
+1
-1
@@ -21,7 +21,7 @@ GIT
|
||||
|
||||
GIT
|
||||
remote: https://github.com/basecamp/fizzy-saas
|
||||
revision: 3b30f3d56d8318bb9256469cb91c06a5a5c760a6
|
||||
revision: 43dbc896ce7b6a08194a92ddd1695d3f1ebf554b
|
||||
specs:
|
||||
fizzy-saas (0.1.0)
|
||||
audits1984
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user