Skip to content

Commit 5f7549a

Browse files
authored
feat(node): Deprecate nestIntegration and setupNestErrorHandler in favor of using @sentry/nestjs (#14374)
1 parent e35dc22 commit 5f7549a

File tree

16 files changed

+53
-11
lines changed

16 files changed

+53
-11
lines changed

dev-packages/node-integration-tests/suites/tracing/nestjs-errors-no-express/scenario.ts

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class AppModule {}
4848
async function run(): Promise<void> {
4949
const app = await NestFactory.create(AppModule);
5050
const { httpAdapter } = app.get(HttpAdapterHost);
51+
// eslint-disable-next-line deprecation/deprecation
5152
Sentry.setupNestErrorHandler(app, new BaseExceptionFilter(httpAdapter));
5253
await app.listen(port);
5354
sendPortToRunner(port);

dev-packages/node-integration-tests/suites/tracing/nestjs-errors/scenario.ts

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class AppModule {}
4646
async function run(): Promise<void> {
4747
const app = await NestFactory.create(AppModule);
4848
const { httpAdapter } = app.get(HttpAdapterHost);
49+
// eslint-disable-next-line deprecation/deprecation
4950
Sentry.setupNestErrorHandler(app, new BaseExceptionFilter(httpAdapter));
5051
await app.listen(port);
5152
sendPortToRunner(port);

dev-packages/node-integration-tests/suites/tracing/nestjs-no-express/scenario.ts

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class AppModule {}
4848
async function run(): Promise<void> {
4949
const app = await NestFactory.create(AppModule);
5050
const { httpAdapter } = app.get(HttpAdapterHost);
51+
// eslint-disable-next-line deprecation/deprecation
5152
Sentry.setupNestErrorHandler(app, new BaseExceptionFilter(httpAdapter));
5253
await app.listen(port);
5354
sendPortToRunner(port);

dev-packages/node-integration-tests/suites/tracing/nestjs/scenario.ts

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ async function run(): Promise<void> {
4848
await app.listen(port);
4949

5050
const { httpAdapter } = app.get(HttpAdapterHost);
51+
// eslint-disable-next-line deprecation/deprecation
5152
Sentry.setupNestErrorHandler(app, new BaseExceptionFilter(httpAdapter));
5253
sendPortToRunner(port);
5354
}

docs/migration/draft-v9-migration-guide.md

+2
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,5 @@
3737
## Server-side SDKs (`@sentry/node` and all dependents)
3838

3939
- Deprecated `processThreadBreadcrumbIntegration` in favor of `childProcessIntegration`. Functionally they are the same.
40+
- Deprecated `nestIntegration`. Use the NestJS SDK (`@sentry/nestjs`) instead.
41+
- Deprecated `setupNestErrorHandler`. Use the NestJS SDK (`@sentry/nestjs`) instead.

packages/astro/src/index.server.ts

+2
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export {
8484
mysql2Integration,
8585
mysqlIntegration,
8686
nativeNodeFetchIntegration,
87+
// eslint-disable-next-line deprecation/deprecation
8788
nestIntegration,
8889
NodeClient,
8990
nodeContextIntegration,
@@ -118,6 +119,7 @@ export {
118119
setupExpressErrorHandler,
119120
setupHapiErrorHandler,
120121
setupKoaErrorHandler,
122+
// eslint-disable-next-line deprecation/deprecation
121123
setupNestErrorHandler,
122124
setUser,
123125
spanToBaggageHeader,

packages/aws-serverless/src/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ export {
101101
mysql2Integration,
102102
redisIntegration,
103103
tediousIntegration,
104+
// eslint-disable-next-line deprecation/deprecation
104105
nestIntegration,
106+
// eslint-disable-next-line deprecation/deprecation
105107
setupNestErrorHandler,
106108
postgresIntegration,
107109
prismaIntegration,

packages/bun/src/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ export {
124124
mysql2Integration,
125125
redisIntegration,
126126
tediousIntegration,
127+
// eslint-disable-next-line deprecation/deprecation
127128
nestIntegration,
129+
// eslint-disable-next-line deprecation/deprecation
128130
setupNestErrorHandler,
129131
postgresIntegration,
130132
prismaIntegration,

packages/google-cloud-serverless/src/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ export {
101101
mysql2Integration,
102102
redisIntegration,
103103
tediousIntegration,
104+
// eslint-disable-next-line deprecation/deprecation
104105
nestIntegration,
106+
// eslint-disable-next-line deprecation/deprecation
105107
setupNestErrorHandler,
106108
postgresIntegration,
107109
prismaIntegration,

packages/nestjs/src/index.ts

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1+
import { nestIntegration as nestIntegrationAlias } from '@sentry/node';
2+
13
export * from '@sentry/node';
24

5+
/**
6+
* Integration capturing tracing data for NestJS.
7+
*/
8+
// eslint-disable-next-line deprecation/deprecation
9+
export const nestIntegration = nestIntegrationAlias;
10+
11+
// TODO(v9): Export custom `getDefaultIntegrations` from this SDK that automatically registers the `nestIntegration`.
12+
313
export { init } from './sdk';
414

515
export {

packages/node/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export { mongooseIntegration } from './integrations/tracing/mongoose';
2121
export { mysqlIntegration } from './integrations/tracing/mysql';
2222
export { mysql2Integration } from './integrations/tracing/mysql2';
2323
export { redisIntegration } from './integrations/tracing/redis';
24+
// eslint-disable-next-line deprecation/deprecation
2425
export { nestIntegration, setupNestErrorHandler } from './integrations/tracing/nest/nest';
2526
export { postgresIntegration } from './integrations/tracing/postgres';
2627
export { prismaIntegration } from './integrations/tracing/prisma';

packages/node/src/integrations/tracing/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export function getAutoPerformanceIntegrations(): Integration[] {
3838
// See https://github.com/prisma/prisma/issues/23410
3939
// TODO v8: Figure out a better solution for this, maybe only disable in ESM mode?
4040
// prismaIntegration(),
41+
// eslint-disable-next-line deprecation/deprecation
4142
nestIntegration(),
4243
hapiIntegration(),
4344
koaIntegration(),
@@ -64,6 +65,7 @@ export function getOpenTelemetryInstrumentationToPreload(): (((options?: any) =>
6465
instrumentKafka,
6566
instrumentKoa,
6667
instrumentLruMemoizer,
68+
// eslint-disable-next-line deprecation/deprecation
6769
instrumentNest,
6870
instrumentMongo,
6971
instrumentMongoose,

packages/node/src/integrations/tracing/nest/nest.ts

+20-11
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import {
99
getIsolationScope,
1010
spanToJSON,
1111
} from '@sentry/core';
12-
import type { IntegrationFn, Span } from '@sentry/types';
13-
import { logger } from '@sentry/utils';
12+
import type { Span } from '@sentry/types';
13+
import { consoleSandbox, logger } from '@sentry/utils';
1414
import { generateInstrumentOnce } from '../../../otel/instrument';
1515
import { SentryNestEventInstrumentation } from './sentry-nest-event-instrumentation';
1616
import { SentryNestInstrumentation } from './sentry-nest-instrumentation';
@@ -39,26 +39,35 @@ export const instrumentNest = Object.assign(
3939
{ id: INTEGRATION_NAME },
4040
);
4141

42-
const _nestIntegration = (() => {
42+
/**
43+
* Integration capturing tracing data for NestJS.
44+
*
45+
* @deprecated The `nestIntegration` is deprecated. Instead, use the NestJS SDK directly (`@sentry/nestjs`), or use the `nestIntegration` export from `@sentry/nestjs`.
46+
*/
47+
export const nestIntegration = defineIntegration(() => {
4348
return {
4449
name: INTEGRATION_NAME,
4550
setupOnce() {
4651
instrumentNest();
4752
},
4853
};
49-
}) satisfies IntegrationFn;
50-
51-
/**
52-
* Nest framework integration
53-
*
54-
* Capture tracing data for nest.
55-
*/
56-
export const nestIntegration = defineIntegration(_nestIntegration);
54+
});
5755

5856
/**
5957
* Setup an error handler for Nest.
58+
*
59+
* @deprecated `setupNestErrorHandler` is deprecated.
60+
* Instead use the `@sentry/nestjs` package, which has more functional APIs for capturing errors.
61+
* See the [`@sentry/nestjs` Setup Guide](https://docs.sentry.io/platforms/javascript/guides/nestjs/) for how to set up the Sentry NestJS SDK.
6062
*/
6163
export function setupNestErrorHandler(app: MinimalNestJsApp, baseFilter: NestJsErrorFilter): void {
64+
consoleSandbox(() => {
65+
// eslint-disable-next-line no-console
66+
console.warn(
67+
'[Sentry] Warning: You used the `setupNestErrorHandler()` method to set up Sentry error monitoring. This function is deprecated and will be removed in the next major version. Instead, it is recommended to use the `@sentry/nestjs` package. To set up the NestJS SDK see: https://docs.sentry.io/platforms/javascript/guides/nestjs/',
68+
);
69+
});
70+
6271
// Sadly, NestInstrumentation has no requestHook, so we need to add the attributes here
6372
// We register this hook in this method, because if we register it in the integration `setup`,
6473
// it would always run even for users that are not even using Nest.js

packages/remix/src/index.server.ts

+2
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export {
8484
mysql2Integration,
8585
mysqlIntegration,
8686
nativeNodeFetchIntegration,
87+
// eslint-disable-next-line deprecation/deprecation
8788
nestIntegration,
8889
NodeClient,
8990
nodeContextIntegration,
@@ -115,6 +116,7 @@ export {
115116
setupExpressErrorHandler,
116117
setupHapiErrorHandler,
117118
setupKoaErrorHandler,
119+
// eslint-disable-next-line deprecation/deprecation
118120
setupNestErrorHandler,
119121
setUser,
120122
spanToBaggageHeader,

packages/solidstart/src/server/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export {
7575
mysql2Integration,
7676
mysqlIntegration,
7777
nativeNodeFetchIntegration,
78+
// eslint-disable-next-line deprecation/deprecation
7879
nestIntegration,
7980
NodeClient,
8081
nodeContextIntegration,
@@ -106,6 +107,7 @@ export {
106107
setupExpressErrorHandler,
107108
setupHapiErrorHandler,
108109
setupKoaErrorHandler,
110+
// eslint-disable-next-line deprecation/deprecation
109111
setupNestErrorHandler,
110112
setUser,
111113
spanToBaggageHeader,

packages/sveltekit/src/server/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export {
7777
mysql2Integration,
7878
mysqlIntegration,
7979
nativeNodeFetchIntegration,
80+
// eslint-disable-next-line deprecation/deprecation
8081
nestIntegration,
8182
NodeClient,
8283
nodeContextIntegration,
@@ -108,6 +109,7 @@ export {
108109
setupExpressErrorHandler,
109110
setupHapiErrorHandler,
110111
setupKoaErrorHandler,
112+
// eslint-disable-next-line deprecation/deprecation
111113
setupNestErrorHandler,
112114
setUser,
113115
spanToBaggageHeader,

0 commit comments

Comments
 (0)