Skip to content

Commit 28f229b

Browse files
committed
adjust setupNodeTransport for new transport
1 parent 05ab35b commit 28f229b

File tree

5 files changed

+15
-37
lines changed

5 files changed

+15
-37
lines changed

packages/core/src/index.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
export type { APIDetails } from './api';
22
export type { ClientClass } from './sdk';
3-
export type {
4-
BaseTransportOptions,
5-
NewTransport,
6-
TransportMakeRequestResponse,
7-
TransportRequest,
8-
TransportRequestExecutor,
9-
} from './transports/base';
103

114
export {
125
addBreadcrumb,

packages/node/src/sdk.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ export function init(options: NodeOptions = {}): void {
131131
setHubOnCarrier(carrier, getCurrentHub());
132132
}
133133

134-
const { transport, newTransport } = setupNodeTransport(options);
135-
initAndBind(NodeClient, options, transport, newTransport);
134+
const { transport } = setupNodeTransport(options);
135+
initAndBind(NodeClient, options, transport);
136136

137137
if (options.autoSessionTracking) {
138138
startSessionTracking();

packages/node/src/transports/new.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import { createTransport } from '@sentry/core';
12
import {
23
BaseTransportOptions,
3-
createTransport,
44
NewTransport,
55
TransportMakeRequestResponse,
66
TransportRequest,
77
TransportRequestExecutor,
8-
} from '@sentry/core';
8+
} from '@sentry/types';
99
import { eventStatusFromHttpCode } from '@sentry/utils';
1010
import * as http from 'http';
1111
import * as https from 'https';

packages/node/src/transports/setup.ts

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,37 @@
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';
33
import { makeDsn } from '@sentry/utils';
44

55
import { NodeOptions } from '../types';
6-
import { HTTPSTransport, HTTPTransport, makeNodeTransport } from '.';
6+
import { makeNodeTransport } from './new';
77

88
/**
99
* 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`.
1410
*/
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 {
2412
const transportOptions: TransportOptions = {
2513
...options.transportOptions,
2614
...(options.httpProxy && { httpProxy: options.httpProxy }),
2715
...(options.httpsProxy && { httpsProxy: options.httpsProxy }),
2816
...(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),
3020
tunnel: options.tunnel,
3121
_metadata: options._metadata,
3222
};
3323

3424
if (options.transport) {
35-
return { transport: new options.transport(transportOptions) };
25+
return options.transport;
3626
}
3727

3828
const api = initAPIDetails(transportOptions.dsn, transportOptions._metadata, transportOptions.tunnel);
3929
const url = getEnvelopeEndpointWithUrlEncodedAuth(api.dsn, api.tunnel);
4030

41-
const newTransport = makeNodeTransport({
31+
return makeNodeTransport({
4232
url,
4333
headers: transportOptions.headers,
4434
proxy: transportOptions.httpProxy,
4535
caCerts: transportOptions.caCerts,
4636
});
47-
48-
if (dsn.protocol === 'http') {
49-
return { transport: new HTTPTransport(transportOptions), newTransport };
50-
}
51-
return { transport: new HTTPSTransport(transportOptions), newTransport };
5237
}

packages/types/src/options.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { CaptureContext } from './scope';
55
import { SdkMetadata } from './sdkmetadata';
66
import { StackLineParser, StackParser } from './stacktrace';
77
import { SamplingContext } from './transaction';
8-
import { Transport, TransportClass, TransportOptions } from './transport';
8+
import { NewTransport, TransportOptions } from './transport';
99

1010
/** Base configuration options for every SDK. */
1111
export interface Options {
@@ -49,7 +49,7 @@ export interface Options {
4949
/**
5050
* Transport object that should be used to send events to Sentry
5151
*/
52-
transport?: TransportClass<Transport>;
52+
transport?: NewTransport;
5353

5454
/**
5555
* Options for the default transport that the SDK uses.

0 commit comments

Comments
 (0)