Skip to content

Commit 1342c42

Browse files
authored
ref(node): Explicitly pass down node transport options (#5057)
We enforce the transport types by assigning the generic when typing the Node Client class (we use `ClientOptions<NodeTransportOptions>`). To further refine the transport types, we remove the transport options from the top level of the sdk init and instead require users to pass it in under the `transportOptions` key explicitly.
1 parent cb9260f commit 1342c42

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed

MIGRATION.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,6 @@ Sentry.init({
218218
...
219219
})
220220

221-
222-
223221
// Before:
224222
class MyCustomTransport extends BaseTransport {
225223
constructor(options: TransportOptions) {
@@ -252,6 +250,30 @@ object with your custom logic, will also take care of rate limiting and flushing
252250

253251
For a complete v7 transport implementation, take a look at our [browser fetch transport](https://github.com/getsentry/sentry-javascript/blob/ebc938a03d6efe7d0c4bbcb47714e84c9a566a9c/packages/browser/src/transports/fetch.ts#L1-L34).
254252

253+
### Node Transport Changes
254+
255+
To clean up the options interface, we now require users to pass down transport related options under the `transportOptions` key. The options that
256+
were changed were `caCerts`, `httpProxy`, and `httpsProxy`. In addition, `httpProxy` and `httpsProxy` were unified to a single option under
257+
the `transportOptions` key, `proxy`.
258+
259+
```ts
260+
// New in v7:
261+
Sentry.init({
262+
dsn: '...',
263+
transportOptions: {
264+
caCerts: getMyCaCert(),
265+
proxy: 'http://example.com',
266+
},
267+
});
268+
269+
// Before:
270+
Sentry.init({
271+
dsn: '...',
272+
caCerts: getMyCaCert(),
273+
httpsProxy: 'http://example.com',
274+
})
275+
```
276+
255277
## Enum Changes
256278

257279
Given that enums have a high bundle-size impact, our long term goal is to eventually remove all enums from the SDK in

packages/node/src/types.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
import { ClientOptions, Options } from '@sentry/types';
22

3+
import { NodeTransportOptions } from './transports';
4+
35
export interface BaseNodeOptions {
46
/** Sets an optional server name (device name) */
57
serverName?: string;
68

7-
/** Set a HTTP proxy that should be used for outbound requests. */
8-
httpProxy?: string;
9-
10-
/** Set a HTTPS proxy that should be used for outbound requests. */
11-
httpsProxy?: string;
12-
13-
/** HTTPS proxy certificates path */
14-
caCerts?: string;
15-
169
/** Callback that is executed when a fatal global error occurs. */
1710
onFatalError?(error: Error): void;
1811
}
@@ -21,10 +14,10 @@ export interface BaseNodeOptions {
2114
* Configuration options for the Sentry Node SDK
2215
* @see @sentry/types Options for more information.
2316
*/
24-
export interface NodeOptions extends Options, BaseNodeOptions {}
17+
export interface NodeOptions extends Options<NodeTransportOptions>, BaseNodeOptions {}
2518

2619
/**
2720
* Configuration options for the Sentry Node SDK Client class
2821
* @see NodeClient for more information.
2922
*/
30-
export interface NodeClientOptions extends ClientOptions, BaseNodeOptions {}
23+
export interface NodeClientOptions extends ClientOptions<NodeTransportOptions>, BaseNodeOptions {}

0 commit comments

Comments
 (0)