Skip to content
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

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

Sjoertjuh
Copy link

@Sjoertjuh Sjoertjuh commented Sep 12, 2024

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 with app.useGlobalFilters()

Copy link
Member

@chargome chargome left a 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') {
Copy link
Member

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Catches exceptions and reports them to Sentry unless they are HttpExceptions.
* Catches exceptions and forwards them to the according error filter.

@chargome chargome self-assigned this Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants