You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to be able to control the contexts that are being attached to the error (in particular, things about the request), but since there's no way to customize the handler that Sentry adds to hook into the nitro error event, I'm left in a bind. In particular, this causes me two issues:
I cannot control the automatic filtering applied in the provided handler to exclude 4xx errors
I cannot attach context from Nitro to the Sentry context -- doing this in beforeSend is not possible because even with the experimental asyncContext via useEvent(), the context will not be available in the sentry.server.config.ts file. However, it is fully available in the handler for the error hook.
Attempting to solely add a second handler that does everything I want runs into the issue of 5xx errors being captured by the Sentry handler, and my handler can't submit the error with the better context, as it gets dropped as a duplicate (not that receiving two errors is great, either).
Solution Brainstorm
I think there are some straightforward solutions, any of which I could make work to cover both of my concerns above:
Add a property to the Nuxt module config that takes a function that will be used in place of the "default" Sentry-provided error hook handler
Add a hook that we can use to modify the Sentry context, etc. before the rest of the hook handler runs. For example:
Add a flag to disable the included hook and leave it up to us to handle it (but keep the custom proxy handler, etc.)
The first or third solution is the most straightforward for me to get what I want -- I already have my own hook that does what I want. The second one has some downsides in that you can't actually drop the error via the custom hook, which is probably not great DX.
The text was updated successfully, but these errors were encountered:
Hey @brtinney thanks for writing in! On first glance, this sounds like a reasonable request to me! I'll leave this up to our Nuxt expert @s1gr1d (who's out today) to further investigate and decide.
Hello and thanks for this request. I think this would make sense.
Add a property to the Nuxt module config that takes a function that will be used in place of the "default" Sentry-provided error hook handler
I think this approach makes more sense than adding a nitro hook. With a nitro hook, the Sentry setup is spread out even more in the codebase and it might be easier if you can just find all server-related settings in the sentry server config.
Problem Statement
I want to be able to control the contexts that are being attached to the error (in particular, things about the request), but since there's no way to customize the handler that Sentry adds to hook into the nitro
error
event, I'm left in a bind. In particular, this causes me two issues:beforeSend
is not possible because even with the experimentalasyncContext
viauseEvent()
, the context will not be available in thesentry.server.config.ts
file. However, it is fully available in the handler for the error hook.Attempting to solely add a second handler that does everything I want runs into the issue of 5xx errors being captured by the Sentry handler, and my handler can't submit the error with the better context, as it gets dropped as a duplicate (not that receiving two errors is great, either).
Solution Brainstorm
I think there are some straightforward solutions, any of which I could make work to cover both of my concerns above:
The first or third solution is the most straightforward for me to get what I want -- I already have my own hook that does what I want. The second one has some downsides in that you can't actually drop the error via the custom hook, which is probably not great DX.
The text was updated successfully, but these errors were encountered: