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): Deprecate SentryTracingInterceptor, SentryService, SentryGlobalGenericFilter, SentryGlobalGraphQLFilter #14371

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/migration/draft-v9-migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@
## `@sentry/nestjs`

- Deprecated `@WithSentry`. Use `@SentryExceptionCaptured` instead.
- Deprecated `SentryTracingInterceptor`.
If you are using `@sentry/nestjs` you can safely remove any references to the `SentryTracingInterceptor`.
If you are using another package migrate to `@sentry/nestjs` and remove the `SentryTracingInterceptor` afterwards.
- Deprecated `SentryService`.
If you are using `@sentry/nestjs` you can safely remove any references to the `SentryService`.
If you are using another package migrate to `@sentry/nestjs` and remove the `SentryService` afterwards.
- Deprecated `SentryGlobalGenericFilter`.
Use the `SentryGlobalFilter` instead.
The `SentryGlobalFilter` is a drop-in replacement.
- Deprecated `SentryGlobalGraphQLFilter`.
Use the `SentryGlobalFilter` instead.
The `SentryGlobalFilter` is a drop-in replacement.

## `@sentry/types`

Expand Down
25 changes: 25 additions & 0 deletions packages/nestjs/src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ import { isExpectedError } from './helpers';

/**
* Interceptor to add Sentry tracing capabilities to Nest.js applications.
*
* @deprecated `SentryTracingInterceptor` is deprecated.
* If you are using `@sentry/nestjs` you can safely remove any references to the `SentryTracingInterceptor`.
* If you are using another package migrate to `@sentry/nestjs` and remove the `SentryTracingInterceptor` afterwards.
*/
class SentryTracingInterceptor implements NestInterceptor {
// used to exclude this class from being auto-instrumented
Expand Down Expand Up @@ -59,7 +63,9 @@ class SentryTracingInterceptor implements NestInterceptor {
return next.handle();
}
}
// eslint-disable-next-line deprecation/deprecation
Injectable()(SentryTracingInterceptor);
// eslint-disable-next-line deprecation/deprecation
export { SentryTracingInterceptor };

/**
Expand Down Expand Up @@ -108,6 +114,8 @@ export { SentryGlobalFilter };

/**
* Global filter to handle exceptions in NestJS + GraphQL applications and report them to Sentry.
*
* @deprecated `SentryGlobalGraphQLFilter` is deprecated. Use the `SentryGlobalFilter` instead. The `SentryGlobalFilter` is a drop-in replacement.
*/
class SentryGlobalGraphQLFilter {
private static readonly _logger = new Logger('ExceptionsHandler');
Expand All @@ -127,24 +135,33 @@ class SentryGlobalGraphQLFilter {
throw exception;
}
if (exception instanceof Error) {
// eslint-disable-next-line deprecation/deprecation
SentryGlobalGraphQLFilter._logger.error(exception.message, exception.stack);
}
captureException(exception);
throw exception;
}
}
// eslint-disable-next-line deprecation/deprecation
Catch()(SentryGlobalGraphQLFilter);
// eslint-disable-next-line deprecation/deprecation
export { SentryGlobalGraphQLFilter };

/**
* Global filter to handle exceptions and report them to Sentry.
*
* This filter is a generic filter that can handle both HTTP and GraphQL exceptions.
*
* @deprecated `SentryGlobalGenericFilter` is deprecated. Use the `SentryGlobalFilter` instead. The `SentryGlobalFilter` is a drop-in replacement.
*/
export const SentryGlobalGenericFilter = SentryGlobalFilter;

/**
* Service to set up Sentry performance tracing for Nest.js applications.
*
* @deprecated `SentryService` is deprecated.
* If you are using `@sentry/nestjs` you can safely remove any references to the `SentryService`.
* If you are using another package migrate to `@sentry/nestjs` and remove the `SentryService` afterwards.
*/
class SentryService implements OnModuleInit {
public readonly __SENTRY_INTERNAL__: boolean;
Expand All @@ -168,7 +185,9 @@ class SentryService implements OnModuleInit {
}
}
}
// eslint-disable-next-line deprecation/deprecation
Injectable()(SentryService);
// eslint-disable-next-line deprecation/deprecation
export { SentryService };

/**
Expand All @@ -182,25 +201,31 @@ class SentryModule {
return {
module: SentryModule,
providers: [
// eslint-disable-next-line deprecation/deprecation
SentryService,
{
provide: APP_INTERCEPTOR,
// eslint-disable-next-line deprecation/deprecation
useClass: SentryTracingInterceptor,
},
],
// eslint-disable-next-line deprecation/deprecation
exports: [SentryService],
};
}
}
Global()(SentryModule);
Module({
providers: [
// eslint-disable-next-line deprecation/deprecation
SentryService,
{
provide: APP_INTERCEPTOR,
// eslint-disable-next-line deprecation/deprecation
useClass: SentryTracingInterceptor,
},
],
// eslint-disable-next-line deprecation/deprecation
exports: [SentryService],
})(SentryModule);
export { SentryModule };
Expand Down
Loading