Takaro - v0.6.0
    Preparing search index...

    A client for using Sentry with Node & OpenTelemetry.

    Hierarchy

    • ServerRuntimeClient<NodeClientOptions>
      • NodeClient
    Index

    Constructors

    • Parameters

      • options: NodeClientOptions

      Returns NodeClient

    Properties

    _dsn?: DsnComponents

    The client Dsn, if specified in options. Without this Dsn, the SDK will be disabled.

    _eventProcessors: EventProcessor[]
    _hooks: Record<string, Set<Function>>
    _integrations: IntegrationIndex

    Array of set up integrations.

    _numProcessing: number

    Number of calls being processed

    _options: NodeClientOptions

    Options passed to the SDK.

    _outcomes: { [key: string]: number }

    Holds flushable

    _promiseBuffer: PromiseBuffer<unknown>
    _transport?: Transport
    asyncLocalStorageLookup: AsyncLocalStorageLookup | undefined
    traceProvider: BasicTracerProvider | undefined

    Accessors

    • get tracer(): Tracer

      Get the OTEL tracer.

      Returns Tracer

    Methods

    • Processes the event and logs an error in case of rejection

      Parameters

      Returns PromiseLike<string | undefined>

    • Clears outcomes on this client and returns them.

      Returns Outcome[]

    • Sends client reports as an envelope.

      Returns void

    • Custom implementation for OTEL, so we can handle scope-span linking.

      Parameters

      Returns [
          dynamicSamplingContext: Partial<DynamicSamplingContext>,
          traceContext: TraceContext,
      ]

    • Determine if the client is finished processing. Returns a promise because it will wait timeout ms before saying "no" (resolving to false) in order to give the client a chance to potentially finish first.

      Parameters

      • Optionaltimeout: number

        The time, in ms, after which to resolve to false if the client is still busy. Passing 0 (or not passing anything) will make the promise wait as long as it takes for processing to finish before resolving to true.

      Returns Promise<boolean>

      A promise which will resolve to true if processing is already done or finishes before the timeout, and false otherwise

    • Determines whether this SDK is enabled and a transport is present.

      Returns boolean

    • Parameters

      Returns PromiseLike<Event | null>

    • Occupies the client with processing and event

      Type Parameters

      • T

      Parameters

      • taskProducer: () => PromiseLike<T>
      • dataCategory: DataCategory

      Returns void

    • Processes an event (either error or message) and sends it to Sentry.

      This also adds breadcrumbs and context information to the event. However, platform specific meta data (such as the User's IP address) must be added by the SDK implementor.

      Parameters

      • event: Event

        The event to send to Sentry.

      • hint: EventHint

        May contain additional information about the original exception.

      • currentScope: Scope

        A scope containing event metadata.

      • isolationScope: Scope

      Returns PromiseLike<Event>

      A SyncPromise that resolves with the event or rejects in case event was/will not be send.

    • Returns void

    • Updates existing session based on the provided event

      Parameters

      Returns void

    • Adds an event processor that applies to any event processed by this client.

      Parameters

      • eventProcessor: EventProcessor

      Returns void

    • Add an integration to the client. This can be used to e.g. lazy load integrations. In most cases, this should not be necessary, and you're better off just passing the integrations via integrations: [] at initialization time. However, if you find the need to conditionally load & add an integration, you can use addIntegration to do so.

      Parameters

      • integration: Integration

      Returns void

    • Create a cron monitor check in and send it to Sentry.

      Parameters

      • checkIn: CheckIn

        An object that describes a check in.

      • OptionalmonitorConfig: MonitorConfig
      • Optionalscope: Scope

      Returns string

    • Parameters

      Returns string

    • Parameters

      Returns string

    • Captures a message event and sends it to Sentry.

      Unlike captureMessage exported from every SDK, this method requires that you pass it the current scope.

      Parameters

      Returns string

    • Captures a session.

      Parameters

      Returns void

    • Parameters

      • Optionaltimeout: number

      Returns PromiseLike<boolean>

    • Disposes of the client and releases all resources.

      This method clears all internal state to allow the client to be garbage collected. It clears hooks, event processors, integrations, transport, and other internal references.

      Call this method after flushing to allow the client to be garbage collected. After calling dispose(), the client should not be used anymore.

      Subclasses should override this method to clean up their own resources and call super.dispose().

      Returns void

    • Fire a hook whenever a span starts.

      Parameters

      • hook: "spanStart"
      • span: Span

      Returns void

    • A hook that is called every time before a span is sampled.

      Parameters

      • hook: "beforeSampling"
      • samplingData: {
            parentContext?: SpanContextData;
            parentSampled?: boolean;
            parentSampleRate?: number;
            spanAttributes: SpanAttributes;
            spanName: string;
        }
      • samplingDecision: { decision: boolean }

      Returns void

    • Fire a hook whenever a span ends.

      Parameters

      • hook: "spanEnd"
      • span: Span

      Returns void

    • Fire a hook indicating that an idle span is allowed to auto finish.

      Parameters

      • hook: "idleSpanEnableAutoFinish"
      • span: Span

      Returns void

    • Fire a hook event for envelope creation and sending. Expects to be given an envelope as the second argument.

      Parameters

      • hook: "beforeEnvelope"
      • envelope: Envelope

      Returns void

    • Fire a hook indicating that stack frame metadata should be applied to the event passed to the hook.

      Parameters

      • hook: "applyFrameMetadata"
      • event: Event

      Returns void

    • Fire a hook event before sending an event. This is called right before an event is sent and should not be used to mutate the event. Expects to be given an Event & EventHint as the second/third argument.

      Parameters

      Returns void

    • Fire a hook event before sending a session/aggregates. Expects to be given the prepared session/aggregates as second argument.

      Parameters

      • hook: "beforeSendSession"
      • session: Session | SessionAggregates

      Returns void

    • Fire a hook event to process events before they are passed to (global) event processors. Expects to be given an Event & EventHint as the second/third argument.

      Parameters

      Returns void

    • Fire a hook event to process a user on an event before it is sent to Sentry, after all other processors have run. Expects to be given an Event & EventHint as the second/third argument.

      Parameters

      Returns void

    • Fire a hook event after sending an event. Expects to be given an Event as the second argument.

      Parameters

      • hook: "afterSendEvent"
      • event: Event
      • sendResponse: TransportMakeRequestResponse

      Returns void

    • Fire a hook for when a breadcrumb is added. Expects the breadcrumb as second argument.

      Parameters

      Returns void

    • Fire a hook for when a DSC (Dynamic Sampling Context) is created. Expects the DSC as second argument.

      Parameters

      • hook: "createDsc"
      • dsc: DynamicSamplingContext
      • OptionalrootSpan: Span

      Returns void

    • Fire a hook event for after preparing a feedback event. Events to be given a feedback event as the second argument, and an optional options object as third argument.

      Parameters

      • hook: "beforeSendFeedback"
      • feedback: FeedbackEvent
      • Optionaloptions: { includeReplay?: boolean }

      Returns void

    • Fire a hook event for when the feedback widget is opened in a user's browser

      Parameters

      • hook: "openFeedbackWidget"

      Returns void

    • Emit a hook event for browser tracing integrations to trigger a span start for a page load.

      Parameters

      • hook: "startPageLoadSpan"
      • options: StartSpanOptions
      • OptionaltraceOptions: { baggage?: string; sentryTrace?: string }

      Returns void

    • Emit a hook event for browser tracing integrations to trigger the end of a page load span.

      Parameters

      • hook: "endPageloadSpan"

      Returns void

    • Emit a hook event for browser tracing integrations to trigger aafter the pageload span was started.

      Parameters

      • hook: "afterStartPageLoadSpan"
      • span: Span

      Returns void

    • Emit a hook event for triggering right before a navigation span is started.

      Parameters

      • hook: "beforeStartNavigationSpan"
      • options: StartSpanOptions
      • OptionalnavigationOptions: { isRedirect?: boolean }

      Returns void

    • Emit a hook event for browser tracing integrations to trigger a span for a navigation.

      Parameters

      • hook: "startNavigationSpan"
      • options: StartSpanOptions
      • OptionalnavigationOptions: { isRedirect?: boolean }

      Returns void

    • Emit a hook event for GraphQL client integration to enhance a span with request data.

      Parameters

      • hook: "beforeOutgoingRequestSpan"
      • span: Span
      • hint: XhrBreadcrumbHint | FetchBreadcrumbHint

      Returns void

    • Emit a hook event for GraphQL client integration to enhance a breadcrumb with request data.

      Parameters

      • hook: "beforeOutgoingRequestBreadcrumb"
      • breadcrumb: Breadcrumb
      • hint: XhrBreadcrumbHint | FetchBreadcrumbHint

      Returns void

    • Emit a hook event for client flush

      Parameters

      • hook: "flush"

      Returns void

    • Emit a hook event for client close

      Parameters

      • hook: "close"

      Returns void

    • Emit a hook event for client before capturing a log. This hooks runs before beforeSendLog is fired.

      Parameters

      • hook: "beforeCaptureLog"
      • log: Log

      Returns void

    • Emit a hook event for client after capturing a log.

      Parameters

      • hook: "afterCaptureLog"
      • log: Log

      Returns void

    • Emit a hook event for client flush logs

      Parameters

      • hook: "flushLogs"

      Returns void

    • Emit a hook event for client after capturing a metric.

      Parameters

      • hook: "afterCaptureMetric"
      • metric: Metric

      Returns void

    • Emit a hook event for client flush metrics

      Parameters

      • hook: "flushMetrics"

      Returns void

    • Emit a hook event for client to process a metric before it is captured. This hook is called before the beforeSendMetric callback is fired.

      Parameters

      • hook: "processMetric"
      • metric: Metric

      Returns void

    • Emit a hook event for client when a http server request is started. This hook is called after request isolation, but before the request is processed.

      Parameters

      • hook: "httpServerRequest"
      • request: unknown
      • response: unknown
      • normalizedRequest: RequestEventData

      Returns void

    • Emit a hook event for starting the UI Profiler.

      Parameters

      • hook: "startUIProfiler"

      Returns void

    • Emit a hook event for stopping the UI Profiler.

      Parameters

      • hook: "stopUIProfiler"

      Returns void

    • Parameters

      Returns PromiseLike<Event>

    • Parameters

      Returns PromiseLike<Event>

    • Parameters

      • Optionaltimeout: number

      Returns PromiseLike<boolean>

    • Get the current Dsn.

      Returns DsnComponents | undefined

    • Get all installed event processors.

      Returns EventProcessor[]

    • Gets an installed integration by its name.

      Type Parameters

      • T extends Integration = Integration

      Parameters

      • integrationName: string

      Returns T | undefined

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

    • Get the current options.

      Returns NodeClientOptions

    • Get the SDK metadata.

      Returns SdkMetadata | undefined

      SdkMetadata

    • Returns the transport that is used by the client. Please note that the transport gets lazy initialized so it will only be there once the first event has been sent.

      Returns Transport | undefined

    • Initialize this client. Call this after the client was set on a scope.

      Returns void

    • Register a callback for whenever a span is started. Receives the span as argument.

      Parameters

      • hook: "spanStart"
      • callback: (span: Span) => void

      Returns () => void

      A function that, when executed, removes the registered callback.

    • Register a callback before span sampling runs. Receives a samplingDecision object argument with a decision property that can be used to make a sampling decision that will be enforced, before any span sampling runs.

      Parameters

      • hook: "beforeSampling"
      • callback: (
            samplingData: {
                parentContext?: SpanContextData;
                parentSampled?: boolean;
                parentSampleRate?: number;
                spanAttributes: SpanAttributes;
                spanName: string;
            },
            samplingDecision: { decision: boolean },
        ) => void

      Returns void

      A function that, when executed, removes the registered callback.

    • Register a callback for after a span is ended. NOTE: The span cannot be mutated anymore in this callback. Receives the span as argument.

      Parameters

      • hook: "spanEnd"
      • callback: (span: Span) => void

      Returns () => void

      A function that, when executed, removes the registered callback.

    • Register a callback for when an idle span is allowed to auto-finish.

      Parameters

      • hook: "idleSpanEnableAutoFinish"
      • callback: (span: Span) => void

      Returns () => void

      A function that, when executed, removes the registered callback.

    • Register a callback for transaction start and finish.

      Parameters

      • hook: "beforeEnvelope"
      • callback: (envelope: Envelope) => void

      Returns () => void

      A function that, when executed, removes the registered callback.

    • Register a callback that runs when stack frame metadata should be applied to an event.

      Parameters

      • hook: "applyFrameMetadata"
      • callback: (event: Event) => void

      Returns () => void

      A function that, when executed, removes the registered callback.

    • Register a callback for before sending an event. This is called right before an event is sent and should not be used to mutate the event. Receives an Event & EventHint as arguments.

      Parameters

      • hook: "beforeSendEvent"
      • callback: (event: Event, hint?: EventHint) => void

      Returns () => void

      A function that, when executed, removes the registered callback.

    • Register a callback for before sending a session or session aggregrates.. Receives the session/aggregate as second argument.

      Parameters

      • hook: "beforeSendSession"
      • callback: (session: Session | SessionAggregates) => void

      Returns () => void

      A function that, when executed, removes the registered callback.

    • Register a callback for preprocessing an event, before it is passed to (global) event processors. Receives an Event & EventHint as arguments.

      Parameters

      • hook: "preprocessEvent"
      • callback: (event: Event, hint?: EventHint) => void

      Returns () => void

      A function that, when executed, removes the registered callback.

    • Register a callback for postprocessing an event, after it was passed to (global) event processors, before it is being sent. Receives an Event & EventHint as arguments.

      Parameters

      • hook: "postprocessEvent"
      • callback: (event: Event, hint?: EventHint) => void

      Returns () => void

      A function that, when executed, removes the registered callback.

    • Register a callback for when an event has been sent.

      Parameters

      • hook: "afterSendEvent"
      • callback: (event: Event, sendResponse: TransportMakeRequestResponse) => void

      Returns () => void

      A function that, when executed, removes the registered callback.

    • Register a callback before a breadcrumb is added.

      Parameters

      Returns () => void

      A function that, when executed, removes the registered callback.

    • Register a callback when a DSC (Dynamic Sampling Context) is created.

      Parameters

      • hook: "createDsc"
      • callback: (dsc: DynamicSamplingContext, rootSpan?: Span) => void

      Returns () => void

      A function that, when executed, removes the registered callback.

    • Register a callback when a Feedback event has been prepared. This should be used to mutate the event. The options argument can hint about what kind of mutation it expects.

      Parameters

      • hook: "beforeSendFeedback"
      • callback: (feedback: FeedbackEvent, options?: { includeReplay?: boolean }) => void

      Returns () => void

      A function that, when executed, removes the registered callback.

    • Register a callback when the feedback widget is opened in a user's browser

      Parameters

      • hook: "openFeedbackWidget"
      • callback: () => void

      Returns () => void

    • A hook for the browser tracing integrations to trigger a span start for a page load.

      Parameters

      • hook: "startPageLoadSpan"
      • callback: (
            options: StartSpanOptions,
            traceOptions?: { baggage?: string; sentryTrace?: string },
        ) => void

      Returns () => void

      A function that, when executed, removes the registered callback.

    • A hook for the browser tracing integrations to trigger the end of a page load span.

      Parameters

      • hook: "endPageloadSpan"
      • callback: () => void

      Returns () => void

      A function that, when executed, removes the registered callback.

    • A hook for the browser tracing integrations to trigger after the pageload span was started.

      Parameters

      • hook: "afterStartPageLoadSpan"
      • callback: (span: Span) => void

      Returns () => void

      A function that, when executed, removes the registered callback.

    • A hook for triggering right before a navigation span is started.

      Parameters

      • hook: "beforeStartNavigationSpan"
      • callback: (
            options: StartSpanOptions,
            navigationOptions?: { isRedirect?: boolean },
        ) => void

      Returns () => void

      A function that, when executed, removes the registered callback.

    • A hook for browser tracing integrations to trigger a span for a navigation.

      Parameters

      • hook: "startNavigationSpan"
      • callback: (
            options: StartSpanOptions,
            navigationOptions?: { isRedirect?: boolean },
        ) => void

      Returns () => void

      A function that, when executed, removes the registered callback.

    • A hook for GraphQL client integration to enhance a span with request data.

      Parameters

      • hook: "beforeOutgoingRequestSpan"
      • callback: (span: Span, hint: XhrBreadcrumbHint | FetchBreadcrumbHint) => void

      Returns () => void

      A function that, when executed, removes the registered callback.

    • A hook for GraphQL client integration to enhance a breadcrumb with request data.

      Parameters

      • hook: "beforeOutgoingRequestBreadcrumb"
      • callback: (breadcrumb: Breadcrumb, hint: XhrBreadcrumbHint | FetchBreadcrumbHint) => void

      Returns () => void

      A function that, when executed, removes the registered callback.

    • A hook that is called when the client is flushing

      Parameters

      • hook: "flush"
      • callback: () => void

      Returns () => void

      A function that, when executed, removes the registered callback.

    • A hook that is called when the client is closing

      Parameters

      • hook: "close"
      • callback: () => void

      Returns () => void

      A function that, when executed, removes the registered callback.

    • A hook that is called before a log is captured. This hooks runs before beforeSendLog is fired.

      Parameters

      • hook: "beforeCaptureLog"
      • callback: (log: Log) => void

      Returns () => void

      A function that, when executed, removes the registered callback.

    • A hook that is called after a log is captured

      Parameters

      • hook: "afterCaptureLog"
      • callback: (log: Log) => void

      Returns () => void

      A function that, when executed, removes the registered callback.

    • A hook that is called when the client is flushing logs

      Parameters

      • hook: "flushLogs"
      • callback: () => void

      Returns () => void

      A function that, when executed, removes the registered callback.

    • A hook that is called after capturing a metric. This hooks runs after beforeSendMetric is fired.

      Parameters

      • hook: "afterCaptureMetric"
      • callback: (metric: Metric) => void

      Returns () => void

      A function that, when executed, removes the registered callback.

    • A hook that is called when the client is flushing metrics

      Parameters

      • hook: "flushMetrics"
      • callback: () => void

      Returns () => void

      A function that, when executed, removes the registered callback.

    • A hook that is called when a metric is processed before it is captured and before the beforeSendMetric callback is fired.

      Parameters

      • hook: "processMetric"
      • callback: (metric: Metric) => void

      Returns () => void

      A function that, when executed, removes the registered callback.

    • A hook that is called when a http server request is started. This hook is called after request isolation, but before the request is processed.

      Parameters

      • hook: "httpServerRequest"
      • callback: (
            request: unknown,
            response: unknown,
            normalizedRequest: RequestEventData,
        ) => void

      Returns () => void

      A function that, when executed, removes the registered callback.

    • A hook that is called when the UI Profiler should start profiling.

      This hook is called when running Sentry.uiProfiler.startProfiler().

      Parameters

      • hook: "startUIProfiler"
      • callback: () => void

      Returns () => void

      A function that, when executed, removes the registered callback.

    • A hook that is called when the UI Profiler should stop profiling.

      This hook is called when running Sentry.uiProfiler.stopProfiler().

      Parameters

      • hook: "stopUIProfiler"
      • callback: () => void

      Returns () => void

      A function that, when executed, removes the registered callback.

    • Record on the client that an event got dropped (ie, an event that will not be sent to Sentry).

      Parameters

      • reason: EventDropReason
      • category: DataCategory
      • Optionalcount: number

      Returns void

    • Send an envelope to Sentry.

      Parameters

      • envelope: Envelope

      Returns PromiseLike<TransportMakeRequestResponse>

    • Send a fully prepared event to Sentry.

      Parameters

      Returns void

    • Send a session or session aggregrates to Sentry.

      Parameters

      • session: Session | SessionAggregates

      Returns void

    • Will start tracking client reports for this client.

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

      Returns void