1 | import type { Breadcrumb, BreadcrumbHint } from './breadcrumb';
|
2 | import type { CheckIn, MonitorConfig } from './checkin';
|
3 | import type { EventDropReason } from './clientreport';
|
4 | import type { DataCategory } from './datacategory';
|
5 | import type { DsnComponents } from './dsn';
|
6 | import type { DynamicSamplingContext, Envelope } from './envelope';
|
7 | import type { Event, EventHint } from './event';
|
8 | import type { Integration, IntegrationClass } from './integration';
|
9 | import type { ClientOptions } from './options';
|
10 | import type { Scope } from './scope';
|
11 | import type { SdkMetadata } from './sdkmetadata';
|
12 | import type { Session, SessionAggregates } from './session';
|
13 | import type { Severity, SeverityLevel } from './severity';
|
14 | import type { Transaction } from './transaction';
|
15 | import type { Transport, TransportMakeRequestResponse } from './transport';
|
16 | /**
|
17 | * User-Facing Sentry SDK Client.
|
18 | *
|
19 | * This interface contains all methods to interface with the SDK once it has
|
20 | * been installed. It allows to send events to Sentry, record breadcrumbs and
|
21 | * set a context included in every event. Since the SDK mutates its environment,
|
22 | * there will only be one instance during runtime.
|
23 | *
|
24 | */
|
25 | export interface Client<O extends ClientOptions = ClientOptions> {
|
26 | /**
|
27 | * Captures an exception event and sends it to Sentry.
|
28 | *
|
29 | * @param exception An exception-like object.
|
30 | * @param hint May contain additional information about the original exception.
|
31 | * @param scope An optional scope containing event metadata.
|
32 | * @returns The event id
|
33 | */
|
34 | captureException(exception: any, hint?: EventHint, scope?: Scope): string | undefined;
|
35 | /**
|
36 | * Captures a message event and sends it to Sentry.
|
37 | *
|
38 | * @param message The message to send to Sentry.
|
39 | * @param level Define the level of the message.
|
40 | * @param hint May contain additional information about the original exception.
|
41 | * @param scope An optional scope containing event metadata.
|
42 | * @returns The event id
|
43 | */
|
44 | captureMessage(message: string, level?: Severity | SeverityLevel, hint?: EventHint, scope?: Scope): string | undefined;
|
45 | /**
|
46 | * Captures a manually created event and sends it to Sentry.
|
47 | *
|
48 | * @param event The event to send to Sentry.
|
49 | * @param hint May contain additional information about the original exception.
|
50 | * @param scope An optional scope containing event metadata.
|
51 | * @returns The event id
|
52 | */
|
53 | captureEvent(event: Event, hint?: EventHint, scope?: Scope): string | undefined;
|
54 | /**
|
55 | * Captures a session
|
56 | *
|
57 | * @param session Session to be delivered
|
58 | */
|
59 | captureSession?(session: Session): void;
|
60 | /**
|
61 | * Create a cron monitor check in and send it to Sentry. This method is not available on all clients.
|
62 | *
|
63 | * @param checkIn An object that describes a check in.
|
64 | * @param upsertMonitorConfig An optional object that describes a monitor config. Use this if you want
|
65 | * to create a monitor automatically when sending a check in.
|
66 | * @returns A string representing the id of the check in.
|
67 | */
|
68 | captureCheckIn?(checkIn: CheckIn, monitorConfig?: MonitorConfig): string;
|
69 | /** Returns the current Dsn. */
|
70 | getDsn(): DsnComponents | undefined;
|
71 | /** Returns the current options. */
|
72 | getOptions(): O;
|
73 | /**
|
74 | * @inheritdoc
|
75 | *
|
76 | * TODO (v8): Make this a required method.
|
77 | */
|
78 | getSdkMetadata?(): SdkMetadata | undefined;
|
79 | /**
|
80 | * Returns the transport that is used by the client.
|
81 | * Please note that the transport gets lazy initialized so it will only be there once the first event has been sent.
|
82 | *
|
83 | * @returns The transport.
|
84 | */
|
85 | getTransport(): Transport | undefined;
|
86 | /**
|
87 | * Flush the event queue and set the client to `enabled = false`. See {@link Client.flush}.
|
88 | *
|
89 | * @param timeout Maximum time in ms the client should wait before shutting down. Omitting this parameter will cause
|
90 | * the client to wait until all events are sent before disabling itself.
|
91 | * @returns A promise which resolves to `true` if the flush completes successfully before the timeout, or `false` if
|
92 | * it doesn't.
|
93 | */
|
94 | close(timeout?: number): PromiseLike<boolean>;
|
95 | /**
|
96 | * Wait for all events to be sent or the timeout to expire, whichever comes first.
|
97 | *
|
98 | * @param timeout Maximum time in ms the client should wait for events to be flushed. Omitting this parameter will
|
99 | * cause the client to wait until all events are sent before resolving the promise.
|
100 | * @returns A promise that will resolve with `true` if all events are sent before the timeout, or `false` if there are
|
101 | * still events in the queue when the timeout is reached.
|
102 | */
|
103 | flush(timeout?: number): PromiseLike<boolean>;
|
104 | /** Returns the client's instance of the given integration class, it any. */
|
105 | getIntegration<T extends Integration>(integration: IntegrationClass<T>): T | null;
|
106 | /**
|
107 | * Add an integration to the client.
|
108 | * This can be used to e.g. lazy load integrations.
|
109 | * In most cases, this should not be necessary, and you're better off just passing the integrations via `integrations: []` at initialization time.
|
110 | * However, if you find the need to conditionally load & add an integration, you can use `addIntegration` to do so.
|
111 | *
|
112 | * TODO (v8): Make this a required method.
|
113 | * */
|
114 | addIntegration?(integration: Integration): void;
|
115 | /** This is an internal function to setup all integrations that should run on the client */
|
116 | setupIntegrations(): void;
|
117 | /** Creates an {@link Event} from all inputs to `captureException` and non-primitive inputs to `captureMessage`. */
|
118 | eventFromException(exception: any, hint?: EventHint): PromiseLike<Event>;
|
119 | /** Creates an {@link Event} from primitive inputs to `captureMessage`. */
|
120 | eventFromMessage(message: string, level?: Severity | SeverityLevel, hint?: EventHint): PromiseLike<Event>;
|
121 | /** Submits the event to Sentry */
|
122 | sendEvent(event: Event, hint?: EventHint): void;
|
123 | /** Submits the session to Sentry */
|
124 | sendSession(session: Session | SessionAggregates): void;
|
125 | /**
|
126 | * Record on the client that an event got dropped (ie, an event that will not be sent to sentry).
|
127 | *
|
128 | * @param reason The reason why the event got dropped.
|
129 | * @param category The data category of the dropped event.
|
130 | * @param event The dropped event.
|
131 | */
|
132 | recordDroppedEvent(reason: EventDropReason, dataCategory: DataCategory, event?: Event): void;
|
133 | /**
|
134 | * Register a callback for transaction start and finish.
|
135 | */
|
136 | on?(hook: 'startTransaction' | 'finishTransaction', callback: (transaction: Transaction) => void): void;
|
137 | /**
|
138 | * Register a callback for transaction start and finish.
|
139 | */
|
140 | on?(hook: 'beforeEnvelope', callback: (envelope: Envelope) => void): void;
|
141 | /**
|
142 | * Register a callback for when an event has been sent.
|
143 | */
|
144 | on?(hook: 'afterSendEvent', callback: (event: Event, sendResponse: TransportMakeRequestResponse | void) => void): void;
|
145 | /**
|
146 | * Register a callback before a breadcrumb is added.
|
147 | */
|
148 | on?(hook: 'beforeAddBreadcrumb', callback: (breadcrumb: Breadcrumb, hint?: BreadcrumbHint) => void): void;
|
149 | /**
|
150 | * Register a callback whena DSC (Dynamic Sampling Context) is created.
|
151 | */
|
152 | on?(hook: 'createDsc', callback: (dsc: DynamicSamplingContext) => void): void;
|
153 | /**
|
154 | * Fire a hook event for transaction start and finish. Expects to be given a transaction as the
|
155 | * second argument.
|
156 | */
|
157 | emit?(hook: 'startTransaction' | 'finishTransaction', transaction: Transaction): void;
|
158 | emit?(hook: 'beforeEnvelope', envelope: Envelope): void;
|
159 | emit?(hook: 'afterSendEvent', event: Event, sendResponse: TransportMakeRequestResponse | void): void;
|
160 | /**
|
161 | * Fire a hook for when a breadcrumb is added. Expects the breadcrumb as second argument.
|
162 | */
|
163 | emit?(hook: 'beforeAddBreadcrumb', breadcrumb: Breadcrumb, hint?: BreadcrumbHint): void;
|
164 | /**
|
165 | * Fire a hook for when a DSC (Dynamic Sampling Context) is created. Expects the DSC as second argument.
|
166 | */
|
167 | emit?(hook: 'createDsc', dsc: DynamicSamplingContext): void;
|
168 | }
|
169 | //# sourceMappingURL=client.d.ts.map |
\ | No newline at end of file |