Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/sentry_deno/packages/core/src/baseclient.ts>BaseClient

Unofficial port of the Sentry SDK for JavaScript to Deno.
Latest
class BaseClient
implements Client<O>
Abstract
import { BaseClient } from "https://deno.land/x/sentry_deno@v0.2.2/packages/core/src/baseclient.ts";

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.

Examples

class NodeClient extends BaseClient { public constructor(options: NodeOptions) { super(options); }

// ... }

Constructors

new
protected
BaseClient(options: O)

Initializes this client instance.

Properties

private
_outcomes: { [key: string]: number; }

Holds flushable

protected
readonly
optional
_dsn: DsnComponents

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

protected
_integrations: IntegrationIndex

Array of set up integrations.

protected
_integrationsInitialized: boolean

Indicates whether this client's integrations have been set up.

protected
_numProcessing: number

Number of calls being processed

protected
readonly
_options: O

Options passed to the SDK.

protected
readonly
optional
_transport: Transport

Methods

protected
_applyClientOptions(event: Event): void

Enhances event using the client configuration. It takes care of all "static" values like environment, release and dist, as well as truncating overly long values.

protected
_applyIntegrationsMetadata(event: Event): void

This function adds all used integrations to the SDK info in the event.

protected
_captureEvent(
event: Event,
hint?: EventHint,
scope?: Scope,
): PromiseLike<string | undefined>

Processes the event and logs an error in case of rejection

protected
_clearOutcomes(): Outcome[]

Clears outcomes on this client and returns them.

protected
_isClientDoneProcessing(timeout?: number): PromiseLike<boolean>

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.

protected
_isEnabled(): boolean

Determines whether this SDK is enabled and a valid Dsn is present.

protected
_normalizeEvent(
event: Event | null,
depth: number,
maxBreadth: number,
): Event | null

Applies normalize function on necessary Event attributes to make them safe for serialization. Normalized keys:

  • breadcrumbs.data
  • user
  • contexts
  • extra
protected
_prepareEvent(
event: Event,
hint: EventHint,
scope?: 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.

protected
_process<T>(promise: PromiseLike<T>): void

Occupies the client with processing and event

protected
_processEvent(
event: Event,
hint: EventHint,
scope?: Scope,
): PromiseLike<Event>

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.

protected
_sendEnvelope(envelope: Envelope): void
protected
_updateSessionFromEvent(session: Session, event: Event): void

Updates existing session based on the provided event

captureEvent(
event: Event,
hint?: EventHint,
scope?: Scope,
): string | undefined
captureException(
exception: any,
hint?: EventHint,
scope?: Scope,
): string | undefined
captureMessage(
message: string,
hint?: EventHint,
scope?: Scope,
): string | undefined
captureSession(session: Session): void
close(timeout?: number): PromiseLike<boolean>
abstract
eventFromException(_exception: any, _hint?: EventHint): PromiseLike<Event>
abstract
eventFromMessage(
_message: string,
_hint?: EventHint,
): PromiseLike<Event>
flush(timeout?: number): PromiseLike<boolean>
getDsn(): DsnComponents | undefined
getIntegration<T extends Integration>(integration: IntegrationClass<T>): T | null
getIntegrationById(integrationId: string): Integration | undefined

Gets an installed integration by its id.

getTransport(): Transport | undefined
sendEvent(event: Event, hint?: EventHint): void

Sets up the integrations