import { Scope } from '@sentry/hub'; import { Client, ClientOptions, DataCategory, DsnComponents, Envelope, Event, EventDropReason, EventHint, Integration, IntegrationClass, Outcome, Session, SessionAggregates, Severity, SeverityLevel, Transport } from '@sentry/types'; import { IntegrationIndex } from './integration'; /** * 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 * {@link Client.getOptions}. * * If a Dsn is specified in the options, it will be parsed and stored. Use * {@link Client.getDsn} to retrieve the Dsn at any moment. In case the Dsn is * invalid, the constructor will throw a {@link SentryException}. Note that * without a valid Dsn, the SDK will not send any events to Sentry. * * Before sending an event, it is passed through * {@link 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 * {@link Client.captureEvent}. It will prepare the event and pass it through * the callback lifecycle. To issue auto-breadcrumbs, use * {@link Client.addBreadcrumb}. * * @example * class NodeClient extends BaseClient { * public constructor(options: NodeOptions) { * super(options); * } * * // ... * } */ export declare abstract class BaseClient implements Client { /** Options passed to the SDK. */ protected readonly _options: O; /** The client Dsn, if specified in options. Without this Dsn, the SDK will be disabled. */ protected readonly _dsn?: DsnComponents; protected readonly _transport?: Transport; /** Array of set up integrations. */ protected _integrations: IntegrationIndex; /** Indicates whether this client's integrations have been set up. */ protected _integrationsInitialized: boolean; /** Number of calls being processed */ protected _numProcessing: number; /** Holds flushable */ private _outcomes; /** * Initializes this client instance. * * @param options Options for the client. */ protected constructor(options: O); /** * @inheritDoc */ captureException(exception: any, hint?: EventHint, scope?: Scope): string | undefined; /** * @inheritDoc */ captureMessage(message: string, level?: Severity | SeverityLevel, hint?: EventHint, scope?: Scope): string | undefined; /** * @inheritDoc */ captureEvent(event: Event, hint?: EventHint, scope?: Scope): string | undefined; /** * @inheritDoc */ captureSession(session: Session): void; /** * @inheritDoc */ getDsn(): DsnComponents | undefined; /** * @inheritDoc */ getOptions(): O; /** * @inheritDoc */ getTransport(): Transport | undefined; /** * @inheritDoc */ flush(timeout?: number): PromiseLike; /** * @inheritDoc */ close(timeout?: number): PromiseLike; /** * Sets up the integrations */ setupIntegrations(): void; /** * Gets an installed integration by its `id`. * * @returns The installed integration or `undefined` if no integration with that `id` was installed. */ getIntegrationById(integrationId: string): Integration | undefined; /** * @inheritDoc */ getIntegration(integration: IntegrationClass): T | null; /** * @inheritDoc */ sendEvent(event: Event, hint?: EventHint): void; /** * @inheritDoc */ sendSession(session: Session | SessionAggregates): void; /** * @inheritDoc */ recordDroppedEvent(reason: EventDropReason, category: DataCategory): void; /** Updates existing session based on the provided event */ protected _updateSessionFromEvent(session: Session, event: Event): void; /** * 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. * * @param timeout 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 A promise which will resolve to `true` if processing is already done or finishes before the timeout, and * `false` otherwise */ protected _isClientDoneProcessing(timeout?: number): PromiseLike; /** Determines whether this SDK is enabled and a valid Dsn is present. */ protected _isEnabled(): boolean; /** * 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. * * @param event The original event. * @param hint May contain additional information about the original exception. * @param scope A scope containing event metadata. * @returns A new event with more information. */ protected _prepareEvent(event: Event, hint: EventHint, scope?: Scope): PromiseLike; /** * Applies `normalize` function on necessary `Event` attributes to make them safe for serialization. * Normalized keys: * - `breadcrumbs.data` * - `user` * - `contexts` * - `extra` * @param event Event * @returns Normalized event */ protected _normalizeEvent(event: Event | null, depth: number, maxBreadth: number): Event | null; /** * 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. * @param event event instance to be enhanced */ protected _applyClientOptions(event: Event): void; /** * This function adds all used integrations to the SDK info in the event. * @param event The event that will be filled with all integrations. */ protected _applyIntegrationsMetadata(event: Event): void; /** * Processes the event and logs an error in case of rejection * @param event * @param hint * @param scope */ protected _captureEvent(event: Event, hint?: EventHint, scope?: Scope): PromiseLike; /** * 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. * * * @param event The event to send to Sentry. * @param hint May contain additional information about the original exception. * @param scope A scope containing event metadata. * @returns A SyncPromise that resolves with the event or rejects in case event was/will not be send. */ protected _processEvent(event: Event, hint: EventHint, scope?: Scope): PromiseLike; /** * Occupies the client with processing and event */ protected _process(promise: PromiseLike): void; /** * @inheritdoc */ protected _sendEnvelope(envelope: Envelope): void; /** * Clears outcomes on this client and returns them. */ protected _clearOutcomes(): Outcome[]; /** * @inheritDoc */ abstract eventFromException(_exception: any, _hint?: EventHint): PromiseLike; /** * @inheritDoc */ abstract eventFromMessage(_message: string, _level?: Severity | SeverityLevel, _hint?: EventHint): PromiseLike; } //# sourceMappingURL=baseclient.d.ts.map