UNPKG

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