diff --git a/dev-packages/node-integration-tests/suites/tracing/nestjs-errors-no-express/scenario.ts b/dev-packages/node-integration-tests/suites/tracing/nestjs-errors-no-express/scenario.ts index e4f15f80fe70..3dcf30f97b20 100644 --- a/dev-packages/node-integration-tests/suites/tracing/nestjs-errors-no-express/scenario.ts +++ b/dev-packages/node-integration-tests/suites/tracing/nestjs-errors-no-express/scenario.ts @@ -48,6 +48,7 @@ class AppModule {} async function run(): Promise { const app = await NestFactory.create(AppModule); const { httpAdapter } = app.get(HttpAdapterHost); + // eslint-disable-next-line deprecation/deprecation Sentry.setupNestErrorHandler(app, new BaseExceptionFilter(httpAdapter)); await app.listen(port); sendPortToRunner(port); diff --git a/dev-packages/node-integration-tests/suites/tracing/nestjs-errors/scenario.ts b/dev-packages/node-integration-tests/suites/tracing/nestjs-errors/scenario.ts index 7cf65cbbbb1c..6f4c9fa6955e 100644 --- a/dev-packages/node-integration-tests/suites/tracing/nestjs-errors/scenario.ts +++ b/dev-packages/node-integration-tests/suites/tracing/nestjs-errors/scenario.ts @@ -46,6 +46,7 @@ class AppModule {} async function run(): Promise { const app = await NestFactory.create(AppModule); const { httpAdapter } = app.get(HttpAdapterHost); + // eslint-disable-next-line deprecation/deprecation Sentry.setupNestErrorHandler(app, new BaseExceptionFilter(httpAdapter)); await app.listen(port); sendPortToRunner(port); diff --git a/dev-packages/node-integration-tests/suites/tracing/nestjs-no-express/scenario.ts b/dev-packages/node-integration-tests/suites/tracing/nestjs-no-express/scenario.ts index e77888ded6a3..62e042a4bf7a 100644 --- a/dev-packages/node-integration-tests/suites/tracing/nestjs-no-express/scenario.ts +++ b/dev-packages/node-integration-tests/suites/tracing/nestjs-no-express/scenario.ts @@ -48,6 +48,7 @@ class AppModule {} async function run(): Promise { const app = await NestFactory.create(AppModule); const { httpAdapter } = app.get(HttpAdapterHost); + // eslint-disable-next-line deprecation/deprecation Sentry.setupNestErrorHandler(app, new BaseExceptionFilter(httpAdapter)); await app.listen(port); sendPortToRunner(port); diff --git a/dev-packages/node-integration-tests/suites/tracing/nestjs/scenario.ts b/dev-packages/node-integration-tests/suites/tracing/nestjs/scenario.ts index 2d4ac4e534cd..449dc82fd070 100644 --- a/dev-packages/node-integration-tests/suites/tracing/nestjs/scenario.ts +++ b/dev-packages/node-integration-tests/suites/tracing/nestjs/scenario.ts @@ -48,6 +48,7 @@ async function run(): Promise { await app.listen(port); const { httpAdapter } = app.get(HttpAdapterHost); + // eslint-disable-next-line deprecation/deprecation Sentry.setupNestErrorHandler(app, new BaseExceptionFilter(httpAdapter)); sendPortToRunner(port); } diff --git a/docs/migration/draft-v9-migration-guide.md b/docs/migration/draft-v9-migration-guide.md index 3a7c8cb2343c..4aee37dddde5 100644 --- a/docs/migration/draft-v9-migration-guide.md +++ b/docs/migration/draft-v9-migration-guide.md @@ -25,3 +25,5 @@ ## Server-side SDKs (`@sentry/node` and all dependents) - Deprecated `processThreadBreadcrumbIntegration` in favor of `childProcessIntegration`. Functionally they are the same. +- Deprecated `nestIntegration`. Use the NestJS SDK (`@sentry/nestjs`) instead. +- Deprecated `setupNestErrorHandler`. Use the NestJS SDK (`@sentry/nestjs`) instead. diff --git a/packages/astro/src/index.server.ts b/packages/astro/src/index.server.ts index 7f0d5cc40ada..92e175b9205e 100644 --- a/packages/astro/src/index.server.ts +++ b/packages/astro/src/index.server.ts @@ -84,6 +84,7 @@ export { mysql2Integration, mysqlIntegration, nativeNodeFetchIntegration, + // eslint-disable-next-line deprecation/deprecation nestIntegration, NodeClient, nodeContextIntegration, @@ -118,6 +119,7 @@ export { setupExpressErrorHandler, setupHapiErrorHandler, setupKoaErrorHandler, + // eslint-disable-next-line deprecation/deprecation setupNestErrorHandler, setUser, spanToBaggageHeader, diff --git a/packages/aws-serverless/src/index.ts b/packages/aws-serverless/src/index.ts index 1156887a691c..e5e38100a257 100644 --- a/packages/aws-serverless/src/index.ts +++ b/packages/aws-serverless/src/index.ts @@ -101,7 +101,9 @@ export { mysql2Integration, redisIntegration, tediousIntegration, + // eslint-disable-next-line deprecation/deprecation nestIntegration, + // eslint-disable-next-line deprecation/deprecation setupNestErrorHandler, postgresIntegration, prismaIntegration, diff --git a/packages/bun/src/index.ts b/packages/bun/src/index.ts index 92d25051ebd7..941cb953a4f9 100644 --- a/packages/bun/src/index.ts +++ b/packages/bun/src/index.ts @@ -124,7 +124,9 @@ export { mysql2Integration, redisIntegration, tediousIntegration, + // eslint-disable-next-line deprecation/deprecation nestIntegration, + // eslint-disable-next-line deprecation/deprecation setupNestErrorHandler, postgresIntegration, prismaIntegration, diff --git a/packages/google-cloud-serverless/src/index.ts b/packages/google-cloud-serverless/src/index.ts index 87349a502f0f..5be557af86c5 100644 --- a/packages/google-cloud-serverless/src/index.ts +++ b/packages/google-cloud-serverless/src/index.ts @@ -101,7 +101,9 @@ export { mysql2Integration, redisIntegration, tediousIntegration, + // eslint-disable-next-line deprecation/deprecation nestIntegration, + // eslint-disable-next-line deprecation/deprecation setupNestErrorHandler, postgresIntegration, prismaIntegration, diff --git a/packages/nestjs/src/index.ts b/packages/nestjs/src/index.ts index 71ef90a51586..c26edc3b4941 100644 --- a/packages/nestjs/src/index.ts +++ b/packages/nestjs/src/index.ts @@ -1,5 +1,15 @@ +import { nestIntegration as nestIntegrationAlias } from '@sentry/node'; + export * from '@sentry/node'; +/** + * Integration capturing tracing data for NestJS. + */ +// eslint-disable-next-line deprecation/deprecation +export const nestIntegration = nestIntegrationAlias; + +// TODO(v9): Export custom `getDefaultIntegrations` from this SDK that automatically registers the `nestIntegration`. + export { init } from './sdk'; export { diff --git a/packages/node/src/index.ts b/packages/node/src/index.ts index 92ef7e6be7f7..a537a2771f45 100644 --- a/packages/node/src/index.ts +++ b/packages/node/src/index.ts @@ -21,6 +21,7 @@ export { mongooseIntegration } from './integrations/tracing/mongoose'; export { mysqlIntegration } from './integrations/tracing/mysql'; export { mysql2Integration } from './integrations/tracing/mysql2'; export { redisIntegration } from './integrations/tracing/redis'; +// eslint-disable-next-line deprecation/deprecation export { nestIntegration, setupNestErrorHandler } from './integrations/tracing/nest/nest'; export { postgresIntegration } from './integrations/tracing/postgres'; export { prismaIntegration } from './integrations/tracing/prisma'; diff --git a/packages/node/src/integrations/tracing/index.ts b/packages/node/src/integrations/tracing/index.ts index 1a1b8835011d..c8f6348aeee0 100644 --- a/packages/node/src/integrations/tracing/index.ts +++ b/packages/node/src/integrations/tracing/index.ts @@ -38,6 +38,7 @@ export function getAutoPerformanceIntegrations(): Integration[] { // See https://github.com/prisma/prisma/issues/23410 // TODO v8: Figure out a better solution for this, maybe only disable in ESM mode? // prismaIntegration(), + // eslint-disable-next-line deprecation/deprecation nestIntegration(), hapiIntegration(), koaIntegration(), @@ -64,6 +65,7 @@ export function getOpenTelemetryInstrumentationToPreload(): (((options?: any) => instrumentKafka, instrumentKoa, instrumentLruMemoizer, + // eslint-disable-next-line deprecation/deprecation instrumentNest, instrumentMongo, instrumentMongoose, diff --git a/packages/node/src/integrations/tracing/nest/nest.ts b/packages/node/src/integrations/tracing/nest/nest.ts index 2520367d1361..1086f4c83394 100644 --- a/packages/node/src/integrations/tracing/nest/nest.ts +++ b/packages/node/src/integrations/tracing/nest/nest.ts @@ -9,8 +9,8 @@ import { getIsolationScope, spanToJSON, } from '@sentry/core'; -import type { IntegrationFn, Span } from '@sentry/types'; -import { logger } from '@sentry/utils'; +import type { Span } from '@sentry/types'; +import { consoleSandbox, logger } from '@sentry/utils'; import { generateInstrumentOnce } from '../../../otel/instrument'; import { SentryNestEventInstrumentation } from './sentry-nest-event-instrumentation'; import { SentryNestInstrumentation } from './sentry-nest-instrumentation'; @@ -39,26 +39,35 @@ export const instrumentNest = Object.assign( { id: INTEGRATION_NAME }, ); -const _nestIntegration = (() => { +/** + * Integration capturing tracing data for NestJS. + * + * @deprecated The `nestIntegration` is deprecated. Instead, use the NestJS SDK directly (`@sentry/nestjs`), or use the `nestIntegration` export from `@sentry/nestjs`. + */ +export const nestIntegration = defineIntegration(() => { return { name: INTEGRATION_NAME, setupOnce() { instrumentNest(); }, }; -}) satisfies IntegrationFn; - -/** - * Nest framework integration - * - * Capture tracing data for nest. - */ -export const nestIntegration = defineIntegration(_nestIntegration); +}); /** * Setup an error handler for Nest. + * + * @deprecated `setupNestErrorHandler` is deprecated. + * Instead use the `@sentry/nestjs` package, which has more functional APIs for capturing errors. + * See the [`@sentry/nestjs` Setup Guide](https://docs.sentry.io/platforms/javascript/guides/nestjs/) for how to set up the Sentry NestJS SDK. */ export function setupNestErrorHandler(app: MinimalNestJsApp, baseFilter: NestJsErrorFilter): void { + consoleSandbox(() => { + // eslint-disable-next-line no-console + console.warn( + '[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/', + ); + }); + // Sadly, NestInstrumentation has no requestHook, so we need to add the attributes here // We register this hook in this method, because if we register it in the integration `setup`, // it would always run even for users that are not even using Nest.js diff --git a/packages/remix/src/index.server.ts b/packages/remix/src/index.server.ts index 9fb2654cc375..71e76b9ed160 100644 --- a/packages/remix/src/index.server.ts +++ b/packages/remix/src/index.server.ts @@ -84,6 +84,7 @@ export { mysql2Integration, mysqlIntegration, nativeNodeFetchIntegration, + // eslint-disable-next-line deprecation/deprecation nestIntegration, NodeClient, nodeContextIntegration, @@ -115,6 +116,7 @@ export { setupExpressErrorHandler, setupHapiErrorHandler, setupKoaErrorHandler, + // eslint-disable-next-line deprecation/deprecation setupNestErrorHandler, setUser, spanToBaggageHeader, diff --git a/packages/solidstart/src/server/index.ts b/packages/solidstart/src/server/index.ts index 780f9fe7fa12..b2faa21768ba 100644 --- a/packages/solidstart/src/server/index.ts +++ b/packages/solidstart/src/server/index.ts @@ -75,6 +75,7 @@ export { mysql2Integration, mysqlIntegration, nativeNodeFetchIntegration, + // eslint-disable-next-line deprecation/deprecation nestIntegration, NodeClient, nodeContextIntegration, @@ -106,6 +107,7 @@ export { setupExpressErrorHandler, setupHapiErrorHandler, setupKoaErrorHandler, + // eslint-disable-next-line deprecation/deprecation setupNestErrorHandler, setUser, spanToBaggageHeader, diff --git a/packages/sveltekit/src/server/index.ts b/packages/sveltekit/src/server/index.ts index 81388a0d1946..c954d4b1bf78 100644 --- a/packages/sveltekit/src/server/index.ts +++ b/packages/sveltekit/src/server/index.ts @@ -77,6 +77,7 @@ export { mysql2Integration, mysqlIntegration, nativeNodeFetchIntegration, + // eslint-disable-next-line deprecation/deprecation nestIntegration, NodeClient, nodeContextIntegration, @@ -108,6 +109,7 @@ export { setupExpressErrorHandler, setupHapiErrorHandler, setupKoaErrorHandler, + // eslint-disable-next-line deprecation/deprecation setupNestErrorHandler, setUser, spanToBaggageHeader,