@sentry/core

  • Version 7.110.1
  • Published
  • 1.92 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

Variables

variable continueTrace

const continueTrace: ContinueTrace;

    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 FunctionToString

      const FunctionToString: IntegrationClass<any>;
      • Patch toString calls to return proper name for wrapped functions.

        Deprecated

        Use functionToStringIntegration() instead.

      variable InboundFilters

      const InboundFilters: any;
      • Inbound filters configurable by the user.

        Deprecated

        Use inboundFiltersIntegration() instead.

      variable Integrations

      const Integrations: typeof INTEGRATIONS;
      • Deprecated

        Import the integration function directly, e.g. inboundFiltersIntegration() instead of `new Integrations.InboundFilter().

      variable LinkedErrors

      const LinkedErrors: any;
      • Adds SDK info to an event.

        Deprecated

        Use linkedErrorsIntegration() instead.

      variable metrics

      const metrics: {
      increment: typeof increment;
      distribution: typeof distribution;
      set: typeof set;
      gauge: typeof gauge;
      MetricsAggregator: any;
      metricsAggregatorIntegration: () => import('@sentry/types').IntegrationFnResult;
      };

        variable ModuleMetadata

        const ModuleMetadata: IntegrationClass<any>;
        • 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

          Deprecated

          Use moduleMetadataIntegration() instead.

        variable RequestData

        const RequestData: any;
        • 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.

          Deprecated

          Use requestDataIntegration() instead.

        variable SDK_VERSION

        const SDK_VERSION: string;

          variable SEMANTIC_ATTRIBUTE_PROFILE_ID

          const SEMANTIC_ATTRIBUTE_PROFILE_ID: string;
          • The id of the profile that this span occured in.

          variable SEMANTIC_ATTRIBUTE_SENTRY_OP

          const SEMANTIC_ATTRIBUTE_SENTRY_OP: string;
          • Use this attribute to represent the operation of a span.

          variable SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN

          const SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN: string;
          • Use this attribute to represent the origin of a span.

          variable SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE

          const SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE: string;
          • Use this attribute to represent the sample rate used for a span.

          variable SEMANTIC_ATTRIBUTE_SENTRY_SOURCE

          const SEMANTIC_ATTRIBUTE_SENTRY_SOURCE: string;
          • Use this attribute to represent the source of a span. Should be one of: custom, url, route, view, component, task, unknown

          variable spanStatusfromHttpCode

          const 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.

            Deprecated

            Use spanStatusFromHttpCode instead. This export will be removed in v8 as the signature contains a typo.

          variable startActiveSpan

          const startActiveSpan: <T>(
          context: StartSpanOptions,
          callback: (span: any) => T
          ) => T;

          variable TRACING_DEFAULTS

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

            Functions

            function addBreadcrumb

            addBreadcrumb: (
            breadcrumb: Breadcrumb,
            hint?: BreadcrumbHint
            ) => 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 addEventProcessor

            addEventProcessor: (callback: EventProcessor) => void;
            • Add an event processor to the current client. This event processor will run for all events processed by this client.

            function addGlobalEventProcessor

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

              Deprecated

              Use addEventProcessor instead. Global event processors will be removed in v8.

            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 applyScopeDataToEvent

            applyScopeDataToEvent: (event: Event, data: ScopeData) => void;
            • Applies data from the scope to the event and runs all event processors on it.

            function applySdkMetadata

            applySdkMetadata: (
            options: Options,
            name: string,
            names?: string[],
            source?: string
            ) => void;
            • A builder for the SDK metadata in the options for the SDK initialization.

              Note: This function is identical to buildMetadata in Remix and NextJS and SvelteKit. We don't extract it for bundle size reasons.

              Parameter options

              SDK options object that gets mutated

              Parameter names

              list of package names

              See Also

              • https://github.com/getsentry/sentry-javascript/pull/7404

              • https://github.com/getsentry/sentry-javascript/pull/4196

                If you make changes to this function consider updating the others as well.

            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) => string;
            • Captures a manually created event and sends it to Sentry.

              Parameter exception

              The event to send to Sentry.

              Parameter hint

              Optional additional data to attach to the Sentry event.

              Returns

              the id of the captured event.

            function captureException

            captureException: (
            exception: any,
            hint?: ExclusiveEventHintOrCaptureContext
            ) => string;
            • Captures an exception event and sends it to Sentry.

              Parameter exception

              The exception to capture.

              Parameter hint

              Optional additional data to attach to the Sentry event.

              Returns

              the id of the captured Sentry event.

            function captureMessage

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

              Parameter exception

              The exception to capture.

              Parameter captureContext

              Define the level of the message or pass in additional data to attach to the message.

              Returns

              the id of the captured message.

            function captureSession

            captureSession: (end?: boolean) => void;
            • Sends the current session on the scope to Sentry

              Parameter end

              If set the session will be marked as exited and removed from the scope. Defaults to false.

            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.

              Deprecated

              Use getCurrentScope() directly.

            function convertIntegrationFnToClass

            convertIntegrationFnToClass: <Fn extends IntegrationFn>(
            name: string,
            fn: Fn
            ) => IntegrationClass<Integration>;
            • Convert a new integration function to the legacy class syntax. In v8, we can remove this and instead export the integration functions directly.

              Deprecated

              This will be removed in v8!

            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 createSessionEnvelope

            createSessionEnvelope: (
            session: Session | SessionAggregates,
            dsn?: DsnComponents,
            metadata?: SdkMetadata,
            tunnel?: string
            ) => SessionEnvelope;
            • Creates an envelope from a Session

            function createSpanEnvelope

            createSpanEnvelope: (spans: Span[], dsn?: DsnComponents) => SpanEnvelope;
            • Create envelope from Span item.

            function createTransport

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

              Parameter options

              Parameter makeRequest

            function defineIntegration

            defineIntegration: <Fn extends IntegrationFn>(
            fn: Fn
            ) => (...args: Parameters<Fn>) => IntegrationFnResult;
            • Define an integration function that can be used to create an integration instance. Note that this by design hides the implementation details of the integration, as they are considered internal.

            function endSession

            endSession: () => void;
            • End the session on the current isolation scope.

            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 functionToStringIntegration

            functionToStringIntegration: () => any;
            • Patch toString calls to return proper name for wrapped functions.

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

            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.

              Deprecated

              You should not rely on the transaction, but just use startSpan() APIs instead.

            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.

              Deprecated

              Use the respective replacement method directly instead.

            function getCurrentScope

            getCurrentScope: () => Scope;
            • Get the currently active scope.

            function getDynamicSamplingContextFromClient

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

              Dispatches the createDsc lifecycle hook as a side effect.

            function getDynamicSamplingContextFromSpan

            getDynamicSamplingContextFromSpan: (span: Span) => DynamicSamplingContext;
            • Creates a dynamic sampling context from a span (and client and scope)

              Parameter span

              the span from which a few values like the root span name and sample rate are extracted.

              Returns

              a dynamic sampling context

            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 getGlobalScope

            getGlobalScope: () => ScopeInterface;
            • Get the global scope. This scope is applied to _all_ events.

            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: Pick<Options, 'defaultIntegrations' | 'integrations'>
            ) => Integration[];
            • Gets integrations to install

            function getIsolationScope

            getIsolationScope: () => Scope;
            • Get the currently active isolation scope. The isolation scope is active for the current exection context, meaning that it will remain stable for the same Hub.

            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 getRootSpan

            getRootSpan: (span: Span) => Span | undefined;
            • Returns the root span of a given span.

              As long as we use Transactions internally, the returned root span will be a Transaction but be aware that this might change in the future.

              If the given span has no root span or transaction, undefined is returned.

            function getSpanStatusFromHttpCode

            getSpanStatusFromHttpCode: (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 handleCallbackErrors

            handleCallbackErrors: <Fn extends () => any>(
            fn: Fn,
            onError: (error: unknown) => void,
            onFinally?: () => void
            ) => ReturnType<Fn>;
            • Wrap a callback function with error handling. If an error is thrown, it will be passed to the onError callback and re-thrown.

              If the return value of the function is a promise, it will be handled with maybeHandlePromiseRejection.

              If an onFinally callback is provided, this will be called when the callback has finished - so if it returns a promise, once the promise resolved/rejected, else once the callback has finished executing. The onFinally callback will _always_ be called, no matter if an error was thrown or not.

            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 inboundFiltersIntegration

            inboundFiltersIntegration: (
            options?: Partial<InboundFiltersOptions> | undefined
            ) => any;

              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 isInitialized

              isInitialized: () => boolean;
              • Returns true if Sentry has been properly initialized.

              function isSentryRequestUrl

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

                Parameter url

                url to verify

                TODO(v8): Remove Hub fallback type

              function isValidSampleRate

              isValidSampleRate: (rate: unknown) => boolean;
              • Checks the given sample rate to make sure it is valid type and value (a boolean, or a number between 0 and 1).

              function lastEventId

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

                Returns

                The last event id of a captured event.

                Deprecated

                This function will be removed in the next major version of the Sentry SDK.

              function linkedErrorsIntegration

              linkedErrorsIntegration: (options?: LinkedErrorsOptions | undefined) => any;

                function makeMain

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

                  Returns

                  The old replaced hub

                  Deprecated

                  Use setCurrentClient() instead.

                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 mergeScopeData

                mergeScopeData: (data: ScopeData, mergeData: ScopeData) => void;
                • Merge data of two scopes together.

                function moduleMetadataIntegration

                moduleMetadataIntegration: () => any;

                  function notifyEventProcessors

                  notifyEventProcessors: (
                  processors: EventProcessor[],
                  event: Event | null,
                  hint: EventHint,
                  index?: number
                  ) => PromiseLike<Event | null>;
                  • Process an array of event processors, returning the processed event (or null if the event was dropped).

                  function parameterize

                  parameterize: (
                  strings: TemplateStringsArray,
                  ...values: string[]
                  ) => ParameterizedString;
                  • Tagged template function which returns paramaterized representation of the message For example: parameterizeThis is a log statement with ${x} and ${y} params, would return: "__sentry_template_string__": 'This is a log statement with %s and %s params', "__sentry_template_values__": ['first', 'second']

                    Parameter strings

                    An array of string values splitted between expressions

                    Parameter values

                    Expressions extracted from template string

                    Returns

                    String with template information in __sentry_template_string__ and __sentry_template_values__ properties

                  function prepareEvent

                  prepareEvent: (
                  options: ClientOptions,
                  event: Event,
                  hint: EventHint,
                  scope?: Scope,
                  client?: Client,
                  isolationScope?: Scope
                  ) => 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 requestDataIntegration

                  requestDataIntegration: (
                  options?: RequestDataIntegrationOptions | undefined
                  ) => any;

                    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 setCurrentClient

                    setCurrentClient: (client: Client) => void;
                    • Make the given client the current client.

                    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 setGlobalScope

                    setGlobalScope: (scope: ScopeInterface | undefined) => void;
                    • This is mainly needed for tests. DO NOT USE this, as this is an internal API and subject to change.

                    function setHttpStatus

                    setHttpStatus: (span: Span, httpStatus: number) => void;
                    • Sets the Http status attributes on the current span based on the http code. Additionally, the span's status is updated, depending on the http code.

                    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 spanIsSampled

                    spanIsSampled: (span: Span) => boolean;
                    • Returns true if a span is sampled. In most cases, you should just use span.isRecording() instead. However, this has a slightly different semantic, as it also returns false if the span is finished. So in the case where this distinction is important, use this method.

                    function spanToJSON

                    spanToJSON: (span: Span) => SpanJSON;
                    • Convert a span to a JSON representation. Note that all fields returned here are optional and need to be guarded against.

                      Note: Because of this, we currently have a circular type dependency (which we opted out of in package.json). This is not avoidable as we need spanToJSON in spanUtils.ts, which in turn is needed by span.ts for backwards compatibility. And spanToJSON needs the Span class from span.ts to check here. TODO v8: When we remove the deprecated stuff from span.ts, we can remove the circular dependency again.

                    function spanToTraceContext

                    spanToTraceContext: (span: Span) => TraceContext;
                    • Convert a span to a trace context, which can be sent as the trace context in an event.

                    function spanToTraceHeader

                    spanToTraceHeader: (span: Span) => string;
                    • Convert a Span to a Sentry trace header.

                    function startIdleTransaction

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

                    function startInactiveSpan

                    startInactiveSpan: (context: StartSpanOptions) => 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 startSession

                    startSession: (context?: SessionContext) => Session;
                    • Start a session on the current isolation scope.

                      Parameter context

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

                      Returns

                      the new active session

                    function startSpan

                    startSpan: <T>(
                    context: StartSpanOptions,
                    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: StartSpanOptions,
                    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. You'll have to call span.end() manually.

                      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 .end() 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

                      Deprecated

                      Use startSpan(), startSpanManual() or startInactiveSpan() instead.

                    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 withActiveSpan

                    withActiveSpan: <T>(span: Span, callback: (scope: Scope) => T) => T;
                    • Forks the current scope and sets the provided span as active span in the context of the provided callback.

                      Parameter span

                      Spans started in the context of the provided callback will be children of this span.

                      Parameter callback

                      Execution context in which the provided span will be active. Is passed the newly forked scope.

                      Returns

                      the value returned from the provided callback function.

                    function withIsolationScope

                    withIsolationScope: <T>(callback: (isolationScope: Scope) => T) => T;
                    • Attempts to fork the current isolation scope and the current scope based on the current async context strategy. If no async context strategy is set, the isolation scope and the current scope will not be forked (this is currently the case, for example, in the browser).

                      Usage of this function in environments without async context strategy is discouraged and may lead to unexpected behaviour.

                      This function is intended for Sentry SDK and SDK integration development. It is not recommended to be used in "normal" applications directly because it comes with pitfalls. Use at your own risk!

                      Parameter callback

                      The callback in which the passed isolation scope is active. (Note: In environments without async context strategy, the currently active isolation scope may change within execution of the callback.)

                      Returns

                      The same value that callback returns.

                    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: {
                    <T>(callback: (scope: Scope) => T): T;
                    <T>(scope: any, callback: (scope: Scope) => T): T;
                    };
                    • 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();

                    • Set the given scope as the active scope in the callback.

                    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.

                    property metricsAggregator

                    metricsAggregator?: MetricsAggregator;
                    • A reference to a metrics aggregator

                      Note this is alpha API. It may experience breaking changes in the future.

                      Modifiers

                      • @experimental

                    method addEventProcessor

                    addEventProcessor: (eventProcessor: EventProcessor) => void;

                    method addIntegration

                    addIntegration: (integration: Integration) => void;

                    method captureAggregateMetrics

                    captureAggregateMetrics: (metricBucketItems: Array<MetricBucketItem>) => 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: ParameterizedString,
                    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;
                    (hook: 'startPageLoadSpan', options: StartSpanOptions): void;
                    (hook: 'startNavigationSpan', options: StartSpanOptions): void;
                    };

                    method eventFromException

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

                    method eventFromMessage

                    abstract eventFromMessage: (
                    _message: ParameterizedString,
                    _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;
                    • Returns the client's instance of the given integration class, it any.

                      Deprecated

                      Use getIntegrationByName() instead.

                    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.

                      Deprecated

                      Use getIntegrationByName() instead.

                    method getIntegrationByName

                    getIntegrationByName: <T extends Integration = Integration>(
                    integrationName: string
                    ) => T | undefined;
                    • Gets an installed integration by its name.

                      Returns

                      The installed integration or undefined if no integration with that name 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 init

                    init: () => void;

                    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;
                    (
                    hook: 'startPageLoadSpan',
                    callback: (options: StartSpanOptions) => void
                    ): void;
                    (
                    hook: 'startNavigationSpan',
                    callback: (options: StartSpanOptions) => 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;
                    • This is an internal function to setup all integrations that should run on the client.

                      Deprecated

                      Use client.init() instead.

                    class Hub

                    class Hub implements HubInterface {}
                    • Deprecated

                      The Hub class will be removed in version 8 of the SDK in favour of Scope and Client objects.

                      If you previously used the Hub class directly, replace it with Scope and Client objects. More information: - [Multiple Sentry Instances](https://docs.sentry.io/platforms/javascript/best-practices/multiple-sentry-instances/) - [Browser Extensions](https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/)

                      Some of our APIs are typed with the Hub class instead of the interface (e.g. getCurrentHub). Most of them are deprecated themselves and will also be removed in version 8. More information: - [Migration Guide](https://github.com/getsentry/sentry-javascript/blob/develop/MIGRATION.md#deprecate-hub)

                    constructor

                    constructor(
                    client?: Client,
                    scope?: Scope,
                    isolationScope?: 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.

                      Deprecated

                      Instantiation of Hub objects is deprecated and the constructor will be removed in version 8 of the SDK.

                      If you are currently using the Hub for multi-client use like so:

                      // OLD
                      const hub = new Hub();
                      hub.bindClient(client);
                      makeMain(hub)

                      instead initialize the client as follows:

                      // NEW
                      Sentry.withIsolationScope(() => {
                      Sentry.setCurrentClient(client);
                      client.init();
                      });

                      If you are using the Hub to capture events like so:

                      // OLD
                      const client = new Client();
                      const hub = new Hub(client);
                      hub.captureException()

                      instead capture isolated events as follows:

                      // NEW
                      const client = new Client();
                      const scope = new Scope();
                      scope.setClient(client);
                      scope.captureException();

                    method addBreadcrumb

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

                      Use Sentry.addBreadcrumb() instead.

                    method bindClient

                    bindClient: (client?: Client) => void;
                    • This binds the given client to the current scope.

                      Parameter client

                      An SDK client (client) instance.

                      Deprecated

                      Use initAndBind() directly, or setCurrentClient() and/or client.init() instead.

                    method captureEvent

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

                      Use Sentry.captureEvent() instead.

                    method captureException

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

                      Use Sentry.captureException() instead.

                    method captureMessage

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

                      Use Sentry.captureMessage() instead.

                    method captureSession

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

                      Use top level captureSession instead.

                    method configureScope

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

                      Use getScope() directly.

                    method endSession

                    endSession: () => void;
                    • Deprecated

                      Use top level endSession instead.

                    method getClient

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

                      Use Sentry.getClient() instead.

                    method getIntegration

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

                      Use Sentry.getClient().getIntegrationByName() instead.

                    method getIsolationScope

                    getIsolationScope: () => Scope;
                    • Deprecated

                      Use Sentry.getIsolationScope() instead.

                    method getScope

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

                      Deprecated

                      Use Sentry.getCurrentScope() instead.

                    method getStack

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

                      Deprecated

                      This will be removed in v8.

                    method getStackTop

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

                      Deprecated

                      This will be removed in v8.

                    method isOlderThan

                    isOlderThan: (version: number) => boolean;
                    • Checks if this hub's version is older than the given version.

                      Parameter version

                      A version number to compare to. True if the given version is newer; otherwise false.

                      Deprecated

                      This will be removed in v8.

                    method lastEventId

                    lastEventId: () => string | undefined;
                    • Deprecated

                      This will be removed in v8.

                    method popScope

                    popScope: () => boolean;
                    • Deprecated

                      Use withScope instead.

                    method pushScope

                    pushScope: () => Scope;
                    • Deprecated

                      Use withScope instead.

                    method run

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

                    method setContext

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

                      Use Sentry.setContext() instead.

                    method setExtra

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

                      Use Sentry.setExtra() instead.

                    method setExtras

                    setExtras: (extras: Extras) => void;
                    • Deprecated

                      Use Sentry.setExtras() instead.

                    method setTag

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

                      Use Sentry.setTag() instead.

                    method setTags

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

                      Use Sentry.setTags() instead.

                    method setUser

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

                      Use Sentry.setUser() instead.

                    method shouldSendDefaultPii

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

                      Deprecated

                      Use top-level getClient().getOptions().sendDefaultPii instead. This function only unnecessarily increased API surface but only wrapped accessing the option.

                    method startSession

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

                      Use top level startSession instead.

                    method 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 .end() method, at which point the transaction with all its finished child spans will be sent to Sentry.

                      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

                      Deprecated

                      Use startSpan(), startSpanManual() or startInactiveSpan() instead.

                    method traceHeaders

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

                      Use spanToTraceHeader() instead.

                    method withScope

                    withScope: <T>(callback: (scope: Scope) => T) => T;
                    • Deprecated

                      Use Sentry.withScope() instead.

                    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,
                    delayAutoFinishUntilSignal?: boolean
                    );
                    • Deprecated

                      Transactions will be removed in v8. Use spans instead.

                    property activities

                    activities: Record<string, boolean>;

                      method cancelIdleTimeout

                      cancelIdleTimeout: (
                      endTimestamp?: SpanTimeInput,
                      { 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 end

                      end: (endTimestamp?: SpanTimeInput) => string | undefined;

                      method initSpanRecorder

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

                      method registerBeforeFinishCallback

                      registerBeforeFinishCallback: (callback: BeforeFinishCallback) => void;
                      • Register a callback function that gets executed 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.

                      method sendAutoFinishSignal

                      sendAutoFinishSignal: () => void;
                      • Permits the IdleTransaction to automatically end itself via the idle timeout and heartbeat mechanisms when the delayAutoFinishUntilSignal option was set to true.

                      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.

                          Deprecated

                          Use applyScopeDataToEvent() directly

                        method captureEvent

                        captureEvent: (event: Event, hint?: EventHint) => string;
                        • Captures a manually created event for this scope and sends it to Sentry.

                          Parameter exception

                          The event to capture.

                          Parameter hint

                          Optional additional data to attach to the Sentry event.

                          Returns

                          the id of the captured event.

                        method captureException

                        captureException: (exception: unknown, hint?: EventHint) => string;
                        • Capture an exception for this scope.

                          Parameter exception

                          The exception to capture.

                          Parameter hint

                          Optinal additional data to attach to the Sentry event.

                          Returns

                          the id of the captured Sentry event.

                        method captureMessage

                        captureMessage: (
                        message: string,
                        level?: SeverityLevel,
                        hint?: EventHint
                        ) => string;
                        • Capture a message for this scope.

                          Parameter message

                          The message to capture.

                          Parameter level

                          An optional severity level to report the message with.

                          Parameter hint

                          Optional additional data to attach to the Sentry event.

                          Returns

                          the id of the captured message.

                        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.

                          Deprecated

                          Use scope.clone() and new Scope() instead.

                        • Clone this scope instance.

                        method getAttachments

                        getAttachments: () => Attachment[];
                        • Deprecated

                          Use getScopeData() instead.

                        method getClient

                        getClient: () => Client | undefined;
                        • Get the client assigned to this scope.

                          It is generally recommended to use the global function Sentry.getClient() instead, unless you know what you are doing.

                        method getLastBreadcrumb

                        getLastBreadcrumb: () => Breadcrumb | undefined;

                        method getPropagationContext

                        getPropagationContext: () => PropagationContext;

                        method getRequestSession

                        getRequestSession: () => RequestSession | undefined;

                        method getScopeData

                        getScopeData: () => ScopeData;

                        method getSession

                        getSession: () => Session | undefined;

                        method getSpan

                        getSpan: () => Span | undefined;
                        • Returns the Span if there is one.

                          Deprecated

                          Use getActiveSpan() instead.

                        method getTransaction

                        getTransaction: () => Transaction | undefined;
                        • Returns the Transaction attached to the scope (if there is one).

                          Deprecated

                          You should not rely on the transaction, but just use startSpan() APIs instead.

                        method getUser

                        getUser: () => User | undefined;

                        method setClient

                        setClient: (client: Client | undefined) => void;
                        • Update the client on the scope.

                        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;
                        • Sets the Span on the scope.

                          Parameter span

                          Span

                          Deprecated

                          Instead of setting a span on a scope, use startSpan()/startSpanManual() instead.

                        method setTag

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

                        method setTags

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

                        method setTransactionName

                        setTransactionName: (name?: string) => this;
                        • Sets the transaction name on the scope for future events.

                        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: ParameterizedString,
                        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 attributes

                            attributes: SpanAttributes;
                            • Attributes for the span.

                              Deprecated

                              Use spanToJSON(span).atttributes instead.

                            property data

                            data: { [key: string]: any };
                            • Data for the span.

                              Deprecated

                              Use spanToJSON(span).atttributes instead.

                            property description

                            description: string;
                            • Get the description of the Span.

                              Deprecated

                              Use spanToJSON(span).description instead.

                            property endTimestamp

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

                              Deprecated

                              Use spanToJSON() instead.

                            property instrumenter

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

                              TODO (v8): This can probably be replaced by an instanceOf check of the span class. the instrumenter can only be sentry or otel so we can check the span instance to verify which one it is and remove this field entirely.

                              Deprecated

                              This field will be removed.

                            property name

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

                              Deprecated

                              Use spanToJSON(span).description instead.

                            property op

                            op: string;
                            • Operation of the span

                              Deprecated

                              Use spanToJSON().op to read the op instead.

                            property origin

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

                              Deprecated

                              Use spanToJSON().origin to read the origin instead.

                            property parentSpanId

                            parentSpanId: string;
                            • Deprecated

                              Use spanToJSON(span).parent_span_id instead.

                            property sampled

                            sampled: boolean;
                            • Was this span chosen to be sent as part of the sample?

                              Deprecated

                              Use isRecording() instead.

                            property spanId

                            spanId: string;
                            • The ID of the span.

                              Deprecated

                              Use spanContext().spanId instead.

                            property spanRecorder

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

                              Deprecated

                              This property will no longer be public. Span recording will be handled internally.

                            property startTimestamp

                            startTimestamp: number;
                            • Timestamp in seconds (epoch time) indicating when the span started.

                              Deprecated

                              Use spanToJSON() instead.

                            property status

                            status: string;
                            • The status of the span.

                              Deprecated

                              Use spanToJSON().status instead to get the status.

                            property tags

                            tags: { [key: string]: Primitive };
                            • Tags for the span.

                              Deprecated

                              Use spanToJSON(span).atttributes instead.

                            property traceId

                            traceId: string;
                            • The ID of the trace.

                              Deprecated

                              Use spanContext().traceId instead.

                            property transaction

                            transaction?: Transaction;
                            • Deprecated

                              Use top level Sentry.getRootSpan() instead

                            method end

                            end: (endTimestamp?: SpanTimeInput) => void;

                            method finish

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

                              Use .end() instead.

                            method getTraceContext

                            getTraceContext: () => TraceContext;
                            • Deprecated

                              Use spanToTraceContext() util function instead.

                            method isRecording

                            isRecording: () => boolean;

                            method isSuccess

                            isSuccess: () => boolean;
                            • Deprecated

                              Use spanToJSON(span).status === 'ok' instead.

                            method setAttribute

                            setAttribute: (key: string, value: SpanAttributeValue | undefined) => void;

                            method setAttributes

                            setAttributes: (attributes: SpanAttributes) => void;

                            method setData

                            setData: (key: string, value: any) => this;
                            • Sets the data attribute on the current span

                              Parameter key

                              Data key

                              Parameter value

                              Data value

                              Deprecated

                              Use setAttribute() instead.

                            method setHttpStatus

                            setHttpStatus: (httpStatus: number) => this;
                            • Deprecated

                              Use top-level setHttpStatus() instead.

                            method setName

                            setName: (name: string) => void;
                            • Deprecated

                              Use .updateName() instead.

                            method setStatus

                            setStatus: (value: SpanStatusType) => this;

                            method setTag

                            setTag: (key: string, value: Primitive) => this;
                            • Sets the tag attribute on the current span.

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

                              Parameter key

                              Tag key

                              Parameter value

                              Tag value

                              Deprecated

                              Use setAttribute() instead.

                            method spanContext

                            spanContext: () => SpanContextData;

                            method startChild

                            startChild: (
                            spanContext?: Pick<
                            SpanContext,
                            Exclude<keyof SpanContext, 'sampled' | 'traceId' | 'parentSpanId'>
                            >
                            ) => SpanInterface;
                            • Creates a new Span while setting the current Span.id as parentSpanId. Also the sampled decision will be inherited.

                              Deprecated

                              Use startSpan(), startSpanManual() or startInactiveSpan() instead.

                            method toContext

                            toContext: () => SpanContext;
                            • Deprecated

                              Use spanToJSON() or access the fields directly instead.

                            method toJSON

                            toJSON: () => SpanJSON;
                            • Convert the object to JSON.

                              Deprecated

                              Use spanToJSON(span) instead.

                            method toTraceparent

                            toTraceparent: () => string;
                            • Deprecated

                              Use spanToTraceHeader() instead.

                            method updateName

                            updateName: (name: string) => this;

                            method updateWithContext

                            updateWithContext: (spanContext: SpanContext) => this;
                            • Deprecated

                              Update the fields directly instead.

                            class Transaction

                            class Transaction extends SpanClass implements TransactionInterface {}
                            • JSDoc

                            property metadata

                            metadata: TransactionMetadata;
                            • Get the metadata for this transaction.

                              Deprecated

                              Use spanGetMetadata(transaction) instead.

                            property name

                            name: string;
                            • Getter for name property.

                              Deprecated

                              Use spanToJSON(span).description instead.

                            method end

                            end: (endTimestamp?: SpanTimeInput) => string | undefined;

                            method getDynamicSamplingContext

                            getDynamicSamplingContext: () => DynamicSamplingContext;
                            • Modifiers

                              • @experimental

                              Deprecated

                              Use top-level getDynamicSamplingContextFromSpan instead.

                            method getProfileId

                            getProfileId: () => string | undefined;
                            • Get the profile id of the transaction.

                            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;
                            • Set the context of a transaction event.

                              Deprecated

                              Use either .setAttribute(), or set the context on the scope before creating the transaction.

                            method setMeasurement

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

                              Use top-level setMeasurement() instead.

                            method setMetadata

                            setMetadata: (newMetadata: TransactionMetadata) => void;
                            • Store metadata on this transaction.

                              Deprecated

                              Use attributes or store data on the scope instead.

                            method setName

                            setName: (name: string, source?: TransactionMetadata) => void;
                            • Setter for name property, which also sets source on the metadata.

                              Deprecated

                              Use .updateName() and .setAttribute() instead.

                            method toContext

                            toContext: () => TransactionContext;

                            method updateName

                            updateName: (name: string) => this;

                            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 FunctionToString

                                                    type FunctionToString = typeof FunctionToString;

                                                      type IntegrationIndex

                                                      type IntegrationIndex = {
                                                      [key: string]: Integration;
                                                      };
                                                      • Map of integrations assigned to a client

                                                      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';

                                                          Package Files (46)

                                                          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>