/
transport.ts
74 lines (67 loc) · 2.51 KB
/
transport.ts
1
2
3
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { DsnLike } from './dsn';
import { Event } from './event';
import { Response } from './response';
import { SdkMetadata } from './sdkmetadata';
import { Session, SessionAggregates } from './session';
export enum Outcome {
BeforeSend = 'before_send',
EventProcessor = 'event_processor',
NetworkError = 'network_error',
QueueSize = 'queue_size',
RateLimit = 'backoff', // NOTE(kamil): I'd prefer to call it `rate_limit` instead of `backoff`
SampleRate = 'sample_rate',
}
/** Transport used sending data to Sentry */
export interface Transport {
/**
* Sends the event to the Store endpoint in Sentry.
*
* @param event Event that should be sent to Sentry.
*/
sendEvent(event: Event): PromiseLike<Response>;
/**
* Sends the session to the Envelope endpoint in Sentry.
*
* @param session Session that should be sent to Sentry | Session Aggregates that should be sent to Sentry.
*/
sendSession?(session: Session | SessionAggregates): PromiseLike<Response>;
/**
* Wait for all events to be sent or the timeout to expire, whichever comes first.
*
* @param timeout Maximum time in ms the transport should wait for events to be flushed. Omitting this parameter will
* cause the transport to wait until all events are sent before resolving the promise.
* @returns A promise that will resolve with `true` if all events are sent before the timeout, or `false` if there are
* still events in the queue when the timeout is reached.
*/
close(timeout?: number): PromiseLike<boolean>;
/**
* Increment the counter for the specific client outcome
*/
recordLostEvent?(type: Outcome): void;
}
/** JSDoc */
export type TransportClass<T extends Transport> = new (options: TransportOptions) => T;
/** JSDoc */
export interface TransportOptions {
/** Sentry DSN */
dsn: DsnLike;
/** Define custom headers */
headers?: { [key: string]: string };
/** Set a HTTP proxy that should be used for outbound requests. */
httpProxy?: string;
/** Set a HTTPS proxy that should be used for outbound requests. */
httpsProxy?: string;
/** HTTPS proxy certificates path */
caCerts?: string;
/** Fetch API init parameters */
fetchParameters?: { [key: string]: string };
/** The envelope tunnel to use. */
tunnel?: string;
/** Automatically send SDK Client Report */
sendClientReport?: boolean;
/**
* Set of metadata about the SDK that can be internally used to enhance envelopes and events,
* and provide additional data about every request.
* */
_metadata?: SdkMetadata;
}