Skip to content

Commit a921440

Browse files
authored
feat(nestjs): Remove SentryTracingInterceptor, SentryGlobalGraphQLFilter, SentryGlobalGenericFilter (#14761)
**Note**: we keep `SentryTracingInterceptor` to maintain parameterized transaction names but remove the public export. Closes: #14295
1 parent 456690f commit a921440

File tree

5 files changed

+14
-58
lines changed

5 files changed

+14
-58
lines changed

dev-packages/e2e-tests/test-applications/nestjs-basic-with-graphql/src/main.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import './instrument';
33

44
// Import other modules
55
import { HttpAdapterHost, NestFactory } from '@nestjs/core';
6-
import { SentryGlobalGenericFilter } from '@sentry/nestjs/setup';
6+
import { SentryGlobalFilter } from '@sentry/nestjs/setup';
77
import { AppModule } from './app.module';
88

99
const PORT = 3030;
@@ -12,7 +12,7 @@ async function bootstrap() {
1212
const app = await NestFactory.create(AppModule);
1313

1414
const { httpAdapter } = app.get(HttpAdapterHost);
15-
app.useGlobalFilters(new SentryGlobalGenericFilter(httpAdapter as any));
15+
app.useGlobalFilters(new SentryGlobalFilter(httpAdapter as any));
1616

1717
await app.listen(PORT);
1818
}

dev-packages/e2e-tests/test-applications/nestjs-graphql/src/app.module.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ApolloDriver } from '@nestjs/apollo';
22
import { Logger, Module } from '@nestjs/common';
33
import { APP_FILTER } from '@nestjs/core';
44
import { GraphQLModule } from '@nestjs/graphql';
5-
import { SentryGlobalGraphQLFilter, SentryModule } from '@sentry/nestjs/setup';
5+
import { SentryGlobalFilter, SentryModule } from '@sentry/nestjs/setup';
66
import { AppResolver } from './app.resolver';
77

88
@Module({
@@ -19,7 +19,7 @@ import { AppResolver } from './app.resolver';
1919
AppResolver,
2020
{
2121
provide: APP_FILTER,
22-
useClass: SentryGlobalGraphQLFilter,
22+
useClass: SentryGlobalFilter,
2323
},
2424
{
2525
provide: Logger,

docs/migration/v8-to-v9.md

+9
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,15 @@ It will be removed in a future major version.
111111
- Removed `SentryService`.
112112
If you are using `@sentry/nestjs` you can safely remove any references to the `SentryService`.
113113
If you are using another package migrate to `@sentry/nestjs` and remove the `SentryService` afterwards.
114+
- Removed `SentryTracingInterceptor`.
115+
If you are using `@sentry/nestjs` you can safely remove any references to the `SentryTracingInterceptor`.
116+
If you are using another package migrate to `@sentry/nestjs` and remove the `SentryTracingInterceptor` afterwards.
117+
- Removed `SentryGlobalGenericFilter`.
118+
Use the `SentryGlobalFilter` instead.
119+
The `SentryGlobalFilter` is a drop-in replacement.
120+
- Removed `SentryGlobalGraphQLFilter`.
121+
Use the `SentryGlobalFilter` instead.
122+
The `SentryGlobalFilter` is a drop-in replacement.
114123

115124
## 5. Build Changes
116125

packages/nestjs/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"build:types:watch": "tsc -p tsconfig.types.json --watch",
7272
"build:tarball": "npm pack",
7373
"circularDepCheck": "madge --circular src/index.ts && madge --circular src/setup.ts",
74-
"clean": "rimraf build coverage sentry-node-*.tgz",
74+
"clean": "rimraf build coverage sentry-nestjs-*.tgz ./*.d.ts ./*.d.ts.map",
7575
"fix": "eslint . --format stylish --fix",
7676
"lint": "eslint . --format stylish",
7777
"test": "vitest run",

packages/nestjs/src/setup.ts

-53
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ interface ExpressRequest {
3535

3636
/**
3737
* Interceptor to add Sentry tracing capabilities to Nest.js applications.
38-
*
39-
* @deprecated `SentryTracingInterceptor` is deprecated.
40-
* If you are using `@sentry/nestjs` you can safely remove any references to the `SentryTracingInterceptor`.
41-
* If you are using another package migrate to `@sentry/nestjs` and remove the `SentryTracingInterceptor` afterwards.
4238
*/
4339
class SentryTracingInterceptor implements NestInterceptor {
4440
// used to exclude this class from being auto-instrumented
@@ -73,10 +69,7 @@ class SentryTracingInterceptor implements NestInterceptor {
7369
return next.handle();
7470
}
7571
}
76-
// eslint-disable-next-line deprecation/deprecation
7772
Injectable()(SentryTracingInterceptor);
78-
// eslint-disable-next-line deprecation/deprecation
79-
export { SentryTracingInterceptor };
8073

8174
/**
8275
* Global filter to handle exceptions and report them to Sentry.
@@ -122,50 +115,6 @@ class SentryGlobalFilter extends BaseExceptionFilter {
122115
Catch()(SentryGlobalFilter);
123116
export { SentryGlobalFilter };
124117

125-
/**
126-
* Global filter to handle exceptions in NestJS + GraphQL applications and report them to Sentry.
127-
*
128-
* @deprecated `SentryGlobalGraphQLFilter` is deprecated. Use the `SentryGlobalFilter` instead. The `SentryGlobalFilter` is a drop-in replacement.
129-
*/
130-
class SentryGlobalGraphQLFilter {
131-
private static readonly _logger = new Logger('ExceptionsHandler');
132-
public readonly __SENTRY_INTERNAL__: boolean;
133-
134-
public constructor() {
135-
this.__SENTRY_INTERNAL__ = true;
136-
}
137-
138-
/**
139-
* Catches exceptions and reports them to Sentry unless they are HttpExceptions.
140-
*/
141-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
142-
public catch(exception: unknown, host: ArgumentsHost): void {
143-
// neither report nor log HttpExceptions
144-
if (exception instanceof HttpException) {
145-
throw exception;
146-
}
147-
if (exception instanceof Error) {
148-
// eslint-disable-next-line deprecation/deprecation
149-
SentryGlobalGraphQLFilter._logger.error(exception.message, exception.stack);
150-
}
151-
captureException(exception);
152-
throw exception;
153-
}
154-
}
155-
// eslint-disable-next-line deprecation/deprecation
156-
Catch()(SentryGlobalGraphQLFilter);
157-
// eslint-disable-next-line deprecation/deprecation
158-
export { SentryGlobalGraphQLFilter };
159-
160-
/**
161-
* Global filter to handle exceptions and report them to Sentry.
162-
*
163-
* This filter is a generic filter that can handle both HTTP and GraphQL exceptions.
164-
*
165-
* @deprecated `SentryGlobalGenericFilter` is deprecated. Use the `SentryGlobalFilter` instead. The `SentryGlobalFilter` is a drop-in replacement.
166-
*/
167-
export const SentryGlobalGenericFilter = SentryGlobalFilter;
168-
169118
/**
170119
* Set up a root module that can be injected in nest applications.
171120
*/
@@ -179,7 +128,6 @@ class SentryModule {
179128
providers: [
180129
{
181130
provide: APP_INTERCEPTOR,
182-
// eslint-disable-next-line deprecation/deprecation
183131
useClass: SentryTracingInterceptor,
184132
},
185133
],
@@ -191,7 +139,6 @@ Module({
191139
providers: [
192140
{
193141
provide: APP_INTERCEPTOR,
194-
// eslint-disable-next-line deprecation/deprecation
195142
useClass: SentryTracingInterceptor,
196143
},
197144
],

0 commit comments

Comments
 (0)