@sentry/core

  • Version 7.82.0
  • Published
  • 1.31 MB
  • 2 dependencies
  • MIT license

Install

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

Overview

Base implementation for all Sentry JavaScript SDKs

Index

Variables

Functions

Classes

Interfaces

Enums

Type Aliases

Namespaces

Variables

variable DEFAULT_ENVIRONMENT

const DEFAULT_ENVIRONMENT: string;

    variable extractTraceparentData

    const extractTraceparentData: any;
    • The extractTraceparentData function and TRACEPARENT_REGEXP constant used to be declared in this file. It was later moved into @sentry/utils as part of a move to remove @sentry/tracing dependencies from @sentry/node (extractTraceparentData is the only tracing function used by @sentry/node).

      These exports are kept here for backwards compatability's sake.

      See https://github.com/getsentry/sentry-javascript/issues/4642 for more details.

      Deprecated

      Import this function from @sentry/utils instead

    variable SDK_VERSION

    const SDK_VERSION: string;

      variable startActiveSpan

      const startActiveSpan: <T>(
      context: TransactionContext,
      callback: (span: Span) => T
      ) => T;

      variable TRACING_DEFAULTS

      const TRACING_DEFAULTS: {
      idleTimeout: number;
      finalTimeout: number;
      heartbeatInterval: number;
      };

        Functions

        function addBreadcrumb

        addBreadcrumb: (breadcrumb: Breadcrumb) => ReturnType<Hub['addBreadcrumb']>;
        • Records a new breadcrumb which will be attached to future events.

          Breadcrumbs will be added to subsequent events to provide more context on user's actions prior to an error or crash.

          Parameter breadcrumb

          The breadcrumb to record.

        function addGlobalEventProcessor

        addGlobalEventProcessor: (callback: EventProcessor) => void;
        • Add a EventProcessor to be kept globally.

          Parameter callback

          EventProcessor to add

        function addIntegration

        addIntegration: (integration: Integration) => void;
        • Add an integration to the current hub's client.

        function addTracingExtensions

        addTracingExtensions: () => void;
        • Adds tracing extensions to the global hub.

        function captureCheckIn

        captureCheckIn: (
        checkIn: CheckIn,
        upsertMonitorConfig?: MonitorConfig
        ) => string;
        • Create a cron monitor check in and send it to Sentry.

          Parameter checkIn

          An object that describes a check in.

          Parameter upsertMonitorConfig

          An optional object that describes a monitor config. Use this if you want to create a monitor automatically when sending a check in.

        function captureEvent

        captureEvent: (
        event: Event,
        hint?: EventHint
        ) => ReturnType<Hub['captureEvent']>;
        • Captures a manually created event and sends it to Sentry.

          Parameter event

          The event to send to Sentry.

          Returns

          The generated eventId.

        function captureException

        captureException: (
        exception: any,
        hint?: ExclusiveEventHintOrCaptureContext
        ) => ReturnType<Hub['captureException']>;
        • Captures an exception event and sends it to Sentry. This accepts an event hint as optional second parameter. Alternatively, you can also pass a CaptureContext directly as second parameter.

        function captureMessage

        captureMessage: (
        message: string,
        captureContext?: CaptureContext | Severity | SeverityLevel
        ) => ReturnType<Hub['captureMessage']>;
        • Captures a message event and sends it to Sentry.

          Parameter message

          The message to send to Sentry.

          Parameter Severity

          Define the level of the message.

          Returns

          The generated eventId.

        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 closeSession

        closeSession: (session: Session, status?: Exclude<SessionStatus, 'ok'>) => void;
        • Closes a session by setting its status and updating the session object with it. Internally calls updateSession to update the passed session object.

          Note that this function mutates the passed session (@see updateSession for explanation).

          Parameter session

          the Session object to be closed

          Parameter status

          the SessionStatus with which the session was closed. If you don't pass a status, this function will keep the previously set status, unless it was 'ok' in which case it is changed to 'exited'.

        function configureScope

        configureScope: (
        callback: (scope: Scope) => void
        ) => ReturnType<Hub['configureScope']>;
        • Callback to set context information onto the scope.

          Parameter callback

          Callback function that receives Scope.

        function continueTrace

        continueTrace: {
        ({
        sentryTrace,
        baggage,
        }: {
        sentryTrace: Parameters<typeof tracingContextFromHeaders>[0];
        baggage: Parameters<typeof tracingContextFromHeaders>[1];
        }): TransactionContext;
        <V>(
        { sentryTrace, baggage }: { sentryTrace: unknown; baggage: unknown },
        callback: (transactionContext: TransactionContext) => V
        ): V;
        };

          function createCheckInEnvelope

          createCheckInEnvelope: (
          checkIn: SerializedCheckIn,
          dynamicSamplingContext?: DynamicSamplingContext,
          metadata?: SdkMetadata,
          tunnel?: string,
          dsn?: DsnComponents
          ) => CheckInEnvelope;
          • Create envelope from check in item.

          function createEventEnvelope

          createEventEnvelope: (
          event: Event,
          dsn?: DsnComponents,
          metadata?: SdkMetadata,
          tunnel?: string
          ) => EventEnvelope;
          • Create an Envelope from an event.

          function createTransport

          createTransport: (
          options: InternalBaseTransportOptions,
          makeRequest: TransportRequestExecutor,
          buffer?: PromiseBuffer<any>
          ) => Transport;
          • Creates an instance of a Sentry Transport

            Parameter options

            Parameter makeRequest

          function ensureHubOnCarrier

          ensureHubOnCarrier: (carrier: Carrier, parent?: Hub) => void;
          • Private API with no semver guarantees!

            If the carrier does not contain a hub, a new hub is created with the global hub client and scope.

          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 getActiveSpan

          getActiveSpan: () => Span | undefined;
          • Returns the currently active span.

          function getActiveTransaction

          getActiveTransaction: <T extends Transaction>(maybeHub?: Hub) => T | undefined;
          • Grabs active transaction off scope, if any

          function getClient

          getClient: <C extends Client>() => C | undefined;
          • Get the currently active client.

          function getCurrentHub

          getCurrentHub: () => Hub;
          • Returns the default hub instance.

            If a hub is already registered in the global carrier but this module contains a more recent version, it replaces the registered version. Otherwise, the currently registered hub will be returned.

          function getDynamicSamplingContextFromClient

          getDynamicSamplingContextFromClient: (
          trace_id: string,
          client: Client,
          scope?: Scope
          ) => DynamicSamplingContext;
          • Creates a dynamic sampling context from a client.

            Dispatchs the createDsc lifecycle hook as a side effect.

          function getEnvelopeEndpointWithUrlEncodedAuth

          getEnvelopeEndpointWithUrlEncodedAuth: (
          dsn: DsnComponents,
          tunnelOrOptions?: string | ClientOptions
          ) => 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.

          function getHubFromCarrier

          getHubFromCarrier: (carrier: Carrier) => Hub;
          • This will create a new Hub and add to the passed object on __SENTRY__.hub.

            Parameter carrier

            object

          function getIntegrationsToSetup

          getIntegrationsToSetup: (options: Options) => Integration[];
          • Gets integrations to install

          function getMainCarrier

          getMainCarrier: () => Carrier;
          • Returns the global shim registry.

            FIXME: This function is problematic, because despite always returning a valid Carrier, it has an optional __SENTRY__ property, which then in turn requires us to always perform an unnecessary check at the call-site. We always access the carrier through this function, so we can guarantee that __SENTRY__ is there.

          function getReportDialogEndpoint

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

          function hasTracingEnabled

          hasTracingEnabled: (
          maybeOptions?:
          | Pick<Options, 'tracesSampleRate' | 'tracesSampler' | 'enableTracing'>
          | undefined
          ) => boolean;
          • Determines if tracing is currently enabled.

            Tracing is enabled when at least one of tracesSampleRate and tracesSampler is defined in the SDK config.

          function initAndBind

          initAndBind: <F extends Client, O extends ClientOptions>(
          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 isSentryRequestUrl

          isSentryRequestUrl: (url: string, hub: Hub) => boolean;
          • Checks whether given url points to Sentry server

            Parameter url

            url to verify

          function lastEventId

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

            Returns

            The last event id of a captured event.

          function makeMain

          makeMain: (hub: Hub) => Hub;
          • Replaces the current main hub with the passed one on the global object

            Returns

            The old replaced hub

          function makeMultiplexedTransport

          makeMultiplexedTransport: <TO extends BaseTransportOptions>(
          createTransport: (options: TO) => Transport,
          matcher: Matcher
          ) => (options: TO) => Transport;
          • Creates a transport that can send events to different DSNs depending on the envelope contents.

          function makeOfflineTransport

          makeOfflineTransport: <TO>(
          createTransport: (options: TO) => Transport
          ) => (options: TO & OfflineTransportOptions) => Transport;
          • Wraps a transport and stores and retries events when they fail to send.

            Parameter createTransport

            The transport to wrap.

          function makeSession

          makeSession: (context?: Omit<SessionContext, 'started' | 'status'>) => Session;
          • Creates a new Session object by setting certain default parameters. If optional

            Parameter context

            is passed, the passed properties are applied to the session object.

            Parameter context

            (optional) additional properties to be applied to the returned session object

            Returns

            a new Session object

          function prepareEvent

          prepareEvent: (
          options: ClientOptions,
          event: Event,
          hint: EventHint,
          scope?: Scope,
          client?: Client
          ) => PromiseLike<Event | null>;
          • Adds common information to events.

            The information includes release and environment from options, breadcrumbs and context (extra, tags and user) from the scope.

            Information that is already present in the event is never overwritten. For nested objects, such as the context, keys are merged.

            Note: This also triggers callbacks for addGlobalEventProcessor, but not beforeSend.

            Parameter event

            The original event.

            Parameter hint

            May contain additional information about the original exception.

            Parameter scope

            A scope containing event metadata.

            Returns

            A new event with more information.

          function runWithAsyncContext

          runWithAsyncContext: <T>(
          callback: () => T,
          options?: RunWithAsyncContextOptions
          ) => T;
          • Runs the supplied callback in its own async context. Async Context strategies are defined per SDK.

            Parameter callback

            The callback to run in its own async context

            Parameter options

            Options to pass to the async context strategy

            Returns

            The result of the callback

          function setAsyncContextStrategy

          setAsyncContextStrategy: (strategy: AsyncContextStrategy | undefined) => void;
          • Private API with no semver guarantees!

            Sets the global async context strategy

          function setContext

          setContext: (
          name: string,
          context: { [key: string]: any }
          ) => ReturnType<Hub['setContext']>;
          • Sets context data with the given name.

            Parameter name

            of the context

            Parameter context

            Any kind of data. This data will be normalized.

          function setExtra

          setExtra: (key: string, extra: Extra) => ReturnType<Hub['setExtra']>;
          • Set key:value that will be sent as extra data with the event.

            Parameter key

            String of extra

            Parameter extra

            Any kind of data. This data will be normalized.

          function setExtras

          setExtras: (extras: Extras) => ReturnType<Hub['setExtras']>;
          • Set an object that will be merged sent as extra data with the event.

            Parameter extras

            Extras object to merge into current context.

          function setHubOnCarrier

          setHubOnCarrier: (carrier: Carrier, hub: Hub) => boolean;
          • This will set passed Hub on the passed object's __SENTRY__.hub attribute

            Parameter carrier

            object

            Parameter hub

            Hub

            Returns

            A boolean indicating success or failure

          function setMeasurement

          setMeasurement: (name: string, value: number, unit: MeasurementUnit) => void;
          • Adds a measurement to the current active transaction.

          function setTag

          setTag: (key: string, value: Primitive) => ReturnType<Hub['setTag']>;
          • Set key:value that will be sent as tags data with the event.

            Can also be used to unset a tag, by passing undefined.

            Parameter key

            String key of tag

            Parameter value

            Value of tag

          function setTags

          setTags: (tags: { [key: string]: Primitive }) => ReturnType<Hub['setTags']>;
          • Set an object that will be merged sent as tags data with the event.

            Parameter tags

            Tags context object to merge into current context.

          function setUser

          setUser: (user: User | null) => ReturnType<Hub['setUser']>;
          • Updates user context information for future events.

            Parameter user

            User context object to be set in the current context. Pass null to unset the user.

          function spanStatusfromHttpCode

          spanStatusfromHttpCode: (httpStatus: number) => SpanStatusType;
          • Converts a HTTP status code into a SpanStatusType.

            Parameter httpStatus

            The HTTP response status code.

            Returns

            The span status or unknown_error.

          function startIdleTransaction

          startIdleTransaction: (
          hub: Hub,
          transactionContext: TransactionContext,
          idleTimeout: number,
          finalTimeout: number,
          onScope?: boolean,
          customSamplingContext?: CustomSamplingContext,
          heartbeatInterval?: number
          ) => IdleTransaction;
          • Create new idle transaction.

          function startInactiveSpan

          startInactiveSpan: (context: TransactionContext) => Span | undefined;
          • Creates a span. This span is not set as active, so will not get automatic instrumentation spans as children or be able to be accessed via Sentry.getSpan().

            If you want to create a span that is set as active, use startSpan.

            Note that if you have not enabled tracing extensions via addTracingExtensions or you didn't set tracesSampleRate or tracesSampler, this function will not generate spans and the span returned from the callback will be undefined.

          function startSpan

          startSpan: <T>(
          context: TransactionContext,
          callback: (span: Span | undefined) => T
          ) => T;
          • Wraps a function with a transaction/span and finishes the span after the function is done. The created span is the active span and will be used as parent by other spans created inside the function and can be accessed via Sentry.getSpan(), as long as the function is executed while the scope is active.

            If you want to create a span that is not set as active, use startInactiveSpan.

            Note that if you have not enabled tracing extensions via addTracingExtensions or you didn't set tracesSampleRate, this function will not generate spans and the span returned from the callback will be undefined.

          function startSpanManual

          startSpanManual: <T>(
          context: TransactionContext,
          callback: (span: Span | undefined, finish: () => void) => T
          ) => T;
          • Similar to Sentry.startSpan. Wraps a function with a transaction/span, but does not finish the span after the function is done automatically.

            The created span is the active span and will be used as parent by other spans created inside the function and can be accessed via Sentry.getActiveSpan(), as long as the function is executed while the scope is active.

            Note that if you have not enabled tracing extensions via addTracingExtensions or you didn't set tracesSampleRate, this function will not generate spans and the span returned from the callback will be undefined.

          function startTransaction

          startTransaction: (
          context: TransactionContext,
          customSamplingContext?: CustomSamplingContext
          ) => Transaction;
          • Starts a new Transaction and returns it. This is the entry point to manual tracing instrumentation.

            A tree structure can be built by adding child spans to the transaction, and child spans to other spans. To start a new child span within the transaction or any span, call the respective .startChild() method.

            Every child span must be finished before the transaction is finished, otherwise the unfinished spans are discarded.

            The transaction must be finished with a call to its .finish() method, at which point the transaction with all its finished child spans will be sent to Sentry.

            NOTE: This function should only be used for *manual* instrumentation. Auto-instrumentation should call startTransaction directly on the hub.

            Parameter context

            Properties of the new Transaction.

            Parameter customSamplingContext

            Information given to the transaction sampling function (along with context-dependent default values). See Options.tracesSampler.

            Returns

            The transaction which was just started

          function updateSession

          updateSession: (session: Session, context?: SessionContext) => void;
          • Updates a session object with the properties passed in the context.

            Note that this function mutates the passed object and returns void. (Had to do this instead of returning a new and updated session because closing and sending a session makes an update to the session after it was passed to the sending logic.

            Parameter session

            the Session to update

            Parameter context

            the SessionContext holding the properties that should be updated in

            Parameter session

            See Also

            • BaseClient.captureSession )

          function withMonitor

          withMonitor: <T>(
          monitorSlug: CheckIn,
          callback: () => T,
          upsertMonitorConfig?: MonitorConfig
          ) => T;
          • Wraps a callback with a cron monitor check in. The check in will be sent to Sentry when the callback finishes.

            Parameter monitorSlug

            The distinct slug of the monitor.

            Parameter upsertMonitorConfig

            An optional object that describes a monitor config. Use this if you want to create a monitor automatically when sending a check in.

          function withScope

          withScope: (callback: (scope: Scope) => void) => ReturnType<Hub['withScope']>;
          • Creates a new scope with and executes the given operation within. The scope is automatically removed once the operation finishes or throws.

            This is essentially a convenience function for:

            pushScope(); callback(); popScope();

            Parameter callback

            that will be enclosed into push/popScope.

          Classes

          class BaseClient

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

            Call the constructor with the corresponding options specific to the client subclass. To access these options later, use Client.getOptions.

            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, 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 { public constructor(options: NodeOptions) { super(options); }

            // ... }

          constructor

          protected constructor(options: ClientOptions);
          • Initializes this client instance.

            Parameter options

            Options for the client.

          method addEventProcessor

          addEventProcessor: (eventProcessor: EventProcessor) => void;

          method addIntegration

          addIntegration: (integration: Integration) => void;

          method captureEvent

          captureEvent: (
          event: Event,
          hint?: EventHint,
          scope?: Scope
          ) => string | undefined;

          method captureException

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

          method captureMessage

          captureMessage: (
          message: string,
          level?: Severity | SeverityLevel,
          hint?: EventHint,
          scope?: Scope
          ) => string | undefined;

          method captureSession

          captureSession: (session: Session) => void;

          method close

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

          method emit

          emit: {
          (hook: 'startTransaction', transaction: Transaction): void;
          (hook: 'finishTransaction', transaction: Transaction): void;
          (hook: 'beforeEnvelope', envelope: Envelope): void;
          (hook: 'beforeSendEvent', event: Event, hint?: EventHint): void;
          (hook: 'preprocessEvent', event: Event, hint?: EventHint): void;
          (hook: 'afterSendEvent', event: Event, sendResponse: any): void;
          (
          hook: 'beforeAddBreadcrumb',
          breadcrumb: Breadcrumb,
          hint?: BreadcrumbHint
          ): void;
          (hook: 'createDsc', dsc: DynamicSamplingContext): void;
          (
          hook: 'otelSpanEnd',
          otelSpan: unknown,
          mutableOptions: { drop: boolean }
          ): void;
          (
          hook: 'beforeSendFeedback',
          feedback: FeedbackEvent,
          options?: { includeReplay: boolean }
          ): void;
          };

          method eventFromException

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

          method eventFromMessage

          abstract eventFromMessage: (
          _message: string,
          _level?: Severity | SeverityLevel,
          _hint?: EventHint
          ) => PromiseLike<Event>;

          method flush

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

          method getDsn

          getDsn: () => DsnComponents | undefined;

          method getEventProcessors

          getEventProcessors: () => EventProcessor[];
          • Get all installed event processors.

          method getIntegration

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

          method getIntegrationById

          getIntegrationById: (integrationId: string) => Integration | undefined;
          • Gets an installed integration by its id.

            Returns

            The installed integration or undefined if no integration with that id was installed.

          method getOptions

          getOptions: () => O;

          method getSdkMetadata

          getSdkMetadata: () => SdkMetadata | undefined;
          • See Also

            • SdkMetadata in @sentry/types

              The metadata of the SDK

          method getTransport

          getTransport: () => Transport | undefined;

          method on

          on: {
          (
          hook: 'startTransaction',
          callback: (transaction: Transaction) => void
          ): void;
          (
          hook: 'finishTransaction',
          callback: (transaction: Transaction) => void
          ): void;
          (hook: 'beforeEnvelope', callback: (envelope: Envelope) => void): void;
          (
          hook: 'beforeSendEvent',
          callback: (event: Event, hint?: EventHint) => void
          ): void;
          (
          hook: 'preprocessEvent',
          callback: (event: Event, hint?: EventHint) => void
          ): void;
          (
          hook: 'afterSendEvent',
          callback: (event: Event, sendResponse: any) => void
          ): void;
          (
          hook: 'beforeAddBreadcrumb',
          callback: (breadcrumb: Breadcrumb, hint?: BreadcrumbHint) => void
          ): void;
          (hook: 'createDsc', callback: (dsc: DynamicSamplingContext) => void): void;
          (
          hook: 'otelSpanEnd',
          callback: (otelSpan: unknown, mutableOptions: { drop: boolean }) => void
          ): void;
          (
          hook: 'beforeSendFeedback',
          callback: (
          feedback: FeedbackEvent,
          options?: { includeReplay: boolean }
          ) => void
          ): void;
          };

          method recordDroppedEvent

          recordDroppedEvent: (
          reason: EventDropReason,
          category: DataCategory,
          _event?: Event
          ) => void;

          method sendEvent

          sendEvent: (event: Event, hint?: EventHint) => void;

          method sendSession

          sendSession: (session: Session | SessionAggregates) => void;

          method setupIntegrations

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

          class FunctionToString

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

          constructor

          constructor();

            property id

            static id: string;

            property name

            name: string;

            method setupOnce

            setupOnce: () => void;

            class Hub

            class Hub implements HubInterface {}

            constructor

            constructor(client?: Client, scope?: Scope, _version?: number);
            • Creates a new instance of the hub, will push one Layer into the internal stack on creation.

              Parameter client

              bound to the hub.

              Parameter scope

              bound to the hub.

              Parameter version

              number, higher number means higher priority.

            method addBreadcrumb

            addBreadcrumb: (breadcrumb: Breadcrumb, hint?: BreadcrumbHint) => void;

            method bindClient

            bindClient: (client?: Client) => void;

            method captureEvent

            captureEvent: (event: Event, hint?: EventHint) => string;

            method captureException

            captureException: (exception: unknown, hint?: EventHint) => string;

            method captureMessage

            captureMessage: (
            message: string,
            level?: Severity | SeverityLevel,
            hint?: EventHint
            ) => string;

            method captureSession

            captureSession: (endSession?: boolean) => void;

            method configureScope

            configureScope: (callback: (scope: Scope) => void) => void;

            method endSession

            endSession: () => void;

            method getClient

            getClient: <C extends Client>() => C | undefined;

            method getIntegration

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

            method getScope

            getScope: () => Scope;
            • Returns the scope of the top stack.

            method getStack

            getStack: () => Layer[];
            • Returns the scope stack for domains or the process.

            method getStackTop

            getStackTop: () => Layer;
            • Returns the topmost scope layer in the order domain > local > process.

            method isOlderThan

            isOlderThan: (version: number) => boolean;

            method lastEventId

            lastEventId: () => string | undefined;

            method popScope

            popScope: () => boolean;

            method pushScope

            pushScope: () => Scope;

            method run

            run: (callback: (hub: Hub) => void) => void;

            method setContext

            setContext: (name: string, context: { [key: string]: any }) => void;

            method setExtra

            setExtra: (key: string, extra: Extra) => void;

            method setExtras

            setExtras: (extras: Extras) => void;

            method setTag

            setTag: (key: string, value: Primitive) => void;

            method setTags

            setTags: (tags: { [key: string]: Primitive }) => void;

            method setUser

            setUser: (user: User | null) => void;

            method shouldSendDefaultPii

            shouldSendDefaultPii: () => boolean;
            • Returns if default PII should be sent to Sentry and propagated in ourgoing requests when Tracing is used.

            method startSession

            startSession: (context?: SessionContext) => Session;

            method startTransaction

            startTransaction: (
            context: TransactionContext,
            customSamplingContext?: CustomSamplingContext
            ) => Transaction;

            method traceHeaders

            traceHeaders: () => { [key: string]: string };

            method withScope

            withScope: (callback: (scope: Scope) => void) => void;

            class IdleTransaction

            class IdleTransaction extends Transaction {}
            • An IdleTransaction is a transaction that automatically finishes. It does this by tracking child spans as activities. You can have multiple IdleTransactions active, but if the onScope option is specified, the idle transaction will put itself on the scope on creation.

            constructor

            constructor(
            transactionContext: TransactionContext,
            _idleHub: Hub,
            _idleTimeout?: number,
            _finalTimeout?: number,
            _heartbeatInterval?: number,
            _onScope?: boolean
            );

              property activities

              activities: Record<string, boolean>;

                method cancelIdleTimeout

                cancelIdleTimeout: (
                endTimestamp?: Parameters<IdleTransaction['finish']>[0],
                { restartOnChildSpanChange }?: { restartOnChildSpanChange?: boolean }
                ) => void;
                • Cancels the existing idle timeout, if there is one.

                  Parameter restartOnChildSpanChange

                  Default is true. If set to false the transaction will end with the last child span.

                method finish

                finish: (endTimestamp?: number) => string | undefined;

                method initSpanRecorder

                initSpanRecorder: (maxlen?: number) => void;

                method registerBeforeFinishCallback

                registerBeforeFinishCallback: (callback: BeforeFinishCallback) => void;
                • Register a callback function that gets excecuted before the transaction finishes. Useful for cleanup or if you want to add any additional spans based on current context.

                  This is exposed because users have no other way of running something before an idle transaction finishes.

                class InboundFilters

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

                constructor

                constructor(options?: Partial<InboundFiltersOptions>);

                  property id

                  static id: string;

                  property name

                  name: string;

                  method processEvent

                  processEvent: (
                  event: Event,
                  _eventHint: EventHint,
                  client: Client
                  ) => Event | null;

                  method setupOnce

                  setupOnce: (_addGlobaleventProcessor: unknown, _getCurrentHub: unknown) => void;

                  class LinkedErrors

                  class LinkedErrors implements Integration {}
                  • Adds SDK info to an event.

                  constructor

                  constructor(options?: { key?: string; limit?: number });

                  property id

                  static id: string;

                  property name

                  readonly name: string;

                  method preprocessEvent

                  preprocessEvent: (
                  event: Event,
                  hint: EventHint | undefined,
                  client: Client
                  ) => void;

                  method setupOnce

                  setupOnce: () => void;

                  class ModuleMetadata

                  class ModuleMetadata implements Integration {}
                  • Adds module metadata to stack frames.

                    Metadata can be injected by the Sentry bundler plugins using the _experiments.moduleMetadata config option.

                    When this integration is added, the metadata passed to the bundler plugin is added to the stack frames of all events under the module_metadata property. This can be used to help in tagging or routing of events from different teams our sources

                  constructor

                  constructor();

                    property id

                    static id: string;

                      property name

                      name: string;

                      method setupOnce

                      setupOnce: (
                      addGlobalEventProcessor: (processor: EventProcessor) => void,
                      getCurrentHub: () => Hub
                      ) => void;

                      class RequestData

                      class RequestData implements Integration {}
                      • Add data about a request to an event. Primarily for use in Node-based SDKs, but included in @sentry/integrations so it can be used in cross-platform SDKs like @sentry/nextjs.

                      constructor

                      constructor(options?: RequestDataIntegrationOptions);

                      property id

                      static id: string;

                      property name

                      name: string;

                      method setupOnce

                      setupOnce: (
                      addGlobalEventProcessor: (eventProcessor: EventProcessor) => void,
                      getCurrentHub: () => Hub
                      ) => void;

                      class Scope

                      class Scope implements ScopeInterface {}
                      • Holds additional event information. Scope.applyToEvent will be called by the client before an event will be sent.

                      constructor

                      constructor();

                        method addAttachment

                        addAttachment: (attachment: Attachment) => this;

                        method addBreadcrumb

                        addBreadcrumb: (breadcrumb: Breadcrumb, maxBreadcrumbs?: number) => this;

                        method addEventProcessor

                        addEventProcessor: (callback: EventProcessor) => this;

                        method addScopeListener

                        addScopeListener: (callback: (scope: Scope) => void) => void;
                        • Add internal on change listener. Used for sub SDKs that need to store the scope.

                        method applyToEvent

                        applyToEvent: (
                        event: Event,
                        hint?: EventHint,
                        additionalEventProcessors?: EventProcessor[]
                        ) => PromiseLike<Event | null>;
                        • Applies data from the scope to the event and runs all event processors on it.

                          Parameter event

                          Event

                          Parameter hint

                          Object containing additional information about the original exception, for use by the event processors.

                        method clear

                        clear: () => this;

                        method clearAttachments

                        clearAttachments: () => this;

                        method clearBreadcrumbs

                        clearBreadcrumbs: () => this;

                        method clone

                        static clone: (scope?: Scope) => Scope;
                        • Inherit values from the parent scope.

                          Parameter scope

                          to clone.

                        method getAttachments

                        getAttachments: () => Attachment[];

                        method getLastBreadcrumb

                        getLastBreadcrumb: () => Breadcrumb | undefined;

                        method getPropagationContext

                        getPropagationContext: () => PropagationContext;

                        method getRequestSession

                        getRequestSession: () => RequestSession | undefined;

                        method getSession

                        getSession: () => Session | undefined;

                        method getSpan

                        getSpan: () => Span | undefined;

                        method getTransaction

                        getTransaction: () => Transaction | undefined;

                        method getUser

                        getUser: () => User | undefined;

                        method setContext

                        setContext: (key: string, context: Context | null) => this;

                        method setExtra

                        setExtra: (key: string, extra: Extra) => this;

                        method setExtras

                        setExtras: (extras: Extras) => this;

                        method setFingerprint

                        setFingerprint: (fingerprint: string[]) => this;

                        method setLevel

                        setLevel: (level: Severity | SeverityLevel) => this;

                        method setPropagationContext

                        setPropagationContext: (context: PropagationContext) => this;

                        method setRequestSession

                        setRequestSession: (requestSession?: RequestSession) => this;

                        method setSDKProcessingMetadata

                        setSDKProcessingMetadata: (newData: { [key: string]: unknown }) => this;
                        • Add data which will be accessible during event processing but won't get sent to Sentry

                        method setSession

                        setSession: (session?: Session) => this;

                        method setSpan

                        setSpan: (span?: Span) => this;

                        method setTag

                        setTag: (key: string, value: Primitive) => this;

                        method setTags

                        setTags: (tags: { [key: string]: Primitive }) => this;

                        method setTransactionName

                        setTransactionName: (name?: string) => this;

                        method setUser

                        setUser: (user: User | null) => this;

                        method update

                        update: (captureContext?: CaptureContext) => this;

                        class ServerRuntimeClient

                        class ServerRuntimeClient<
                        O extends ClientOptions & ServerRuntimeClientOptions = ServerRuntimeClientOptions
                        > extends BaseClient<O> {}
                        • The Sentry Server Runtime Client SDK.

                        constructor

                        constructor(options: {});
                        • Creates a new Edge SDK instance.

                          Parameter options

                          Configuration options for this SDK.

                        method captureCheckIn

                        captureCheckIn: (
                        checkIn: CheckIn,
                        monitorConfig?: MonitorConfig,
                        scope?: Scope
                        ) => string;
                        • Create a cron monitor check in and send it to Sentry.

                          Parameter checkIn

                          An object that describes a check in.

                          Parameter upsertMonitorConfig

                          An optional object that describes a monitor config. Use this if you want to create a monitor automatically when sending a check in.

                        method captureEvent

                        captureEvent: (
                        event: Event,
                        hint?: EventHint,
                        scope?: Scope
                        ) => string | undefined;

                        method captureException

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

                        method close

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

                        method eventFromException

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

                        method eventFromMessage

                        eventFromMessage: (
                        message: string,
                        level?: Severity | SeverityLevel,
                        hint?: EventHint
                        ) => PromiseLike<Event>;

                        method initSessionFlusher

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

                        class SessionFlusher

                        class SessionFlusher implements SessionFlusherLike {}

                        constructor

                        constructor(client: Client, attrs: ReleaseHealthAttributes);

                          property flushTimeout

                          readonly flushTimeout: number;

                            method close

                            close: () => void;
                            • JSDoc

                            method flush

                            flush: () => void;
                            • Checks if pendingAggregates has entries, and if it does flushes them by calling sendSession

                            method getSessionAggregates

                            getSessionAggregates: () => SessionAggregates;
                            • Massages the entries in pendingAggregates and returns aggregated sessions

                            method incrementSessionStatusCount

                            incrementSessionStatusCount: () => void;
                            • Wrapper function for _incrementSessionStatusCount that checks if the instance of SessionFlusher is enabled then fetches the session status of the request from Scope.getRequestSession().status on the scope and passes them to _incrementSessionStatusCount along with the start date

                            class Span

                            class Span implements SpanInterface {}
                            • Span contains all data about a span

                            property data

                            data: { [key: string]: any };

                            property description

                            description?: string;

                            property endTimestamp

                            endTimestamp?: number;
                            • Timestamp in seconds when the span ended.

                            property instrumenter

                            instrumenter: Instrumenter;
                            • The instrumenter that created this span.

                            property name

                            name: string;
                            • An alias for description of the Span.

                            property op

                            op?: string;

                            property origin

                            origin?: SpanOrigin;
                            • The origin of the span, giving context about what created the span.

                            property parentSpanId

                            parentSpanId?: string;

                            property sampled

                            sampled?: boolean;

                            property spanId

                            spanId: string;

                            property spanRecorder

                            spanRecorder?: SpanRecorder;
                            • List of spans that were finalized

                            property startTimestamp

                            startTimestamp: number;
                            • Timestamp in seconds when the span was created.

                            property status

                            status?: string;
                            • Internal keeper of the status

                            property tags

                            tags: { [key: string]: Primitive };

                            property traceId

                            traceId: string;

                            property transaction

                            transaction?: Transaction;

                            method finish

                            finish: (endTimestamp?: number) => void;

                            method getTraceContext

                            getTraceContext: () => TraceContext;

                            method isSuccess

                            isSuccess: () => boolean;

                            method setData

                            setData: (key: string, value: any) => this;

                            method setHttpStatus

                            setHttpStatus: (httpStatus: number) => this;

                            method setName

                            setName: (name: string) => void;

                            method setStatus

                            setStatus: (value: SpanStatusType) => this;

                            method setTag

                            setTag: (key: string, value: Primitive) => this;

                            method startChild

                            startChild: (
                            spanContext?: Pick<
                            SpanContext,
                            Exclude<keyof SpanContext, 'sampled' | 'traceId' | 'parentSpanId'>
                            >
                            ) => Span;

                            method toContext

                            toContext: () => SpanContext;

                            method toJSON

                            toJSON: () => {
                            data?: { [key: string]: any };
                            description?: string;
                            op?: string;
                            parent_span_id?: string;
                            span_id: string;
                            start_timestamp: number;
                            status?: string;
                            tags?: { [key: string]: Primitive };
                            timestamp?: number;
                            trace_id: string;
                            origin?: SpanOrigin;
                            };

                            method toTraceparent

                            toTraceparent: () => string;

                            method updateWithContext

                            updateWithContext: (spanContext: SpanContext) => this;

                            class Transaction

                            class Transaction extends SpanClass implements TransactionInterface {}
                            • JSDoc

                            property metadata

                            metadata: TransactionMetadata;

                              property name

                              name: string;
                              • Getter for name property

                              method finish

                              finish: (endTimestamp?: number) => string | undefined;

                              method getDynamicSamplingContext

                              getDynamicSamplingContext: () => DynamicSamplingContext;
                              • Modifiers

                                • @experimental

                              method initSpanRecorder

                              initSpanRecorder: (maxlen?: number) => void;
                              • Attaches SpanRecorder to the span itself

                                Parameter maxlen

                                maximum number of spans that can be recorded

                              method setContext

                              setContext: (key: string, context: Context | null) => void;

                              method setMeasurement

                              setMeasurement: (name: string, value: number, unit?: MeasurementUnit) => void;

                              method setMetadata

                              setMetadata: (newMetadata: TransactionMetadata) => void;

                              method setName

                              setName: (name: string, source?: TransactionMetadata) => void;
                              • JSDoc

                              method toContext

                              toContext: () => TransactionContext;

                              method updateWithContext

                              updateWithContext: (transactionContext: TransactionContext) => this;

                              Interfaces

                              interface AsyncContextStrategy

                              interface AsyncContextStrategy {}
                              • Private API with no semver guarantees!

                                Strategy used to track async context.

                              property getCurrentHub

                              getCurrentHub: () => Hub | undefined;
                              • Gets the current async context. Returns undefined if there is no current async context.

                              method runWithAsyncContext

                              runWithAsyncContext: <T>(
                              callback: () => T,
                              options: RunWithAsyncContextOptions
                              ) => T;
                              • Runs the supplied callback in its own async context.

                              interface Carrier

                              interface Carrier {}
                              • An object that contains a hub and maintains a scope stack.

                              interface Layer

                              interface Layer {}
                              • A layer in the process stack.

                              property client

                              client?: Client;

                                property scope

                                scope: Scope;

                                  interface OfflineStore

                                  interface OfflineStore {}

                                    method insert

                                    insert: (env: Envelope) => Promise<void>;

                                      method pop

                                      pop: () => Promise<Envelope | undefined>;

                                        interface OfflineTransportOptions

                                        interface OfflineTransportOptions extends InternalBaseTransportOptions {}

                                          property createStore

                                          createStore?: CreateOfflineStore;
                                          • A function that creates the offline store instance.

                                          property flushAtStartup

                                          flushAtStartup?: boolean;
                                          • Flush the offline store shortly after startup.

                                            Defaults: false

                                          property shouldStore

                                          shouldStore?: (
                                          envelope: Envelope,
                                          error: Error,
                                          retryDelay: number
                                          ) => boolean | Promise<boolean>;
                                          • Called before an event is stored.

                                            Return false to drop the envelope rather than store it.

                                            Parameter envelope

                                            The envelope that failed to send.

                                            Parameter error

                                            The error that occurred.

                                            Parameter retryDelay

                                            The current retry delay in milliseconds.

                                          interface RunWithAsyncContextOptions

                                          interface RunWithAsyncContextOptions {}

                                            property reuseExisting

                                            reuseExisting?: boolean;
                                            • Whether to reuse an existing async context if one exists. Defaults to false.

                                            interface ServerRuntimeClientOptions

                                            interface ServerRuntimeClientOptions extends ClientOptions<BaseTransportOptions> {}

                                              property platform

                                              platform?: string;

                                                property runtime

                                                runtime?: {
                                                name: string;
                                                version?: string;
                                                };

                                                  property serverName

                                                  serverName?: string;

                                                    Enums

                                                    enum SpanStatus

                                                    enum SpanStatus {
                                                    Ok = 'ok',
                                                    DeadlineExceeded = 'deadline_exceeded',
                                                    Unauthenticated = 'unauthenticated',
                                                    PermissionDenied = 'permission_denied',
                                                    NotFound = 'not_found',
                                                    ResourceExhausted = 'resource_exhausted',
                                                    InvalidArgument = 'invalid_argument',
                                                    Unimplemented = 'unimplemented',
                                                    Unavailable = 'unavailable',
                                                    InternalError = 'internal_error',
                                                    UnknownError = 'unknown_error',
                                                    Cancelled = 'cancelled',
                                                    AlreadyExists = 'already_exists',
                                                    FailedPrecondition = 'failed_precondition',
                                                    Aborted = 'aborted',
                                                    OutOfRange = 'out_of_range',
                                                    DataLoss = 'data_loss',
                                                    }
                                                    • The status of an Span.

                                                      Deprecated

                                                      Use string literals - if you require type casting, cast to SpanStatusType type

                                                    member Aborted

                                                    Aborted = 'aborted'
                                                    • The operation was aborted, typically due to a concurrency issue.

                                                    member AlreadyExists

                                                    AlreadyExists = 'already_exists'
                                                    • Already exists (409)

                                                    member Cancelled

                                                    Cancelled = 'cancelled'
                                                    • The operation was cancelled (typically by the user).

                                                    member DataLoss

                                                    DataLoss = 'data_loss'
                                                    • Unrecoverable data loss or corruption

                                                    member DeadlineExceeded

                                                    DeadlineExceeded = 'deadline_exceeded'
                                                    • Deadline expired before operation could complete.

                                                    member FailedPrecondition

                                                    FailedPrecondition = 'failed_precondition'
                                                    • Operation was rejected because the system is not in a state required for the operation's

                                                    member InternalError

                                                    InternalError = 'internal_error'
                                                    • Other/generic 5xx.

                                                    member InvalidArgument

                                                    InvalidArgument = 'invalid_argument'
                                                    • Client specified an invalid argument. 4xx.

                                                    member NotFound

                                                    NotFound = 'not_found'
                                                    • 404 Not Found. Some requested entity (file or directory) was not found.

                                                    member Ok

                                                    Ok = 'ok'
                                                    • The operation completed successfully.

                                                    member OutOfRange

                                                    OutOfRange = 'out_of_range'
                                                    • Operation was attempted past the valid range.

                                                    member PermissionDenied

                                                    PermissionDenied = 'permission_denied'
                                                    • 403 Forbidden

                                                    member ResourceExhausted

                                                    ResourceExhausted = 'resource_exhausted'
                                                    • 429 Too Many Requests

                                                    member Unauthenticated

                                                    Unauthenticated = 'unauthenticated'
                                                    • 401 Unauthorized (actually does mean unauthenticated according to RFC 7235)

                                                    member Unavailable

                                                    Unavailable = 'unavailable'
                                                    • 503 Service Unavailable

                                                    member Unimplemented

                                                    Unimplemented = 'unimplemented'
                                                    • 501 Not Implemented

                                                    member UnknownError

                                                    UnknownError = 'unknown_error'
                                                    • Unknown. Any non-standard HTTP status code.

                                                    Type Aliases

                                                    type BeforeFinishCallback

                                                    type BeforeFinishCallback = (
                                                    transactionSpan: IdleTransaction,
                                                    endTimestamp: number
                                                    ) => void;

                                                      type ClientClass

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

                                                      type RequestDataIntegrationOptions

                                                      type RequestDataIntegrationOptions = {
                                                      /**
                                                      * Controls what data is pulled from the request and added to the event
                                                      */
                                                      include?: {
                                                      cookies?: boolean;
                                                      data?: boolean;
                                                      headers?: boolean;
                                                      ip?: boolean;
                                                      query_string?: boolean;
                                                      url?: boolean;
                                                      user?:
                                                      | boolean
                                                      | {
                                                      id?: boolean;
                                                      username?: boolean;
                                                      email?: boolean;
                                                      };
                                                      };
                                                      /** Whether to identify transactions by parameterized path, parameterized path with method, or handler name */
                                                      transactionNamingScheme?: TransactionNamingScheme;
                                                      };

                                                        type SpanStatusType

                                                        type SpanStatusType =
                                                        /** The operation completed successfully. */
                                                        | 'ok'
                                                        /** Deadline expired before operation could complete. */
                                                        | 'deadline_exceeded'
                                                        /** 401 Unauthorized (actually does mean unauthenticated according to RFC 7235) */
                                                        | 'unauthenticated'
                                                        /** 403 Forbidden */
                                                        | 'permission_denied'
                                                        /** 404 Not Found. Some requested entity (file or directory) was not found. */
                                                        | 'not_found'
                                                        /** 429 Too Many Requests */
                                                        | 'resource_exhausted'
                                                        /** Client specified an invalid argument. 4xx. */
                                                        | 'invalid_argument'
                                                        /** 501 Not Implemented */
                                                        | 'unimplemented'
                                                        /** 503 Service Unavailable */
                                                        | 'unavailable'
                                                        /** Other/generic 5xx. */
                                                        | 'internal_error'
                                                        /** Unknown. Any non-standard HTTP status code. */
                                                        | 'unknown_error'
                                                        /** The operation was cancelled (typically by the user). */
                                                        | 'cancelled'
                                                        /** Already exists (409) */
                                                        | 'already_exists'
                                                        /** Operation was rejected because the system is not in a state required for the operation's */
                                                        | 'failed_precondition'
                                                        /** The operation was aborted, typically due to a concurrency issue. */
                                                        | 'aborted'
                                                        /** Operation was attempted past the valid range. */
                                                        | 'out_of_range'
                                                        /** Unrecoverable data loss or corruption */
                                                        | 'data_loss';

                                                          Namespaces

                                                          namespace Integrations

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

                                                            class FunctionToString

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

                                                            constructor

                                                            constructor();

                                                              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

                                                              constructor(options?: Partial<InboundFiltersOptions>);

                                                                property id

                                                                static id: string;

                                                                property name

                                                                name: string;

                                                                method processEvent

                                                                processEvent: (
                                                                event: Event,
                                                                _eventHint: EventHint,
                                                                client: Client
                                                                ) => Event | null;

                                                                method setupOnce

                                                                setupOnce: (_addGlobaleventProcessor: unknown, _getCurrentHub: unknown) => void;

                                                                class LinkedErrors

                                                                class LinkedErrors implements Integration {}
                                                                • Adds SDK info to an event.

                                                                constructor

                                                                constructor(options?: { key?: string; limit?: number });

                                                                property id

                                                                static id: string;

                                                                property name

                                                                readonly name: string;

                                                                method preprocessEvent

                                                                preprocessEvent: (
                                                                event: Event,
                                                                hint: EventHint | undefined,
                                                                client: Client
                                                                ) => void;

                                                                method setupOnce

                                                                setupOnce: () => void;

                                                                Package Files (37)

                                                                Dependencies (2)

                                                                Dev Dependencies (0)

                                                                No dev dependencies.

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

                                                                • Markdown
                                                                  [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@sentry/core)
                                                                • 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>