Skip to content

Commit 9ed4b27

Browse files
committed
move types to types
1 parent 5bbcc5c commit 9ed4b27

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

packages/types/src/index.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,19 @@ export type {
6262
TransactionSamplingMethod,
6363
} from './transaction';
6464
export type { Thread } from './thread';
65-
export type { Outcome, Transport, TransportOptions, TransportClass } from './transport';
65+
export type {
66+
Outcome,
67+
Transport,
68+
TransportOptions,
69+
TransportClass,
70+
TransportCategory,
71+
TransportRequest,
72+
TransportMakeRequestResponse,
73+
TransportResponse,
74+
InternalBaseTransportOptions,
75+
BaseTransportOptions,
76+
NewTransport,
77+
TransportRequestExecutor,
78+
} from './transport';
6679
export type { User, UserFeedback } from './user';
6780
export type { WrappedFunction } from './wrappedfunction';

packages/types/src/transport.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { DsnLike } from './dsn';
2+
import { Envelope } from './envelope';
23
import { Event } from './event';
4+
import { EventStatus } from './eventstatus';
35
import { SentryRequestType } from './request';
46
import { Response } from './response';
57
import { SdkMetadata } from './sdkmetadata';
@@ -13,6 +15,46 @@ export type Outcome =
1315
| 'ratelimit_backoff'
1416
| 'sample_rate';
1517

18+
export type TransportCategory = 'error' | 'transaction' | 'attachment' | 'session';
19+
20+
export type TransportRequest = {
21+
body: string;
22+
category: TransportCategory;
23+
};
24+
25+
export type TransportMakeRequestResponse = {
26+
body?: string;
27+
headers?: {
28+
[key: string]: string | null;
29+
'x-sentry-rate-limits': string | null;
30+
'retry-after': string | null;
31+
};
32+
reason?: string;
33+
statusCode: number;
34+
};
35+
36+
export type TransportResponse = {
37+
status: EventStatus;
38+
reason?: string;
39+
};
40+
41+
export interface InternalBaseTransportOptions {
42+
bufferSize?: number;
43+
}
44+
export interface BaseTransportOptions extends InternalBaseTransportOptions {
45+
// url to send the event
46+
// transport does not care about dsn specific - client should take care of
47+
// parsing and figuring that out
48+
url: string;
49+
}
50+
51+
export interface NewTransport {
52+
send(request: Envelope): PromiseLike<TransportResponse>;
53+
flush(timeout?: number): PromiseLike<boolean>;
54+
}
55+
56+
export type TransportRequestExecutor = (request: TransportRequest) => PromiseLike<TransportMakeRequestResponse>;
57+
1658
/** Transport used sending data to Sentry */
1759
export interface Transport {
1860
/**

0 commit comments

Comments
 (0)