Skip to content

Commit e64dd94

Browse files
committed
adjust transport constructors
1 parent 28f229b commit e64dd94

File tree

6 files changed

+14
-47
lines changed

6 files changed

+14
-47
lines changed

packages/browser/src/sdk.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ export function init(options: BrowserOptions = {}): void {
9898
options.stackParser = defaultStackParsers;
9999
}
100100

101-
const { transport, newTransport } = setupBrowserTransport(options);
102-
initAndBind(BrowserClient, options, transport, newTransport);
101+
initAndBind(BrowserClient, options, setupBrowserTransport(options));
103102

104103
if (options.autoSessionTracking) {
105104
startSessionTracking();

packages/browser/src/transports/new-fetch.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
import {
2-
BaseTransportOptions,
3-
createTransport,
4-
NewTransport,
5-
TransportMakeRequestResponse,
6-
TransportRequest,
7-
} from '@sentry/core';
1+
import { BaseTransportOptions, NewTransport, TransportMakeRequestResponse, TransportRequest } from '@sentry/types';
2+
import { createTransport } from '@sentry/core';
83

94
import { FetchImpl, getNativeFetchImplementation } from './utils';
105

packages/browser/src/transports/new-xhr.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
import {
2-
BaseTransportOptions,
3-
createTransport,
4-
NewTransport,
5-
TransportMakeRequestResponse,
6-
TransportRequest,
7-
} from '@sentry/core';
1+
import { createTransport } from '@sentry/core';
2+
import { BaseTransportOptions, NewTransport, TransportMakeRequestResponse, TransportRequest } from '@sentry/types';
83
import { SyncPromise } from '@sentry/utils';
94

105
/**
Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
1-
import {
2-
BaseTransportOptions,
3-
getEnvelopeEndpointWithUrlEncodedAuth,
4-
initAPIDetails,
5-
NewTransport,
6-
NoopTransport,
7-
} from '@sentry/core';
8-
import { Transport, TransportOptions } from '@sentry/types';
1+
import { getEnvelopeEndpointWithUrlEncodedAuth, initAPIDetails } from '@sentry/core';
2+
import { BaseTransportOptions, NewTransport, TransportOptions } from '@sentry/types';
93
import { supportsFetch } from '@sentry/utils';
104

115
import { BrowserOptions } from '../client';
12-
import { FetchTransport } from './fetch';
136
import { makeNewFetchTransport } from './new-fetch';
147
import { makeNewXHRTransport } from './new-xhr';
15-
import { XHRTransport } from './xhr';
168

179
export interface BrowserTransportOptions extends BaseTransportOptions {
1810
// options to pass into fetch request
@@ -25,20 +17,11 @@ export interface BrowserTransportOptions extends BaseTransportOptions {
2517
* Sets up Browser transports based on the passed `options`. If available, the returned
2618
* transport will use the fetch API. In case fetch is not supported, an XMLHttpRequest
2719
* based transport is created.
28-
*
29-
* @returns an object currently still containing both, the old `Transport` and
30-
* `NewTransport` which will eventually replace `Transport`. Once this is replaced,
31-
* this function will return a ready to use `NewTransport`.
3220
*/
33-
// TODO(v7): Adjust return value when NewTransport is the default
34-
export function setupBrowserTransport(options: BrowserOptions): { transport: Transport; newTransport?: NewTransport } {
35-
if (!options.dsn) {
36-
// We return the noop transport here in case there is no Dsn.
37-
return { transport: new NoopTransport() };
38-
}
39-
21+
export function setupBrowserTransport(options: BrowserOptions): NewTransport {
4022
const transportOptions: TransportOptions = {
4123
...options.transportOptions,
24+
// @ts-ignore figure out dsn stuff
4225
dsn: options.dsn,
4326
tunnel: options.tunnel,
4427
sendClientReports: options.sendClientReports,
@@ -49,20 +32,16 @@ export function setupBrowserTransport(options: BrowserOptions): { transport: Tra
4932
const url = getEnvelopeEndpointWithUrlEncodedAuth(api.dsn, api.tunnel);
5033

5134
if (options.transport) {
52-
return { transport: new options.transport(transportOptions) };
35+
return options.transport;
5336
}
5437

5538
if (supportsFetch()) {
5639
const requestOptions: RequestInit = { ...transportOptions.fetchParameters };
57-
const newTransport = makeNewFetchTransport({ requestOptions, url });
58-
const fetchTransport = new FetchTransport(transportOptions);
59-
return { transport: fetchTransport, newTransport };
40+
return makeNewFetchTransport({ requestOptions, url });
6041
}
6142

62-
const newTransport = makeNewXHRTransport({
43+
return makeNewXHRTransport({
6344
url,
6445
headers: transportOptions.headers,
6546
});
66-
const transport = new XHRTransport(transportOptions);
67-
return { transport, newTransport };
6847
}

packages/node/src/sdk.ts

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

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

137136
if (options.autoSessionTracking) {
138137
startSessionTracking();

packages/node/src/transports/setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export function setupNodeTransport(options: NodeOptions): NewTransport {
1616
...(options.caCerts && { caCerts: options.caCerts }),
1717
// @ts-ignore Come back to this
1818
// TODO(v7): Figure out how to enforce dsn
19-
dsn: options.dsn === undefined ? undefined : makeDsn(options.dsn),
19+
dsn: options.dsn,
2020
tunnel: options.tunnel,
2121
_metadata: options._metadata,
2222
};

0 commit comments

Comments
 (0)