1 | import type { Breadcrumb, BreadcrumbHint, Client, ClientOptions, DataCategory, DsnComponents, DynamicSamplingContext, Envelope, Event, EventDropReason, EventHint, EventProcessor, FeedbackEvent, Integration, IntegrationClass, MetricBucketItem, MetricsAggregator, Outcome, ParameterizedString, SdkMetadata, Session, SessionAggregates, Severity, SeverityLevel, StartSpanOptions, Transaction, Transport, TransportMakeRequestResponse } from '@sentry/types';
|
2 | import type { IntegrationIndex } from './integration';
|
3 | import type { Scope } from './scope';
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 | export declare abstract class BaseClient<O extends ClientOptions> implements Client<O> {
|
36 | |
37 |
|
38 |
|
39 |
|
40 |
|
41 | metricsAggregator?: MetricsAggregator;
|
42 |
|
43 | protected readonly _options: O;
|
44 |
|
45 | protected readonly _dsn?: DsnComponents;
|
46 | protected readonly _transport?: Transport;
|
47 |
|
48 | protected _integrations: IntegrationIndex;
|
49 |
|
50 | protected _integrationsInitialized: boolean;
|
51 |
|
52 | protected _numProcessing: number;
|
53 | protected _eventProcessors: EventProcessor[];
|
54 |
|
55 | private _outcomes;
|
56 | private _hooks;
|
57 | |
58 |
|
59 |
|
60 |
|
61 |
|
62 | protected constructor(options: O);
|
63 | /**
|
64 | * @inheritDoc
|
65 | */
|
66 | captureException(exception: any, hint?: EventHint, scope?: Scope): string | undefined;
|
67 | /**
|
68 | * @inheritDoc
|
69 | */
|
70 | captureMessage(message: ParameterizedString, level?: Severity | SeverityLevel, hint?: EventHint, scope?: Scope): string | undefined;
|
71 | /**
|
72 | * @inheritDoc
|
73 | */
|
74 | captureEvent(event: Event, hint?: EventHint, scope?: Scope): string | undefined;
|
75 | /**
|
76 | * @inheritDoc
|
77 | */
|
78 | captureSession(session: Session): void;
|
79 | /**
|
80 | * @inheritDoc
|
81 | */
|
82 | getDsn(): DsnComponents | undefined;
|
83 | /**
|
84 | * @inheritDoc
|
85 | */
|
86 | getOptions(): O;
|
87 | /**
|
88 | * @see SdkMetadata in @sentry/types
|
89 | *
|
90 | * @return The metadata of the SDK
|
91 | */
|
92 | getSdkMetadata(): SdkMetadata | undefined;
|
93 | /**
|
94 | * @inheritDoc
|
95 | */
|
96 | getTransport(): Transport | undefined;
|
97 | /**
|
98 | * @inheritDoc
|
99 | */
|
100 | flush(timeout?: number): PromiseLike<boolean>;
|
101 | /**
|
102 | * @inheritDoc
|
103 | */
|
104 | close(timeout?: number): PromiseLike<boolean>;
|
105 | /** Get all installed event processors. */
|
106 | getEventProcessors(): EventProcessor[];
|
107 | /** @inheritDoc */
|
108 | addEventProcessor(eventProcessor: EventProcessor): void;
|
109 | /**
|
110 | * This is an internal function to setup all integrations that should run on the client.
|
111 | * @deprecated Use `client.init()` instead.
|
112 | */
|
113 | setupIntegrations(forceInitialize?: boolean): void;
|
114 | /** @inheritdoc */
|
115 | init(): void;
|
116 | /**
|
117 | * Gets an installed integration by its `id`.
|
118 | *
|
119 | * @returns The installed integration or `undefined` if no integration with that `id` was installed.
|
120 | * @deprecated Use `getIntegrationByName()` instead.
|
121 | */
|
122 | getIntegrationById(integrationId: string): Integration | undefined;
|
123 | /**
|
124 | * Gets an installed integration by its name.
|
125 | *
|
126 | * @returns The installed integration or `undefined` if no integration with that `name` was installed.
|
127 | */
|
128 | getIntegrationByName<T extends Integration = Integration>(integrationName: string): T | undefined;
|
129 | /**
|
130 | * Returns the client's instance of the given integration class, it any.
|
131 | * @deprecated Use `getIntegrationByName()` instead.
|
132 | */
|
133 | getIntegration<T extends Integration>(integration: IntegrationClass<T>): T | null;
|
134 | /**
|
135 | * @inheritDoc
|
136 | */
|
137 | addIntegration(integration: Integration): void;
|
138 | /**
|
139 | * @inheritDoc
|
140 | */
|
141 | sendEvent(event: Event, hint?: EventHint): void;
|
142 | /**
|
143 | * @inheritDoc
|
144 | */
|
145 | sendSession(session: Session | SessionAggregates): void;
|
146 | /**
|
147 | * @inheritDoc
|
148 | */
|
149 | recordDroppedEvent(reason: EventDropReason, category: DataCategory, _event?: Event): void;
|
150 | /**
|
151 | * @inheritDoc
|
152 | */
|
153 | captureAggregateMetrics(metricBucketItems: Array<MetricBucketItem>): void;
|
154 | /** @inheritdoc */
|
155 | on(hook: 'startTransaction', callback: (transaction: Transaction) => void): void;
|
156 | /** @inheritdoc */
|
157 | on(hook: 'finishTransaction', callback: (transaction: Transaction) => void): void;
|
158 | /** @inheritdoc */
|
159 | on(hook: 'beforeEnvelope', callback: (envelope: Envelope) => void): void;
|
160 | /** @inheritdoc */
|
161 | on(hook: 'beforeSendEvent', callback: (event: Event, hint?: EventHint) => void): void;
|
162 | /** @inheritdoc */
|
163 | on(hook: 'preprocessEvent', callback: (event: Event, hint?: EventHint) => void): void;
|
164 | /** @inheritdoc */
|
165 | on(hook: 'afterSendEvent', callback: (event: Event, sendResponse: TransportMakeRequestResponse | void) => void): void;
|
166 | /** @inheritdoc */
|
167 | on(hook: 'beforeAddBreadcrumb', callback: (breadcrumb: Breadcrumb, hint?: BreadcrumbHint) => void): void;
|
168 | /** @inheritdoc */
|
169 | on(hook: 'createDsc', callback: (dsc: DynamicSamplingContext) => void): void;
|
170 | /** @inheritdoc */
|
171 | on(hook: 'otelSpanEnd', callback: (otelSpan: unknown, mutableOptions: {
|
172 | drop: boolean;
|
173 | }) => void): void;
|
174 | /** @inheritdoc */
|
175 | on(hook: 'beforeSendFeedback', callback: (feedback: FeedbackEvent, options?: {
|
176 | includeReplay: boolean;
|
177 | }) => void): void;
|
178 | /** @inheritdoc */
|
179 | on(hook: 'startPageLoadSpan', callback: (options: StartSpanOptions) => void): void;
|
180 | /** @inheritdoc */
|
181 | on(hook: 'startNavigationSpan', callback: (options: StartSpanOptions) => void): void;
|
182 | /** @inheritdoc */
|
183 | emit(hook: 'startTransaction', transaction: Transaction): void;
|
184 | /** @inheritdoc */
|
185 | emit(hook: 'finishTransaction', transaction: Transaction): void;
|
186 | /** @inheritdoc */
|
187 | emit(hook: 'beforeEnvelope', envelope: Envelope): void;
|
188 | /** @inheritdoc */
|
189 | emit(hook: 'beforeSendEvent', event: Event, hint?: EventHint): void;
|
190 | /** @inheritdoc */
|
191 | emit(hook: 'preprocessEvent', event: Event, hint?: EventHint): void;
|
192 | /** @inheritdoc */
|
193 | emit(hook: 'afterSendEvent', event: Event, sendResponse: TransportMakeRequestResponse | void): void;
|
194 | /** @inheritdoc */
|
195 | emit(hook: 'beforeAddBreadcrumb', breadcrumb: Breadcrumb, hint?: BreadcrumbHint): void;
|
196 | /** @inheritdoc */
|
197 | emit(hook: 'createDsc', dsc: DynamicSamplingContext): void;
|
198 | /** @inheritdoc */
|
199 | emit(hook: 'otelSpanEnd', otelSpan: unknown, mutableOptions: {
|
200 | drop: boolean;
|
201 | }): void;
|
202 | /** @inheritdoc */
|
203 | emit(hook: 'beforeSendFeedback', feedback: FeedbackEvent, options?: {
|
204 | includeReplay: boolean;
|
205 | }): void;
|
206 | /** @inheritdoc */
|
207 | emit(hook: 'startPageLoadSpan', options: StartSpanOptions): void;
|
208 | /** @inheritdoc */
|
209 | emit(hook: 'startNavigationSpan', options: StartSpanOptions): void;
|
210 | /** Setup integrations for this client. */
|
211 | protected _setupIntegrations(): void;
|
212 | /** Updates existing session based on the provided event */
|
213 | protected _updateSessionFromEvent(session: Session, event: Event): void;
|
214 | /**
|
215 | * Determine if the client is finished processing. Returns a promise because it will wait `timeout` ms before saying
|
216 | * "no" (resolving to `false`) in order to give the client a chance to potentially finish first.
|
217 | *
|
218 | * @param timeout The time, in ms, after which to resolve to `false` if the client is still busy. Passing `0` (or not
|
219 | * passing anything) will make the promise wait as long as it takes for processing to finish before resolving to
|
220 | * `true`.
|
221 | * @returns A promise which will resolve to `true` if processing is already done or finishes before the timeout, and
|
222 | * `false` otherwise
|
223 | */
|
224 | protected _isClientDoneProcessing(timeout?: number): PromiseLike<boolean>;
|
225 | /** Determines whether this SDK is enabled and a transport is present. */
|
226 | protected _isEnabled(): boolean;
|
227 | /**
|
228 | * Adds common information to events.
|
229 | *
|
230 | * The information includes release and environment from `options`,
|
231 | * breadcrumbs and context (extra, tags and user) from the scope.
|
232 | *
|
233 | * Information that is already present in the event is never overwritten. For
|
234 | * nested objects, such as the context, keys are merged.
|
235 | *
|
236 | * @param event The original event.
|
237 | * @param hint May contain additional information about the original exception.
|
238 | * @param scope A scope containing event metadata.
|
239 | * @returns A new event with more information.
|
240 | */
|
241 | protected _prepareEvent(event: Event, hint: EventHint, scope?: Scope, isolationScope?: Scope): PromiseLike<Event | null>;
|
242 | /**
|
243 | * Processes the event and logs an error in case of rejection
|
244 | * @param event
|
245 | * @param hint
|
246 | * @param scope
|
247 | */
|
248 | protected _captureEvent(event: Event, hint?: EventHint, scope?: Scope): PromiseLike<string | undefined>;
|
249 | /**
|
250 | * Processes an event (either error or message) and sends it to Sentry.
|
251 | *
|
252 | * This also adds breadcrumbs and context information to the event. However,
|
253 | * platform specific meta data (such as the User's IP address) must be added
|
254 | * by the SDK implementor.
|
255 | *
|
256 | *
|
257 | * @param event The event to send to Sentry.
|
258 | * @param hint May contain additional information about the original exception.
|
259 | * @param scope A scope containing event metadata.
|
260 | * @returns A SyncPromise that resolves with the event or rejects in case event was/will not be send.
|
261 | */
|
262 | protected _processEvent(event: Event, hint: EventHint, scope?: Scope): PromiseLike<Event>;
|
263 | /**
|
264 | * Occupies the client with processing and event
|
265 | */
|
266 | protected _process<T>(promise: PromiseLike<T>): void;
|
267 | /**
|
268 | * @inheritdoc
|
269 | */
|
270 | protected _sendEnvelope(envelope: Envelope): PromiseLike<void | TransportMakeRequestResponse> | void;
|
271 | /**
|
272 | * Clears outcomes on this client and returns them.
|
273 | */
|
274 | protected _clearOutcomes(): Outcome[];
|
275 | /**
|
276 | * @inheritDoc
|
277 | */
|
278 | abstract eventFromException(_exception: any, _hint?: EventHint): PromiseLike<Event>;
|
279 | /**
|
280 | * @inheritDoc
|
281 | */
|
282 | abstract eventFromMessage(_message: ParameterizedString, _level?: Severity | SeverityLevel, _hint?: EventHint): PromiseLike<Event>;
|
283 | }
|
284 | /**
|
285 | * Add an event processor to the current client.
|
286 | * This event processor will run for all events processed by this client.
|
287 | */
|
288 | export declare function addEventProcessor(callback: EventProcessor): void;
|
289 | //# sourceMappingURL=baseclient.d.ts.map |
\ | No newline at end of file |