@sentry/node

  • Version 9.15.0
  • Published
  • 2.11 MB
  • 34 dependencies
  • MIT license

Install

npm i @sentry/node
yarn add @sentry/node
pnpm add @sentry/node

Overview

Sentry Node SDK using OpenTelemetry for performance instrumentation

Index

Variables

variable anrIntegration

const anrIntegration: AnrReturn;

    variable cron

    const cron: {
    instrumentCron: typeof instrumentCron;
    instrumentNodeCron: typeof instrumentNodeCron;
    instrumentNodeSchedule: typeof instrumentNodeSchedule;
    };
    • Methods to instrument cron libraries for Sentry check-ins

    variable defaultStackParser

    const defaultStackParser: StackParser;
    • Node.js stack parser

    variable SentryContextManager

    const SentryContextManager: new (
    ...args: unknown[]
    ) => AsyncLocalStorageContextManager;
    • This is a custom ContextManager for OpenTelemetry, which extends the default AsyncLocalStorageContextManager. It ensures that we create a new hub per context, so that the OTEL Context & the Sentry Scopes are always in sync.

      Note that we currently only support AsyncHooks with this, but since this should work for Node 14+ anyhow that should be good enough.

    Functions

    function amqplibIntegration

    amqplibIntegration: () => any;
    • Adds Sentry tracing instrumentation for the [amqplib](https://www.npmjs.com/package/amqplib) library.

      For more information, see the [amqplibIntegration documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/amqplib/).

      Example 1

      const Sentry = require('@sentry/node');
      Sentry.init({
      integrations: [Sentry.amqplibIntegration()],
      });

    function childProcessIntegration

    childProcessIntegration: (options?: Options | undefined) => any;
    • Capture breadcrumbs and events for child processes and worker threads.

    function connectIntegration

    connectIntegration: () => any;
    • Adds Sentry tracing instrumentation for [Connect](https://github.com/senchalabs/connect/).

      If you also want to capture errors, you need to call setupConnectErrorHandler(app) after you initialize your connect app.

      For more information, see the [connect documentation](https://docs.sentry.io/platforms/javascript/guides/connect/).

      Example 1

      const Sentry = require('@sentry/node');
      Sentry.init({
      integrations: [Sentry.connectIntegration()],
      })

    function contextLinesIntegration

    contextLinesIntegration: (options?: ContextLinesOptions | undefined) => any;
    • Capture the lines before and after the frame's context.

    function createGetModuleFromFilename

    createGetModuleFromFilename: (
    basePath?: string,
    isWindows?: boolean
    ) => (filename: string | undefined) => string | undefined;
    • Creates a function that gets the module name from a filename

    function createSentryWinstonTransport

    createSentryWinstonTransport: <TransportStreamInstance extends object>(
    TransportClass: new (options?: any) => TransportStreamInstance,
    sentryWinstonOptions?: WinstonTransportOptions
    ) => typeof TransportClass;
    • Creates a new Sentry Winston transport that fowards logs to Sentry. Requires _experiments.enableLogs to be enabled.

      Supports Winston 3.x.x.

      Parameter TransportClass

      The Winston transport class to extend.

      Returns

      The extended transport class.

      This method will experience breaking changes. This is not yet part of the stable Sentry SDK API and can be changed or removed without warning.

      Example 1

      const winston = require('winston');
      const Transport = require('winston-transport');
      const transport = Sentry.createSentryWinstonTransport(Transport);
      const logger = winston.createLogger({
      transports: [transport],
      });

      Modifiers

      • @experimental

    function dataloaderIntegration

    dataloaderIntegration: () => any;
    • Adds Sentry tracing instrumentation for the [dataloader](https://www.npmjs.com/package/dataloader) library.

      For more information, see the [dataloaderIntegration documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/dataloader/).

      Example 1

      const Sentry = require('@sentry/node');
      Sentry.init({
      integrations: [Sentry.dataloaderIntegration()],
      });

    function disableAnrDetectionForCallback

    disableAnrDetectionForCallback: {
    <T>(callback: () => T): T;
    <T>(callback: () => Promise<T>): Promise<T>;
    };

      function expressErrorHandler

      expressErrorHandler: (options?: ExpressHandlerOptions) => ExpressErrorMiddleware;
      • An Express-compatible error handler.

      function expressIntegration

      expressIntegration: () => any;
      • Adds Sentry tracing instrumentation for [Express](https://expressjs.com/).

        If you also want to capture errors, you need to call setupExpressErrorHandler(app) after you set up your Express server.

        For more information, see the [express documentation](https://docs.sentry.io/platforms/javascript/guides/express/).

        Example 1

        const Sentry = require('@sentry/node');
        Sentry.init({
        integrations: [Sentry.expressIntegration()],
        })

      function fastifyIntegration

      fastifyIntegration: () => any;
      • Adds Sentry tracing instrumentation for [Fastify](https://fastify.dev/).

        If you also want to capture errors, you need to call setupFastifyErrorHandler(app) after you set up your Fastify server.

        For more information, see the [fastify documentation](https://docs.sentry.io/platforms/javascript/guides/fastify/).

        Example 1

        const Sentry = require('@sentry/node');
        Sentry.init({
        integrations: [Sentry.fastifyIntegration()],
        })

      function fsIntegration

      fsIntegration: (
      options?:
      | {
      recordFilePaths?: boolean | undefined;
      recordErrorMessagesAsSpanAttributes?: boolean | undefined;
      }
      | undefined
      ) => any;
      • This integration will create spans for fs API operations, like reading and writing files.

        **WARNING:** This integration may add significant overhead to your application. Especially in scenarios with a lot of file I/O, like for example when running a framework dev server, including this integration can massively slow down your application.

        Parameter options

        Configuration for this integration.

      function generateInstrumentOnce

      generateInstrumentOnce: {
      <Options, InstrumentationClass extends new (...args: any[]) => Instrumentation>(
      name: string,
      instrumentationClass: InstrumentationClass,
      optionsCallback: (
      options: Options
      ) => ConstructorParameters<InstrumentationClass>[0]
      ): ((options: Options) => InstanceType<InstrumentationClass>) & { id: string };
      <
      Options = unknown,
      InstrumentationInstance extends Instrumentation = Instrumentation
      >(
      name: string,
      creator: (options?: Options) => InstrumentationInstance
      ): ((options?: Options) => InstrumentationInstance) & { id: string };
      };

        function genericPoolIntegration

        genericPoolIntegration: () => any;
        • Adds Sentry tracing instrumentation for the [generic-pool](https://www.npmjs.com/package/generic-pool) library.

          For more information, see the [genericPoolIntegration documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/genericpool/).

          Example 1

          const Sentry = require('@sentry/node');
          Sentry.init({
          integrations: [Sentry.genericPoolIntegration()],
          });

        function getAutoPerformanceIntegrations

        getAutoPerformanceIntegrations: () => Integration[];
        • With OTEL, all performance integrations will be added, as OTEL only initializes them when the patched package is actually required.

        function getDefaultIntegrations

        getDefaultIntegrations: (options: Options) => Integration[];
        • Get the default integrations for the Node SDK.

        function getDefaultIntegrationsWithoutPerformance

        getDefaultIntegrationsWithoutPerformance: () => Integration[];
        • Get default integrations, excluding performance.

        function getSentryRelease

        getSentryRelease: (fallback?: string) => string | undefined;
        • Returns a release dynamically from environment variables.

        function graphqlIntegration

        graphqlIntegration: (options?: GraphqlOptions | undefined) => any;
        • Adds Sentry tracing instrumentation for the [graphql](https://www.npmjs.com/package/graphql) library.

          For more information, see the [graphqlIntegration documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/graphql/).

          Parameter options

          Configuration options for the GraphQL integration.

          Example 1

          ```javascript const Sentry = require('@sentry/node');

          Sentry.init({ integrations: [Sentry.graphqlIntegration()], });

        function hapiIntegration

        hapiIntegration: () => any;
        • Adds Sentry tracing instrumentation for [Hapi](https://hapi.dev/).

          If you also want to capture errors, you need to call setupHapiErrorHandler(server) after you set up your server.

          For more information, see the [hapi documentation](https://docs.sentry.io/platforms/javascript/guides/hapi/).

          Example 1

          const Sentry = require('@sentry/node');
          Sentry.init({
          integrations: [Sentry.hapiIntegration()],
          })

        function httpIntegration

        httpIntegration: (options?: HttpOptions | undefined) => any;
        • The http integration instruments Node's internal http and https modules. It creates breadcrumbs and spans for outgoing HTTP requests which will be attached to the currently active span.

        function init

        init: (options?: NodeOptions | undefined) => NodeClient | undefined;
        • Initialize Sentry for Node.

        function initOpenTelemetry

        initOpenTelemetry: (
        client: NodeClient,
        options?: AdditionalOpenTelemetryOptions
        ) => void;
        • Initialize OpenTelemetry for Node.

        function initWithoutDefaultIntegrations

        initWithoutDefaultIntegrations: (
        options?: NodeOptions | undefined
        ) => NodeClient;
        • Initialize Sentry for Node, without any integrations added by default.

        function kafkaIntegration

        kafkaIntegration: () => any;
        • Adds Sentry tracing instrumentation for the [kafkajs](https://www.npmjs.com/package/kafkajs) library.

          For more information, see the [kafkaIntegration documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/kafka/).

          Example 1

          ```javascript const Sentry = require('@sentry/node');

          Sentry.init({ integrations: [Sentry.kafkaIntegration()], });

        function knexIntegration

        knexIntegration: () => any;
        • Knex integration

          Capture tracing data for [Knex](https://knexjs.org/).

          Example 1

          import * as Sentry from '@sentry/node';
          Sentry.init({
          integrations: [Sentry.knexIntegration()],
          });

        function koaIntegration

        koaIntegration: () => any;
        • Adds Sentry tracing instrumentation for [Koa](https://koajs.com/).

          If you also want to capture errors, you need to call setupKoaErrorHandler(app) after you set up your Koa server.

          For more information, see the [koa documentation](https://docs.sentry.io/platforms/javascript/guides/koa/).

          Example 1

          const Sentry = require('@sentry/node');
          Sentry.init({
          integrations: [Sentry.koaIntegration()],
          })

        function localVariablesIntegration

        localVariablesIntegration: (
        options?: LocalVariablesIntegrationOptions
        ) => Integration;

          function lruMemoizerIntegration

          lruMemoizerIntegration: () => any;
          • Adds Sentry tracing instrumentation for the [lru-memoizer](https://www.npmjs.com/package/lru-memoizer) library.

            For more information, see the [lruMemoizerIntegration documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/lrumemoizer/).

            Example 1

            ```javascript const Sentry = require('@sentry/node');

            Sentry.init({ integrations: [Sentry.lruMemoizerIntegration()], });

          function makeNodeTransport

          makeNodeTransport: (options: NodeTransportOptions) => Transport;
          • Creates a Transport that uses native the native 'http' and 'https' modules to send events to Sentry.

          function modulesIntegration

          modulesIntegration: () => any;
          • Add node modules / packages to the event.

            Only works in CommonJS (CJS) environments.

          function mongoIntegration

          mongoIntegration: () => any;
          • Adds Sentry tracing instrumentation for the [mongodb](https://www.npmjs.com/package/mongodb) library.

            For more information, see the [mongoIntegration documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/mongo/).

            Example 1

            const Sentry = require('@sentry/node');
            Sentry.init({
            integrations: [Sentry.mongoIntegration()],
            });

          function mongooseIntegration

          mongooseIntegration: () => any;
          • Adds Sentry tracing instrumentation for the [mongoose](https://www.npmjs.com/package/mongoose) library.

            For more information, see the [mongooseIntegration documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/mongoose/).

            Example 1

            const Sentry = require('@sentry/node');
            Sentry.init({
            integrations: [Sentry.mongooseIntegration()],
            });

          function mysql2Integration

          mysql2Integration: () => any;
          • Adds Sentry tracing instrumentation for the [mysql2](https://www.npmjs.com/package/mysql2) library.

            For more information, see the [mysql2Integration documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/mysql2/).

            Example 1

            const Sentry = require('@sentry/node');
            Sentry.init({
            integrations: [Sentry.mysqlIntegration()],
            });

          function mysqlIntegration

          mysqlIntegration: () => any;
          • Adds Sentry tracing instrumentation for the [mysql](https://www.npmjs.com/package/mysql) library.

            For more information, see the [mysqlIntegration documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/mysql/).

            Example 1

            const Sentry = require('@sentry/node');
            Sentry.init({
            integrations: [Sentry.mysqlIntegration()],
            });

          function nativeNodeFetchIntegration

          nativeNodeFetchIntegration: (options?: NodeFetchOptions | undefined) => any;

            function nodeContextIntegration

            nodeContextIntegration: (options?: ContextOptions | undefined) => any;
            • Capture context about the environment and the device that the client is running on, to events.

            function onUncaughtExceptionIntegration

            onUncaughtExceptionIntegration: (
            options?: Partial<OnUncaughtExceptionOptions> | undefined
            ) => any;
            • Add a global exception handler.

            function onUnhandledRejectionIntegration

            onUnhandledRejectionIntegration: (
            options?: Partial<OnUnhandledRejectionOptions> | undefined
            ) => any;
            • Add a global promise rejection handler.

            function postgresIntegration

            postgresIntegration: () => any;
            • Adds Sentry tracing instrumentation for the [pg](https://www.npmjs.com/package/pg) library.

              For more information, see the [postgresIntegration documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/postgres/).

              Example 1

              const Sentry = require('@sentry/node');
              Sentry.init({
              integrations: [Sentry.postgresIntegration()],
              });

            function preloadOpenTelemetry

            preloadOpenTelemetry: (options?: NodePreloadOptions) => void;
            • Preload OpenTelemetry for Node. This can be used to preload instrumentation early, but set up Sentry later. By preloading the OTEL instrumentation wrapping still happens early enough that everything works.

            function prismaIntegration

            prismaIntegration: (
            args_0?:
            | {
            prismaInstrumentation?:
            | Instrumentation<
            import('@opentelemetry/instrumentation').InstrumentationConfig
            >
            | undefined;
            }
            | undefined
            ) => any;
            • Adds Sentry tracing instrumentation for the [prisma](https://www.npmjs.com/package/prisma) library. For more information, see the [prismaIntegration documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/prisma/).

              NOTE: By default, this integration works with Prisma version 6. To get performance instrumentation for other Prisma versions, 1. Install the @prisma/instrumentation package with the desired version. 1. Pass a new PrismaInstrumentation() instance as exported from @prisma/instrumentation to the prismaInstrumentation option of this integration:

              ```js import { PrismaInstrumentation } from '@prisma/instrumentation'

              Sentry.init({ integrations: [ prismaIntegration({ // Override the default instrumentation that Sentry uses prismaInstrumentation: new PrismaInstrumentation() }) ] }) ```

              The passed instrumentation instance will override the default instrumentation instance the integration would use, while the prismaIntegration will still ensure data compatibility for the various Prisma versions. 1. Depending on your Prisma version (prior to version 6), add previewFeatures = ["tracing"] to the client generator block of your Prisma schema:

              ``` generator client { provider = "prisma-client-js" previewFeatures = ["tracing"] } ```

            function redisIntegration

            redisIntegration: (options?: RedisOptions | undefined) => any;
            • Adds Sentry tracing instrumentation for the [redis](https://www.npmjs.com/package/redis) and [ioredis](https://www.npmjs.com/package/ioredis) libraries.

              For more information, see the [redisIntegration documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/redis/).

              Example 1

              const Sentry = require('@sentry/node');
              Sentry.init({
              integrations: [Sentry.redisIntegration()],
              });

            function setupConnectErrorHandler

            setupConnectErrorHandler: (app: ConnectApp) => void;
            • Add a Connect middleware to capture errors to Sentry.

              Parameter app

              The Connect app to attach the error handler to

              Example 1

              const Sentry = require('@sentry/node');
              const connect = require("connect");
              const app = connect();
              Sentry.setupConnectErrorHandler(app);
              // Add you connect routes here
              app.listen(3000);

            function setupExpressErrorHandler

            setupExpressErrorHandler: (
            app: {
            use: (middleware: ExpressMiddleware | ExpressErrorMiddleware) => unknown;
            },
            options?: ExpressHandlerOptions
            ) => void;
            • Add an Express error handler to capture errors to Sentry.

              The error handler must be before any other middleware and after all controllers.

              Parameter app

              The Express instances

              Parameter options

              Configuration options for the handler

              Example 1

              const Sentry = require('@sentry/node');
              const express = require("express");
              const app = express();
              // Add your routes, etc.
              // Add this after all routes,
              // but before any and other error-handling middlewares are defined
              Sentry.setupExpressErrorHandler(app);
              app.listen(3000);

            function setupFastifyErrorHandler

            setupFastifyErrorHandler: (
            fastify: Fastify,
            options?: Partial<FastifyHandlerOptions>
            ) => void;
            • Add an Fastify error handler to capture errors to Sentry.

              Parameter fastify

              The Fastify instance to which to add the error handler

              Parameter options

              Configuration options for the handler

              Example 1

              const Sentry = require('@sentry/node');
              const Fastify = require("fastify");
              const app = Fastify();
              Sentry.setupFastifyErrorHandler(app);
              // Add your routes, etc.
              app.listen({ port: 3000 });

            function setupHapiErrorHandler

            setupHapiErrorHandler: (server: Server) => Promise<void>;
            • Add a Hapi plugin to capture errors to Sentry.

              Parameter server

              The Hapi server to attach the error handler to

              Example 1

              const Sentry = require('@sentry/node');
              const Hapi = require('@hapi/hapi');
              const init = async () => {
              const server = Hapi.server();
              // all your routes here
              await Sentry.setupHapiErrorHandler(server);
              await server.start();
              };

            function setupKoaErrorHandler

            setupKoaErrorHandler: (app: {
            use: (arg0: (ctx: any, next: any) => Promise<void>) => void;
            }) => void;
            • Add an Koa error handler to capture errors to Sentry.

              The error handler must be before any other middleware and after all controllers.

              Parameter app

              The Express instances

              Parameter options

              Configuration options for the handler

              Example 1

              const Sentry = require('@sentry/node');
              const Koa = require("koa");
              const app = new Koa();
              Sentry.setupKoaErrorHandler(app);
              // Add your routes, etc.
              app.listen(3000);

            function spotlightIntegration

            spotlightIntegration: (
            options?: Partial<SpotlightConnectionOptions> | undefined
            ) => any;
            • Use this integration to send errors and transactions to Spotlight.

              Learn more about spotlight at https://spotlightjs.com

              Important: This integration only works with Node 18 or newer.

            function tediousIntegration

            tediousIntegration: () => any;
            • Adds Sentry tracing instrumentation for the [tedious](https://www.npmjs.com/package/tedious) library.

              For more information, see the [tediousIntegration documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/tedious/).

              Example 1

              const Sentry = require('@sentry/node');
              Sentry.init({
              integrations: [Sentry.tediousIntegration()],
              });

            function validateOpenTelemetrySetup

            validateOpenTelemetrySetup: () => void;
            • Validate that your OpenTelemetry setup is correct.

            function vercelAIIntegration

            vercelAIIntegration: () => any;
            • Adds Sentry tracing instrumentation for the [ai](https://www.npmjs.com/package/ai) library.

              For more information, see the [ai documentation](https://sdk.vercel.ai/docs/ai-sdk-core/telemetry).

              Example 1

              const Sentry = require('@sentry/node');
              Sentry.init({
              integrations: [Sentry.vercelAIIntegration()],
              });

              By default this integration adds tracing support to all ai function calls. If you need to disable collecting spans for a specific call, you can do so by setting experimental_telemetry.isEnabled to false in the first argument of the function call.

              const result = await generateText({
              model: openai('gpt-4-turbo'),
              experimental_telemetry: { isEnabled: false },
              });

              If you want to collect inputs and outputs for a specific call, you must specifically opt-in to each function call by setting experimental_telemetry.recordInputs and experimental_telemetry.recordOutputs to true.

              ```javascript const result = await generateText({ model: openai('gpt-4-turbo'), experimental_telemetry: { isEnabled: true, recordInputs: true, recordOutputs: true }, });

            Classes

            class NodeClient

            class NodeClient extends ServerRuntimeClient<NodeClientOptions> {}
            • A client for using Sentry with Node & OpenTelemetry.

            constructor

            constructor(options: NodeClientOptions);

              property traceProvider

              traceProvider: any;

                property tracer

                readonly tracer: Tracer;
                • Get the OTEL tracer.

                method close

                close: (timeout?: number | undefined) => PromiseLike<boolean>;

                  method flush

                  flush: (timeout?: number) => Promise<boolean>;

                    method startClientReportTracking

                    startClientReportTracking: () => void;
                    • Will start tracking client reports for this client.

                      NOTICE: This method will create an interval that is periodically called and attach a process.on('beforeExit') hook. To clean up these resources, call .close() when you no longer intend to use the client. Not doing so will result in a memory leak.

                    Interfaces

                    interface NodeOptions

                    interface NodeOptions extends Options<NodeTransportOptions>, BaseNodeOptions {}
                    • Configuration options for the Sentry Node SDK

                      See Also

                      • @sentry/core Options for more information.

                    Namespaces

                    namespace logger

                    module 'build/types/logs/exports.d.ts' {}
                    • Capture a log with the trace level. Requires _experiments.enableLogs to be enabled.

                      You can either pass a message and attributes or a message template, params and attributes.

                      Example 1

                      Sentry.logger.trace('Starting database connection', {
                      database: 'users',
                      connectionId: 'conn_123'
                      });

                      Example 2

                      With template strings

                      Sentry.logger.trace('Database connection %s established for %s',
                      ['successful', 'users'],
                      { connectionId: 'conn_123' }
                      );

                    function debug

                    debug: (...args: CaptureLogArgs) => void;
                    • Capture a log with the debug level. Requires _experiments.enableLogs to be enabled.

                      You can either pass a message and attributes or a message template, params and attributes.

                      Example 1

                      Sentry.logger.debug('Cache miss for user profile', {
                      userId: 'user_123',
                      cacheKey: 'profile:user_123'
                      });

                      Example 2

                      With template strings

                      Sentry.logger.debug('Cache %s for %s: %s',
                      ['miss', 'user profile', 'key not found'],
                      { userId: 'user_123' }
                      );

                    function error

                    error: (...args: CaptureLogArgs) => void;
                    • Capture a log with the error level. Requires _experiments.enableLogs to be enabled.

                      You can either pass a message and attributes or a message template, params and attributes.

                      Example 1

                      Sentry.logger.error('Failed to process payment', {
                      orderId: 'order_123',
                      errorCode: 'PAYMENT_FAILED',
                      amount: 99.99
                      });

                      Example 2

                      With template strings

                      Sentry.logger.error('Payment processing failed for order %s: %s',
                      ['order_123', 'insufficient funds'],
                      { amount: 99.99 }
                      );

                    function fatal

                    fatal: (...args: CaptureLogArgs) => void;
                    • Capture a log with the fatal level. Requires _experiments.enableLogs to be enabled.

                      You can either pass a message and attributes or a message template, params and attributes.

                      Example 1

                      Sentry.logger.fatal('Database connection pool exhausted', {
                      database: 'users',
                      activeConnections: 100,
                      maxConnections: 100
                      });

                      Example 2

                      With template strings

                      Sentry.logger.fatal('Database %s: %s connections active',
                      ['connection pool exhausted', '100/100'],
                      { database: 'users' }
                      );

                    function info

                    info: (...args: CaptureLogArgs) => void;
                    • Capture a log with the info level. Requires _experiments.enableLogs to be enabled.

                      You can either pass a message and attributes or a message template, params and attributes.

                      Example 1

                      Sentry.logger.info('User profile updated', {
                      userId: 'user_123',
                      updatedFields: ['email', 'preferences']
                      });

                      Example 2

                      With template strings

                      Sentry.logger.info('User %s updated their %s',
                      ['John Doe', 'profile settings'],
                      { userId: 'user_123' }
                      );

                    function trace

                    trace: (...args: CaptureLogArgs) => void;
                    • Capture a log with the trace level. Requires _experiments.enableLogs to be enabled.

                      You can either pass a message and attributes or a message template, params and attributes.

                      Example 1

                      Sentry.logger.trace('Starting database connection', {
                      database: 'users',
                      connectionId: 'conn_123'
                      });

                      Example 2

                      With template strings

                      Sentry.logger.trace('Database connection %s established for %s',
                      ['successful', 'users'],
                      { connectionId: 'conn_123' }
                      );

                    function warn

                    warn: (...args: CaptureLogArgs) => void;
                    • Capture a log with the warn level. Requires _experiments.enableLogs to be enabled.

                      You can either pass a message and attributes or a message template, params and attributes.

                      Example 1

                      Sentry.logger.warn('Rate limit approaching', {
                      endpoint: '/api/users',
                      currentRate: '95/100',
                      resetTime: '2024-03-20T10:00:00Z'
                      });

                      Example 2

                      With template strings

                      Sentry.logger.warn('Rate limit %s for %s: %s',
                      ['approaching', '/api/users', '95/100 requests'],
                      { resetTime: '2024-03-20T10:00:00Z' }
                      );

                    Package Files (47)

                    Dependencies (34)

                    Dev Dependencies (1)

                    Peer Dependencies (0)

                    No peer dependencies.

                    Badge

                    To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                    You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@sentry/node.

                    • Markdown
                      [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@sentry/node)
                    • HTML
                      <a href="https://www.jsdocs.io/package/@sentry/node"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>