getsentry / sentry-javascript

Official Sentry SDKs for JavaScript
https://sentry.io
MIT License
8.01k stars 1.58k forks source link

Rename submodule export from `setup` #13589

Open nicohrubec opened 2 months ago

nicohrubec commented 2 months ago

The setup.ts file in our NestJS SDK relies on imports from @nestjs/core and @nestjs/common. This initially led to problems with our otel instrumentation, because the NestJS packages were being imported in applications before we could call Sentry.init, leading to the standard @nestjs/core otel instrumentation not being loaded properly.

We solved this by adding a submodule export @sentry/nestjs/setup for the setup.ts file. However, the naming of this might be a bit confusing to users or specifically what should be imported from this submodule export vs the non-submodule export. One idea for a rename would be module, since the file actually mainly exports the SentryModule. This would require to also rename the setup.ts file, because the name of the file and submodule path must be identical for some reason.

Additional Note: Originally the SentryModule also included the global error filters provided by Sentry (SentryGlobalFilter and SentryGlobalGraphQLFilter). For this reason these filters still live in this file. However, these filters are no longer part of the SentryModule, meaning that we could potentially looking into moving these error filters to a separate file, which would then allow us to export them from @sentry/nestjs instead of @sentry/nestjs/setup.

lforst commented 1 week ago

The SentryGlobalFilter still extends the BaseExceptionFilter as exported from @nestjs/core, so I don't think we can move these filters out of the setup submodule export as outlined in the issue description. We can still think about renaming the export. However, I don't think the current naming is bad.