• Version 6.12.0
  • Published
  • 314 kB
  • 5 dependencies
  • BSD-3-Clause license


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


Base implementation for all Sentry JavaScript SDKs



variable SDK_VERSION

const SDK_VERSION: string;


    function eventToSentryRequest

    eventToSentryRequest: (event: any, api: API) => any;
    • Creates a SentryRequest from an event.

    function initAndBind

    initAndBind: <F extends any, O extends any>(
    clientClass: ClientClass<F, O>,
    options: O
    ) => void;
    • Internal function to create a new SDK client instance. The client is installed and then bound to the current scope.

      Parameter clientClass

      The client class to instantiate.

      Parameter options

      Options to pass to the client.

    function sessionToSentryRequest

    sessionToSentryRequest: (session: Session | SessionAggregates, api: API) => any;
    • Creates a SentryRequest from a Session.


    class API

    class API {}
    • Helper class to provide urls, headers and metadata that can be used to form different types of requests to Sentry endpoints. Supports both envelopes and regular event requests.


    constructor(dsn: any, metadata?: any, tunnel?: string);
    • Create a new instance of API

    property dsn

    dsn: any;
    • The DSN as passed to Sentry.init()

    property metadata

    metadata: any;
    • Metadata about the SDK (name, version, etc) for inclusion in envelope headers

    method forceEnvelope

    forceEnvelope: () => boolean;
    • Does this transport force envelopes?

    method getBaseApiEndpoint

    getBaseApiEndpoint: () => string;
    • Returns the prefix to construct Sentry ingestion API endpoints.

    method getDsn

    getDsn: () => any;
    • Returns the Dsn object.

    method getEnvelopeEndpointWithUrlEncodedAuth

    getEnvelopeEndpointWithUrlEncodedAuth: () => string;
    • Returns the envelope endpoint URL with auth in the query string.

      Sending auth as part of the query string and not as custom HTTP headers avoids CORS preflight requests.

    method getReportDialogEndpoint

    getReportDialogEndpoint: (dialogOptions?: {
    [key: string]: any;
    user?: { name?: string; email?: string };
    }) => string;
    • Returns the url to the report dialog endpoint.

    method getRequestHeaders

    getRequestHeaders: (
    clientName: string,
    clientVersion: string
    ) => { [key: string]: string };
    • Returns an object that can be used in request headers. This is needed for node and the old /store endpoint in sentry

    method getStoreEndpoint

    getStoreEndpoint: () => string;
    • Returns the store endpoint URL.

    method getStoreEndpointPath

    getStoreEndpointPath: () => string;
    • Returns only the path component for the store endpoint.

    method getStoreEndpointWithUrlEncodedAuth

    getStoreEndpointWithUrlEncodedAuth: () => string;
    • Returns the store endpoint URL with auth in the query string.

      Sending auth as part of the query string and not as custom HTTP headers avoids CORS preflight requests.

    class BaseBackend

    abstract class BaseBackend<O extends Options> implements Backend {}
    • This is the base implemention of a Backend.


    constructor(options: any);
    • Creates a new backend instance.

    method eventFromException

    eventFromException: (_exception: any, _hint?: any) => PromiseLike<Event>;

    method eventFromMessage

    eventFromMessage: (
    _message: string,
    _level?: any,
    _hint?: any
    ) => PromiseLike<Event>;

    method getTransport

    getTransport: () => any;

    method sendEvent

    sendEvent: (event: any) => void;

    method sendSession

    sendSession: (session: any) => void;

    class BaseClient

    abstract class BaseClient<B extends Backend, O extends Options>
    implements Client<O> {}
    • Base implementation for all JavaScript SDK clients.

      Call the constructor with the corresponding backend constructor and options specific to the client subclass. To access these options later, use Client.getOptions. Also, the Backend instance is available via Client.getBackend.

      If a Dsn is specified in the options, it will be parsed and stored. Use Client.getDsn to retrieve the Dsn at any moment. In case the Dsn is invalid, the constructor will throw a SentryException. Note that without a valid Dsn, the SDK will not send any events to Sentry.

      Before sending an event via the backend, it is passed through BaseClient._prepareEvent to add SDK information and scope data (breadcrumbs and context). To add more custom information, override this method and extend the resulting prepared event.

      To issue automatically created events (e.g. via instrumentation), use Client.captureEvent. It will prepare the event and pass it through the callback lifecycle. To issue auto-breadcrumbs, use Client.addBreadcrumb.

      Example 1

      class NodeClient extends BaseClient<NodeBackend, NodeOptions> { public constructor(options: NodeOptions) { super(NodeBackend, options); }

      // ... }


    protected constructor(backendClass: BackendClass<B, O>, options: any);
    • Initializes this client instance.

      Parameter backendClass

      A constructor function to create the backend.

      Parameter options

      Options for the client.

    method captureEvent

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

    method captureException

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

    method captureMessage

    captureMessage: (
    message: string,
    level?: any,
    hint?: any,
    scope?: any
    ) => string | undefined;

    method captureSession

    captureSession: (session: any) => void;

    method close

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

    method flush

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

    method getDsn

    getDsn: () => Dsn | undefined;

    method getIntegration

    getIntegration: <T extends any>(integration: any) => T | null;

    method getOptions

    getOptions: () => O;

    method setupIntegrations

    setupIntegrations: () => void;
    • Sets up the integrations

    class NoopTransport

    class NoopTransport implements Transport {}
    • Noop transport

    method close

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

    method sendEvent

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

    Type Aliases

    type BackendClass

    type BackendClass<B extends Backend, O extends Options> = new (options: O) => B;
    • A class object that can instantiate Backend objects.

    type ClientClass

    type ClientClass<F extends Client, O extends Options> = new (options: O) => F;
    • A class object that can instantiate Client objects.


    namespace Integrations

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

      class FunctionToString

      class FunctionToString implements Integration {}
      • Patch toString calls to return proper name for wrapped functions

      property id

      static id: string;

      property name

      name: string;

      method setupOnce

      setupOnce: () => void;

      class InboundFilters

      class InboundFilters implements Integration {}
      • Inbound filters configurable by the user


      constructor(_options?: Partial<InboundFiltersOptions>);

        property id

        static id: string;

        property name

        name: string;

        method setupOnce

        setupOnce: () => void;

        Package Files (11)

        Dependencies (5)

        Dev Dependencies (6)

        Peer Dependencies (0)

        No peer dependencies.


        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/core.

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