-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(nestjs): add SentryGlobalGenericFilter
and allow specifying application ref in global filter
#13673
base: develop
Are you sure you want to change the base?
feat(nestjs): add SentryGlobalGenericFilter
and allow specifying application ref in global filter
#13673
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks for that! The new e2e did not pass yet, did you try running it locally?
* Catches exceptions and reports them to Sentry unless they are HttpExceptions. | ||
*/ | ||
public catch(exception: unknown, host: ArgumentsHost): void { | ||
if (host.getType<'graphql'>() === 'graphql') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could think about checking for both host types 'graphql' and 'http' and otherwise provide a warning for an unsupported host type, wdyt?
} | ||
|
||
/** | ||
* Catches exceptions and reports them to Sentry unless they are HttpExceptions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Catches exceptions and reports them to Sentry unless they are HttpExceptions. | |
* Catches exceptions and forwards them to the according error filter. |
Currently, a hybrid nestjs application should create its own global filter, since there is no way to use both http and graphql exception filters from sentry. This adds a new filter that uses the correct filter based on the context.
The new filter should also be usable for http-only and graphql-only applications, so it could be possible to deprecate the other filters.
These changes also allow the application ref to be set in the
SentryGlobalFilter
, which can be nice if the filter is registered withapp.useGlobalFilters()