Skip to content

Commit dc69ad3

Browse files
authored
Merge branch 'develop' into fix/fetch-not-release
2 parents 8181799 + a921440 commit dc69ad3

File tree

5 files changed

+21
-129
lines changed

5 files changed

+21
-129
lines changed

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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,21 @@ It will be removed in a future major version.
106106

107107
- The `getNumberOfUrlSegments` method has been removed. There are no replacements.
108108

109+
### `@sentry/nestjs`
110+
111+
- Removed `SentryService`.
112+
If you are using `@sentry/nestjs` you can safely remove any references to the `SentryService`.
113+
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.
123+
109124
## 5. Build Changes
110125

111126
Previously the CJS versions of the SDK code (wrongfully) contained compatibility statements for default exports in ESM:

packages/nestjs/package.json

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,10 @@ import type {
55
ExecutionContext,
66
HttpServer,
77
NestInterceptor,
8-
OnModuleInit,
98
} from '@nestjs/common';
109
import { Catch, Global, HttpException, Injectable, Logger, Module } from '@nestjs/common';
1110
import { APP_INTERCEPTOR, BaseExceptionFilter } from '@nestjs/core';
12-
import type { Span } from '@sentry/core';
13-
import {
14-
SEMANTIC_ATTRIBUTE_SENTRY_OP,
15-
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
16-
captureException,
17-
getClient,
18-
getDefaultIsolationScope,
19-
getIsolationScope,
20-
logger,
21-
spanToJSON,
22-
} from '@sentry/core';
11+
import { captureException, getDefaultIsolationScope, getIsolationScope, logger } from '@sentry/core';
2312
import type { Observable } from 'rxjs';
2413
import { isExpectedError } from './helpers';
2514

@@ -46,10 +35,6 @@ interface ExpressRequest {
4635

4736
/**
4837
* Interceptor to add Sentry tracing capabilities to Nest.js applications.
49-
*
50-
* @deprecated `SentryTracingInterceptor` is deprecated.
51-
* If you are using `@sentry/nestjs` you can safely remove any references to the `SentryTracingInterceptor`.
52-
* If you are using another package migrate to `@sentry/nestjs` and remove the `SentryTracingInterceptor` afterwards.
5338
*/
5439
class SentryTracingInterceptor implements NestInterceptor {
5540
// used to exclude this class from being auto-instrumented
@@ -84,10 +69,7 @@ class SentryTracingInterceptor implements NestInterceptor {
8469
return next.handle();
8570
}
8671
}
87-
// eslint-disable-next-line deprecation/deprecation
8872
Injectable()(SentryTracingInterceptor);
89-
// eslint-disable-next-line deprecation/deprecation
90-
export { SentryTracingInterceptor };
9173

9274
/**
9375
* Global filter to handle exceptions and report them to Sentry.
@@ -133,84 +115,6 @@ class SentryGlobalFilter extends BaseExceptionFilter {
133115
Catch()(SentryGlobalFilter);
134116
export { SentryGlobalFilter };
135117

136-
/**
137-
* Global filter to handle exceptions in NestJS + GraphQL applications and report them to Sentry.
138-
*
139-
* @deprecated `SentryGlobalGraphQLFilter` is deprecated. Use the `SentryGlobalFilter` instead. The `SentryGlobalFilter` is a drop-in replacement.
140-
*/
141-
class SentryGlobalGraphQLFilter {
142-
private static readonly _logger = new Logger('ExceptionsHandler');
143-
public readonly __SENTRY_INTERNAL__: boolean;
144-
145-
public constructor() {
146-
this.__SENTRY_INTERNAL__ = true;
147-
}
148-
149-
/**
150-
* Catches exceptions and reports them to Sentry unless they are HttpExceptions.
151-
*/
152-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
153-
public catch(exception: unknown, host: ArgumentsHost): void {
154-
// neither report nor log HttpExceptions
155-
if (exception instanceof HttpException) {
156-
throw exception;
157-
}
158-
if (exception instanceof Error) {
159-
// eslint-disable-next-line deprecation/deprecation
160-
SentryGlobalGraphQLFilter._logger.error(exception.message, exception.stack);
161-
}
162-
captureException(exception);
163-
throw exception;
164-
}
165-
}
166-
// eslint-disable-next-line deprecation/deprecation
167-
Catch()(SentryGlobalGraphQLFilter);
168-
// eslint-disable-next-line deprecation/deprecation
169-
export { SentryGlobalGraphQLFilter };
170-
171-
/**
172-
* Global filter to handle exceptions and report them to Sentry.
173-
*
174-
* This filter is a generic filter that can handle both HTTP and GraphQL exceptions.
175-
*
176-
* @deprecated `SentryGlobalGenericFilter` is deprecated. Use the `SentryGlobalFilter` instead. The `SentryGlobalFilter` is a drop-in replacement.
177-
*/
178-
export const SentryGlobalGenericFilter = SentryGlobalFilter;
179-
180-
/**
181-
* Service to set up Sentry performance tracing for Nest.js applications.
182-
*
183-
* @deprecated `SentryService` is deprecated.
184-
* If you are using `@sentry/nestjs` you can safely remove any references to the `SentryService`.
185-
* If you are using another package migrate to `@sentry/nestjs` and remove the `SentryService` afterwards.
186-
*/
187-
class SentryService implements OnModuleInit {
188-
public readonly __SENTRY_INTERNAL__: boolean;
189-
190-
public constructor() {
191-
this.__SENTRY_INTERNAL__ = true;
192-
}
193-
194-
/**
195-
* Initializes the Sentry service and registers span attributes.
196-
*/
197-
public onModuleInit(): void {
198-
// Sadly, NestInstrumentation has no requestHook, so we need to add the attributes here
199-
// We register this hook in this method, because if we register it in the integration `setup`,
200-
// it would always run even for users that are not even using Nest.js
201-
const client = getClient();
202-
if (client) {
203-
client.on('spanStart', span => {
204-
addNestSpanAttributes(span);
205-
});
206-
}
207-
}
208-
}
209-
// eslint-disable-next-line deprecation/deprecation
210-
Injectable()(SentryService);
211-
// eslint-disable-next-line deprecation/deprecation
212-
export { SentryService };
213-
214118
/**
215119
* Set up a root module that can be injected in nest applications.
216120
*/
@@ -222,48 +126,21 @@ class SentryModule {
222126
return {
223127
module: SentryModule,
224128
providers: [
225-
// eslint-disable-next-line deprecation/deprecation
226-
SentryService,
227129
{
228130
provide: APP_INTERCEPTOR,
229-
// eslint-disable-next-line deprecation/deprecation
230131
useClass: SentryTracingInterceptor,
231132
},
232133
],
233-
// eslint-disable-next-line deprecation/deprecation
234-
exports: [SentryService],
235134
};
236135
}
237136
}
238137
Global()(SentryModule);
239138
Module({
240139
providers: [
241-
// eslint-disable-next-line deprecation/deprecation
242-
SentryService,
243140
{
244141
provide: APP_INTERCEPTOR,
245-
// eslint-disable-next-line deprecation/deprecation
246142
useClass: SentryTracingInterceptor,
247143
},
248144
],
249-
// eslint-disable-next-line deprecation/deprecation
250-
exports: [SentryService],
251145
})(SentryModule);
252146
export { SentryModule };
253-
254-
function addNestSpanAttributes(span: Span): void {
255-
const attributes = spanToJSON(span).data;
256-
257-
// this is one of: app_creation, request_context, handler
258-
const type = attributes['nestjs.type'];
259-
260-
// If this is already set, or we have no nest.js span, no need to process again...
261-
if (attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP] || !type) {
262-
return;
263-
}
264-
265-
span.setAttributes({
266-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.otel.nestjs',
267-
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: `${type}.nestjs`,
268-
});
269-
}

0 commit comments

Comments
 (0)