@sentry/node

  • Version 6.12.0
  • Published
  • 591 kB
  • 9 dependencies
  • BSD-3-Clause license

Install

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

Overview

Official Sentry SDK for Node.js

Index

Variables

variable defaultIntegrations

const defaultIntegrations: any[];

    variable Integrations

    const Integrations: {
    Console: typeof NodeIntegrations.Console;
    Http: typeof NodeIntegrations.Http;
    OnUncaughtException: typeof NodeIntegrations.OnUncaughtException;
    OnUnhandledRejection: typeof NodeIntegrations.OnUnhandledRejection;
    LinkedErrors: typeof NodeIntegrations.LinkedErrors;
    Modules: typeof NodeIntegrations.Modules;
    FunctionToString: any;
    InboundFilters: any;
    };

      variable SDK_NAME

      const SDK_NAME: string;

        Functions

        function close

        close: (timeout?: number) => Promise<boolean>;
        • Call close() on the current client, if there is one. See Client.close.

          Parameter timeout

          Maximum time in ms the client should wait to flush its event queue before shutting down. Omitting this parameter will cause the client to wait until all events are sent before disabling itself.

          Returns

          A promise which resolves to true if the queue successfully drains before the timeout, or false if it doesn't (or if there's no client defined).

        function deepReadDirSync

        deepReadDirSync: (targetDir: string) => string[];
        • Recursively read the contents of a directory.

          Parameter targetDir

          Absolute or relative path of the directory to scan. All returned paths will be relative to this directory.

          Returns

          Array holding all relative paths

        function flush

        flush: (timeout?: number) => Promise<boolean>;
        • Call flush() on the current client, if there is one. See Client.flush.

          Parameter timeout

          Maximum time in ms the client should wait to flush its event queue. Omitting this parameter will cause the client to wait until all events are sent before resolving the promise.

          Returns

          A promise which resolves to true if the queue successfully drains before the timeout, or false if it doesn't (or if there's no client defined).

        function getSentryRelease

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

        function init

        init: (options?: NodeOptions) => void;
        • The Sentry Node SDK Client.

          To use this SDK, call the init function as early as possible in the main entry module. To set context information or send manual events, use the provided methods.

          Example 1

          const { init } = require('@sentry/node');
          init({
          dsn: '__DSN__',
          // ...
          });

          Example 2

          const { configureScope } = require('@sentry/node');
          configureScope((scope: Scope) => {
          scope.setExtra({ battery: 0.7 });
          scope.setTag({ user_mode: 'admin' });
          scope.setUser({ id: '4711' });
          });

          Example 3

          const { addBreadcrumb } = require('@sentry/node');
          addBreadcrumb({
          message: 'My Breadcrumb',
          // ...
          });

          Example 4

          const Sentry = require('@sentry/node');
          Sentry.captureMessage('Hello, world!');
          Sentry.captureException(new Error('Good bye'));
          Sentry.captureEvent({
          message: 'Manual',
          stacktrace: [
          // ...
          ],
          });

          See Also

          • NodeOptions for documentation on configuration options.

        function lastEventId

        lastEventId: () => string | undefined;
        • This is the getter for lastEventId.

          Returns

          The last event id of a captured event.

        Classes

        class NodeBackend

        class NodeBackend extends BaseBackend<NodeOptions> {}
        • The Sentry Node SDK Backend.

        method eventFromException

        eventFromException: (exception: any, hint?: any) => PromiseLike<Event>;

        method eventFromMessage

        eventFromMessage: (
        message: string,
        level?: any,
        hint?: any
        ) => PromiseLike<Event>;

        class NodeClient

        class NodeClient extends BaseClient<NodeBackend, NodeOptions> {}
        • The Sentry Node SDK Client.

          See Also

          • NodeOptions for documentation on configuration options.

          • SentryClient for usage documentation.

        constructor

        constructor(options: NodeOptions);
        • Creates a new Node SDK instance.

          Parameter options

          Configuration options for this SDK.

        method captureEvent

        captureEvent: (event: any, hint?: any, scope?: any) => string | undefined;

        method captureException

        captureException: (
        exception: any,
        hint?: any,
        scope?: any
        ) => string | undefined;

        method close

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

        method initSessionFlusher

        initSessionFlusher: () => void;
        • Method that initialises an instance of SessionFlusher on Client

        Interfaces

        interface NodeOptions

        interface NodeOptions extends Options {}
        • Configuration options for the Sentry Node SDK.

          See Also

          • NodeClient for more information.

        property caCerts

        caCerts?: string;
        • HTTPS proxy certificates path

        property frameContextLines

        frameContextLines?: number;
        • Sets the number of context lines for each frame when loading a file.

        property httpProxy

        httpProxy?: string;
        • Set a HTTP proxy that should be used for outbound requests.

        property httpsProxy

        httpsProxy?: string;
        • Set a HTTPS proxy that should be used for outbound requests.

        property serverName

        serverName?: string;
        • Sets an optional server name (device name)

        property shutdownTimeout

        shutdownTimeout?: number;
        • Maximum time in milliseconds to wait to drain the request queue, before the process is allowed to exit.

        method onFatalError

        onFatalError: (error: Error) => void;
        • Callback that is executed when a fatal global error occurs.

        Namespaces

        namespace Handlers

        module 'dist/handlers.d.ts' {}
        • Express-compatible tracing handler.

          See Also

          • Exposed as Handlers.tracingHandler

        function errorHandler

        errorHandler: (options?: {
        shouldHandleError?(error: MiddlewareError): boolean;
        }) => (
        error: MiddlewareError,
        req: any,
        res: any,
        next: (error: MiddlewareError) => void
        ) => void;
        • Express compatible error handler.

          See Also

          • Exposed as Handlers.errorHandler

        function extractRequestData

        extractRequestData: (req: { [key: string]: any }, keys?: string[]) => any;
        • Normalizes data from the request object, accounting for framework differences.

          Parameter req

          The request object from which to extract data

          Parameter keys

          An optional array of keys to include in the normalized data. Defaults to DEFAULT_REQUEST_KEYS if not provided.

          Returns

          An object containing normalized request data

        function parseRequest

        parseRequest: (
        event: any,
        req: ExpressRequest,
        options?: ParseRequestOptions
        ) => any;
        • Enriches passed event with request data.

          Parameter event

          Will be mutated and enriched with req data

          Parameter req

          Request object

          Parameter options

          object containing flags to enable functionality

        function requestHandler

        requestHandler: (
        options?: RequestHandlerOptions
        ) => (req: any, res: any, next: (error?: any) => void) => void;
        • Express compatible request handler.

          See Also

          • Exposed as Handlers.requestHandler

        function tracingHandler

        tracingHandler: () => (req: any, res: any, next: (error?: any) => void) => void;
        • Express-compatible tracing handler.

          See Also

          • Exposed as Handlers.tracingHandler

        interface ExpressRequest

        interface ExpressRequest {}

          property baseUrl

          baseUrl?: string;

            property connection

            connection?: {
            remoteAddress?: string;
            };

              property ip

              ip?: string;

                property method

                method?: string;

                  property originalUrl

                  originalUrl?: string;

                    property query

                    query?: {
                    [key: string]: unknown;
                    };

                      property route

                      route?: {
                      path: string;
                      stack: [
                      {
                      name: string;
                      }
                      ];
                      };

                        property url

                        url?: string;

                          property user

                          user?: {
                          [key: string]: any;
                          };

                            interface ParseRequestOptions

                            interface ParseRequestOptions {}
                            • Options deciding what parts of the request to use when enhancing an event

                            property ip

                            ip?: boolean;

                              property request

                              request?: boolean | string[];

                                property serverName

                                serverName?: boolean;

                                  property transaction

                                  transaction?: boolean | TransactionNamingScheme;

                                    property user

                                    user?: boolean | string[];

                                      property version

                                      version?: boolean;

                                        type RequestHandlerOptions

                                        type RequestHandlerOptions = ParseRequestOptions & {
                                        flushTimeout?: number;
                                        };

                                          namespace Transports

                                          module 'dist/transports/index.d.ts' {}

                                            class BaseTransport

                                            abstract class BaseTransport implements Transport {}
                                            • Base Transport class implementation

                                            constructor

                                            constructor(options: any);
                                            • Create instance and set this.dsn

                                            property client

                                            client?: any;
                                            • The Agent used for corresponding transport

                                            property module

                                            module?: HTTPModule;
                                            • The Agent used for corresponding transport

                                            property options

                                            options: any;

                                              property urlParser

                                              urlParser: UrlParser;
                                              • Default function used to parse URLs

                                              method close

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

                                              method sendEvent

                                              sendEvent: (_: any) => PromiseLike<Response>;

                                              class HTTPSTransport

                                              class HTTPSTransport extends BaseTransport {}
                                              • Node https module transport

                                              constructor

                                              constructor(options: any);
                                              • Create a new instance and set this.agent

                                              property options

                                              options: any;

                                                method sendEvent

                                                sendEvent: (event: any) => Promise<Response>;

                                                method sendSession

                                                sendSession: (session: Session | SessionAggregates) => PromiseLike<Response>;

                                                class HTTPTransport

                                                class HTTPTransport extends BaseTransport {}
                                                • Node http module transport

                                                constructor

                                                constructor(options: any);
                                                • Create a new instance and set this.agent

                                                property options

                                                options: any;

                                                  method sendEvent

                                                  sendEvent: (event: any) => Promise<Response>;

                                                  method sendSession

                                                  sendSession: (session: Session | SessionAggregates) => PromiseLike<Response>;

                                                  Package Files (12)

                                                  Dependencies (9)

                                                  Dev Dependencies (12)

                                                  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>