|
1 |
| -import { getEnvelopeEndpointWithUrlEncodedAuth, initAPIDetails, NewTransport, NoopTransport } from '@sentry/core'; |
2 |
| -import { Transport, TransportOptions } from '@sentry/types'; |
| 1 | +import { getEnvelopeEndpointWithUrlEncodedAuth, initAPIDetails } from '@sentry/core'; |
| 2 | +import { NewTransport, TransportOptions } from '@sentry/types'; |
3 | 3 | import { makeDsn } from '@sentry/utils';
|
4 | 4 |
|
5 | 5 | import { NodeOptions } from '../types';
|
6 |
| -import { HTTPSTransport, HTTPTransport, makeNodeTransport } from '.'; |
| 6 | +import { makeNodeTransport } from './new'; |
7 | 7 |
|
8 | 8 | /**
|
9 | 9 | * Sets up Node transport based on the passed `options`.
|
10 |
| - * |
11 |
| - * @returns an object currently still containing both, the old `Transport` and |
12 |
| - * `NewTransport` which will eventually replace `Transport`. Once this is replaced, |
13 |
| - * this function will return a ready to use `NewTransport`. |
14 | 10 | */
|
15 |
| -// TODO(v7): Adjust return value when NewTransport is the default |
16 |
| -export function setupNodeTransport(options: NodeOptions): { transport: Transport; newTransport?: NewTransport } { |
17 |
| - if (!options.dsn) { |
18 |
| - // We return the noop transport here in case there is no Dsn. |
19 |
| - return { transport: new NoopTransport() }; |
20 |
| - } |
21 |
| - |
22 |
| - const dsn = makeDsn(options.dsn); |
23 |
| - |
| 11 | +export function setupNodeTransport(options: NodeOptions): NewTransport { |
24 | 12 | const transportOptions: TransportOptions = {
|
25 | 13 | ...options.transportOptions,
|
26 | 14 | ...(options.httpProxy && { httpProxy: options.httpProxy }),
|
27 | 15 | ...(options.httpsProxy && { httpsProxy: options.httpsProxy }),
|
28 | 16 | ...(options.caCerts && { caCerts: options.caCerts }),
|
29 |
| - dsn: options.dsn, |
| 17 | + // @ts-ignore Come back to this |
| 18 | + // TODO(v7): Figure out how to enforce dsn |
| 19 | + dsn: options.dsn === undefined ? undefined : makeDsn(options.dsn), |
30 | 20 | tunnel: options.tunnel,
|
31 | 21 | _metadata: options._metadata,
|
32 | 22 | };
|
33 | 23 |
|
34 | 24 | if (options.transport) {
|
35 |
| - return { transport: new options.transport(transportOptions) }; |
| 25 | + return options.transport; |
36 | 26 | }
|
37 | 27 |
|
38 | 28 | const api = initAPIDetails(transportOptions.dsn, transportOptions._metadata, transportOptions.tunnel);
|
39 | 29 | const url = getEnvelopeEndpointWithUrlEncodedAuth(api.dsn, api.tunnel);
|
40 | 30 |
|
41 |
| - const newTransport = makeNodeTransport({ |
| 31 | + return makeNodeTransport({ |
42 | 32 | url,
|
43 | 33 | headers: transportOptions.headers,
|
44 | 34 | proxy: transportOptions.httpProxy,
|
45 | 35 | caCerts: transportOptions.caCerts,
|
46 | 36 | });
|
47 |
| - |
48 |
| - if (dsn.protocol === 'http') { |
49 |
| - return { transport: new HTTPTransport(transportOptions), newTransport }; |
50 |
| - } |
51 |
| - return { transport: new HTTPSTransport(transportOptions), newTransport }; |
52 | 37 | }
|
0 commit comments