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 { EventProcessor } from './eventprocessor';
|
9 | import type { FeedbackEvent } from './feedback';
|
10 | import type { Integration } from './integration';
|
11 | import type { ClientOptions } from './options';
|
12 | import type { ParameterizedString } from './parameterize';
|
13 | import type { Scope } from './scope';
|
14 | import type { SdkMetadata } from './sdkmetadata';
|
15 | import type { Session, SessionAggregates } from './session';
|
16 | import type { SeverityLevel } from './severity';
|
17 | import type { Span, SpanAttributes, SpanContextData } from './span';
|
18 | import type { StartSpanOptions } from './startSpanOptions';
|
19 | import type { Transport, TransportMakeRequestResponse } from './transport';
|
20 | /**
|
21 | * User-Facing Sentry SDK Client.
|
22 | *
|
23 | * This interface contains all methods to interface with the SDK once it has
|
24 | * been installed. It allows to send events to Sentry, record breadcrumbs and
|
25 | * set a context included in every event. Since the SDK mutates its environment,
|
26 | * there will only be one instance during runtime.
|
27 | *
|
28 | */
|
29 | export interface Client<O extends ClientOptions = ClientOptions> {
|
30 | /**
|
31 | * Captures an exception event and sends it to Sentry.
|
32 | *
|
33 | * Unlike `captureException` exported from every SDK, this method requires that you pass it the current scope.
|
34 | *
|
35 | * @param exception An exception-like object.
|
36 | * @param hint May contain additional information about the original exception.
|
37 | * @param currentScope An optional scope containing event metadata.
|
38 | * @returns The event id
|
39 | */
|
40 | captureException(exception: any, hint?: EventHint, currentScope?: Scope): string;
|
41 | /**
|
42 | * Captures a message event and sends it to Sentry.
|
43 | *
|
44 | * Unlike `captureMessage` exported from every SDK, this method requires that you pass it the current scope.
|
45 | *
|
46 | * @param message The message to send to Sentry.
|
47 | * @param level Define the level of the message.
|
48 | * @param hint May contain additional information about the original exception.
|
49 | * @param currentScope An optional scope containing event metadata.
|
50 | * @returns The event id
|
51 | */
|
52 | captureMessage(message: string, level?: SeverityLevel, hint?: EventHint, currentScope?: Scope): string;
|
53 | /**
|
54 | * Captures a manually created event and sends it to Sentry.
|
55 | *
|
56 | * Unlike `captureEvent` exported from every SDK, this method requires that you pass it the current scope.
|
57 | *
|
58 | * @param event The event to send to Sentry.
|
59 | * @param hint May contain additional information about the original exception.
|
60 | * @param currentScope An optional scope containing event metadata.
|
61 | * @returns The event id
|
62 | */
|
63 | captureEvent(event: Event, hint?: EventHint, currentScope?: Scope): string;
|
64 | /**
|
65 | * Captures a session
|
66 | *
|
67 | * @param session Session to be delivered
|
68 | */
|
69 | captureSession(session: Session): void;
|
70 | /**
|
71 | * Create a cron monitor check in and send it to Sentry. This method is not available on all clients.
|
72 | *
|
73 | * @param checkIn An object that describes a check in.
|
74 | * @param upsertMonitorConfig An optional object that describes a monitor config. Use this if you want
|
75 | * to create a monitor automatically when sending a check in.
|
76 | * @param scope An optional scope containing event metadata.
|
77 | * @returns A string representing the id of the check in.
|
78 | */
|
79 | captureCheckIn?(checkIn: CheckIn, monitorConfig?: MonitorConfig, scope?: Scope): string;
|
80 | /** Returns the current Dsn. */
|
81 | getDsn(): DsnComponents | undefined;
|
82 | /** Returns the current options. */
|
83 | getOptions(): O;
|
84 | /**
|
85 | * @inheritdoc
|
86 | *
|
87 | */
|
88 | getSdkMetadata(): SdkMetadata | undefined;
|
89 | /**
|
90 | * Returns the transport that is used by the client.
|
91 | * Please note that the transport gets lazy initialized so it will only be there once the first event has been sent.
|
92 | *
|
93 | * @returns The transport.
|
94 | */
|
95 | getTransport(): Transport | undefined;
|
96 | /**
|
97 | * Flush the event queue and set the client to `enabled = false`. See {@link Client.flush}.
|
98 | *
|
99 | * @param timeout Maximum time in ms the client should wait before shutting down. Omitting this parameter will cause
|
100 | * the client to wait until all events are sent before disabling itself.
|
101 | * @returns A promise which resolves to `true` if the flush completes successfully before the timeout, or `false` if
|
102 | * it doesn't.
|
103 | */
|
104 | close(timeout?: number): PromiseLike<boolean>;
|
105 | /**
|
106 | * Wait for all events to be sent or the timeout to expire, whichever comes first.
|
107 | *
|
108 | * @param timeout Maximum time in ms the client should wait for events to be flushed. Omitting this parameter will
|
109 | * cause the client to wait until all events are sent before resolving the promise.
|
110 | * @returns A promise that will resolve with `true` if all events are sent before the timeout, or `false` if there are
|
111 | * still events in the queue when the timeout is reached.
|
112 | */
|
113 | flush(timeout?: number): PromiseLike<boolean>;
|
114 | /**
|
115 | * Adds an event processor that applies to any event processed by this client.
|
116 | */
|
117 | addEventProcessor(eventProcessor: EventProcessor): void;
|
118 | /**
|
119 | * Get all added event processors for this client.
|
120 | */
|
121 | getEventProcessors(): EventProcessor[];
|
122 | /** Get the instance of the integration with the given name on the client, if it was added. */
|
123 | getIntegrationByName<T extends Integration = Integration>(name: string): T | undefined;
|
124 | /**
|
125 | * Add an integration to the client.
|
126 | * This can be used to e.g. lazy load integrations.
|
127 | * In most cases, this should not be necessary, and you're better off just passing the integrations via `integrations: []` at initialization time.
|
128 | * However, if you find the need to conditionally load & add an integration, you can use `addIntegration` to do so.
|
129 | *
|
130 | * */
|
131 | addIntegration(integration: Integration): void;
|
132 | /**
|
133 | * Initialize this client.
|
134 | * Call this after the client was set on a scope.
|
135 | */
|
136 | init(): void;
|
137 | /** Creates an {@link Event} from all inputs to `captureException` and non-primitive inputs to `captureMessage`. */
|
138 | eventFromException(exception: any, hint?: EventHint): PromiseLike<Event>;
|
139 | /** Creates an {@link Event} from primitive inputs to `captureMessage`. */
|
140 | eventFromMessage(message: ParameterizedString, level?: SeverityLevel, hint?: EventHint): PromiseLike<Event>;
|
141 | /** Submits the event to Sentry */
|
142 | sendEvent(event: Event, hint?: EventHint): void;
|
143 | /** Submits the session to Sentry */
|
144 | sendSession(session: Session | SessionAggregates): void;
|
145 | /** Sends an envelope to Sentry */
|
146 | sendEnvelope(envelope: Envelope): PromiseLike<TransportMakeRequestResponse>;
|
147 | /**
|
148 | * Record on the client that an event got dropped (ie, an event that will not be sent to sentry).
|
149 | *
|
150 | * @param reason The reason why the event got dropped.
|
151 | * @param category The data category of the dropped event.
|
152 | * @param event The dropped event.
|
153 | */
|
154 | recordDroppedEvent(reason: EventDropReason, dataCategory: DataCategory, event?: Event): void;
|
155 | /**
|
156 | * Register a callback for whenever a span is started.
|
157 | * Receives the span as argument.
|
158 | * @returns A function that, when executed, removes the registered callback.
|
159 | */
|
160 | on(hook: 'spanStart', callback: (span: Span) => void): () => void;
|
161 | /**
|
162 | * Register a callback before span sampling runs. Receives a `samplingDecision` object argument with a `decision`
|
163 | * property that can be used to make a sampling decision that will be enforced, before any span sampling runs.
|
164 | * @returns A function that, when executed, removes the registered callback.
|
165 | */
|
166 | on(hook: 'beforeSampling', callback: (samplingData: {
|
167 | spanAttributes: SpanAttributes;
|
168 | spanName: string;
|
169 | parentSampled?: boolean;
|
170 | parentContext?: SpanContextData;
|
171 | }, samplingDecision: {
|
172 | decision: boolean;
|
173 | }) => void): void;
|
174 | /**
|
175 | * Register a callback for whenever a span is ended.
|
176 | * Receives the span as argument.
|
177 | * @returns A function that, when executed, removes the registered callback.
|
178 | */
|
179 | on(hook: 'spanEnd', callback: (span: Span) => void): () => void;
|
180 | /**
|
181 | * Register a callback for when an idle span is allowed to auto-finish.
|
182 | * @returns A function that, when executed, removes the registered callback.
|
183 | */
|
184 | on(hook: 'idleSpanEnableAutoFinish', callback: (span: Span) => void): () => void;
|
185 | /**
|
186 | * Register a callback for transaction start and finish.
|
187 | * @returns A function that, when executed, removes the registered callback.
|
188 | */
|
189 | on(hook: 'beforeEnvelope', callback: (envelope: Envelope) => void): () => void;
|
190 | /**
|
191 | * Register a callback that runs when stack frame metadata should be applied to an event.
|
192 | * @returns A function that, when executed, removes the registered callback.
|
193 | */
|
194 | on(hook: 'applyFrameMetadata', callback: (event: Event) => void): () => void;
|
195 | /**
|
196 | * Register a callback for before sending an event.
|
197 | * This is called right before an event is sent and should not be used to mutate the event.
|
198 | * Receives an Event & EventHint as arguments.
|
199 | * @returns A function that, when executed, removes the registered callback.
|
200 | */
|
201 | on(hook: 'beforeSendEvent', callback: (event: Event, hint?: EventHint | undefined) => void): () => void;
|
202 | /**
|
203 | * Register a callback for preprocessing an event,
|
204 | * before it is passed to (global) event processors.
|
205 | * Receives an Event & EventHint as arguments.
|
206 | * @returns A function that, when executed, removes the registered callback.
|
207 | */
|
208 | on(hook: 'preprocessEvent', callback: (event: Event, hint?: EventHint | undefined) => void): () => void;
|
209 | /**
|
210 | * Register a callback for when an event has been sent.
|
211 | * @returns A function that, when executed, removes the registered callback.
|
212 | */
|
213 | on(hook: 'afterSendEvent', callback: (event: Event, sendResponse: TransportMakeRequestResponse) => void): () => void;
|
214 | /**
|
215 | * Register a callback before a breadcrumb is added.
|
216 | * @returns A function that, when executed, removes the registered callback.
|
217 | */
|
218 | on(hook: 'beforeAddBreadcrumb', callback: (breadcrumb: Breadcrumb, hint?: BreadcrumbHint) => void): () => void;
|
219 | /**
|
220 | * Register a callback when a DSC (Dynamic Sampling Context) is created.
|
221 | * @returns A function that, when executed, removes the registered callback.
|
222 | */
|
223 | on(hook: 'createDsc', callback: (dsc: DynamicSamplingContext, rootSpan?: Span) => void): () => void;
|
224 | /**
|
225 | * Register a callback when a Feedback event has been prepared.
|
226 | * This should be used to mutate the event. The options argument can hint
|
227 | * about what kind of mutation it expects.
|
228 | * @returns A function that, when executed, removes the registered callback.
|
229 | */
|
230 | on(hook: 'beforeSendFeedback', callback: (feedback: FeedbackEvent, options?: {
|
231 | includeReplay?: boolean;
|
232 | }) => void): () => void;
|
233 | /**
|
234 | * A hook for the browser tracing integrations to trigger a span start for a page load.
|
235 | * @returns A function that, when executed, removes the registered callback.
|
236 | */
|
237 | on(hook: 'startPageLoadSpan', callback: (options: StartSpanOptions, traceOptions?: {
|
238 | sentryTrace?: string | undefined;
|
239 | baggage?: string | undefined;
|
240 | }) => void): () => void;
|
241 | /**
|
242 | * A hook for browser tracing integrations to trigger a span for a navigation.
|
243 | * @returns A function that, when executed, removes the registered callback.
|
244 | */
|
245 | on(hook: 'startNavigationSpan', callback: (options: StartSpanOptions) => void): () => void;
|
246 | /**
|
247 | * A hook that is called when the client is flushing
|
248 | * @returns A function that, when executed, removes the registered callback.
|
249 | */
|
250 | on(hook: 'flush', callback: () => void): () => void;
|
251 | /**
|
252 | * A hook that is called when the client is closing
|
253 | * @returns A function that, when executed, removes the registered callback.
|
254 | */
|
255 | on(hook: 'close', callback: () => void): () => void;
|
256 | /** Fire a hook whener a span starts. */
|
257 | emit(hook: 'spanStart', span: Span): void;
|
258 | /** A hook that is called every time before a span is sampled. */
|
259 | emit(hook: 'beforeSampling', samplingData: {
|
260 | spanAttributes: SpanAttributes;
|
261 | spanName: string;
|
262 | parentSampled?: boolean;
|
263 | parentContext?: SpanContextData;
|
264 | }, samplingDecision: {
|
265 | decision: boolean;
|
266 | }): void;
|
267 | /** Fire a hook whener a span ends. */
|
268 | emit(hook: 'spanEnd', span: Span): void;
|
269 | /**
|
270 | * Fire a hook indicating that an idle span is allowed to auto finish.
|
271 | */
|
272 | emit(hook: 'idleSpanEnableAutoFinish', span: Span): void;
|
273 | emit(hook: 'beforeEnvelope', envelope: Envelope): void;
|
274 | emit(hook: 'applyFrameMetadata', event: Event): void;
|
275 | /**
|
276 | * Fire a hook event before sending an event.
|
277 | * This is called right before an event is sent and should not be used to mutate the event.
|
278 | * Expects to be given an Event & EventHint as the second/third argument.
|
279 | */
|
280 | emit(hook: 'beforeSendEvent', event: Event, hint?: EventHint): void;
|
281 | /**
|
282 | * Fire a hook event to process events before they are passed to (global) event processors.
|
283 | * Expects to be given an Event & EventHint as the second/third argument.
|
284 | */
|
285 | emit(hook: 'preprocessEvent', event: Event, hint?: EventHint): void;
|
286 | emit(hook: 'afterSendEvent', event: Event, sendResponse: TransportMakeRequestResponse): void;
|
287 | /**
|
288 | * Fire a hook for when a breadcrumb is added. Expects the breadcrumb as second argument.
|
289 | */
|
290 | emit(hook: 'beforeAddBreadcrumb', breadcrumb: Breadcrumb, hint?: BreadcrumbHint): void;
|
291 | /**
|
292 | * Fire a hook for when a DSC (Dynamic Sampling Context) is created. Expects the DSC as second argument.
|
293 | */
|
294 | emit(hook: 'createDsc', dsc: DynamicSamplingContext, rootSpan?: Span): void;
|
295 | /**
|
296 | * Fire a hook event for after preparing a feedback event. Events to be given
|
297 | * a feedback event as the second argument, and an optional options object as
|
298 | * third argument.
|
299 | */
|
300 | emit(hook: 'beforeSendFeedback', feedback: FeedbackEvent, options?: {
|
301 | includeReplay?: boolean;
|
302 | }): void;
|
303 | /**
|
304 | * Emit a hook event for browser tracing integrations to trigger a span start for a page load.
|
305 | */
|
306 | emit(hook: 'startPageLoadSpan', options: StartSpanOptions, traceOptions?: {
|
307 | sentryTrace?: string | undefined;
|
308 | baggage?: string | undefined;
|
309 | }): void;
|
310 | /**
|
311 | * Emit a hook event for browser tracing integrations to trigger a span for a navigation.
|
312 | */
|
313 | emit(hook: 'startNavigationSpan', options: StartSpanOptions): void;
|
314 | /**
|
315 | * Emit a hook event for client flush
|
316 | */
|
317 | emit(hook: 'flush'): void;
|
318 | /**
|
319 | * Emit a hook event for client close
|
320 | */
|
321 | emit(hook: 'close'): void;
|
322 | }
|
323 | //# sourceMappingURL=client.d.ts.map |
\ | No newline at end of file |