UNPKG

3.59 kBTypeScriptView Raw
1import { Dsn } from './dsn';
2import { Event, EventHint } from './event';
3import { Integration, IntegrationClass } from './integration';
4import { Options } from './options';
5import { Scope } from './scope';
6import { Session } from './session';
7import { Severity } from './severity';
8/**
9 * User-Facing Sentry SDK Client.
10 *
11 * This interface contains all methods to interface with the SDK once it has
12 * been installed. It allows to send events to Sentry, record breadcrumbs and
13 * set a context included in every event. Since the SDK mutates its environment,
14 * there will only be one instance during runtime.
15 *
16 */
17export interface Client<O extends Options = Options> {
18 /**
19 * Captures an exception event and sends it to Sentry.
20 *
21 * @param exception An exception-like object.
22 * @param hint May contain additional information about the original exception.
23 * @param scope An optional scope containing event metadata.
24 * @returns The event id
25 */
26 captureException(exception: any, hint?: EventHint, scope?: Scope): string | undefined;
27 /**
28 * Captures a message event and sends it to Sentry.
29 *
30 * @param message The message to send to Sentry.
31 * @param level Define the level of the message.
32 * @param hint May contain additional information about the original exception.
33 * @param scope An optional scope containing event metadata.
34 * @returns The event id
35 */
36 captureMessage(message: string, level?: Severity, hint?: EventHint, scope?: Scope): string | undefined;
37 /**
38 * Captures a manually created event and sends it to Sentry.
39 *
40 * @param event The event to send to Sentry.
41 * @param hint May contain additional information about the original exception.
42 * @param scope An optional scope containing event metadata.
43 * @returns The event id
44 */
45 captureEvent(event: Event, hint?: EventHint, scope?: Scope): string | undefined;
46 /** Captures a session
47 *
48 * @param session Session to be delivered
49 */
50 captureSession?(session: Session): void;
51 /** Returns the current Dsn. */
52 getDsn(): Dsn | undefined;
53 /** Returns the current options. */
54 getOptions(): O;
55 /**
56 * Flush the event queue and set the client to `enabled = false`. See {@link Client.flush}.
57 *
58 * @param timeout Maximum time in ms the client should wait before shutting down. Omitting this parameter will cause
59 * the client to wait until all events are sent before disabling itself.
60 * @returns A promise which resolves to `true` if the flush completes successfully before the timeout, or `false` if
61 * it doesn't.
62 */
63 close(timeout?: number): PromiseLike<boolean>;
64 /**
65 * Wait for all events to be sent or the timeout to expire, whichever comes first.
66 *
67 * @param timeout Maximum time in ms the client should wait for events to be flushed. Omitting this parameter will
68 * cause the client to wait until all events are sent before resolving the promise.
69 * @returns A promise that will resolve with `true` if all events are sent before the timeout, or `false` if there are
70 * still events in the queue when the timeout is reached.
71 */
72 flush(timeout?: number): PromiseLike<boolean>;
73 /** Returns an array of installed integrations on the client. */
74 getIntegration<T extends Integration>(integration: IntegrationClass<T>): T | null;
75 /** This is an internal function to setup all integrations that should run on the client */
76 setupIntegrations(): void;
77}
78//# sourceMappingURL=client.d.ts.map
\No newline at end of file