Skip to content

ref(node): Explicitly pass down node transport options #5057

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,6 @@ Sentry.init({
...
})



// Before:
class MyCustomTransport extends BaseTransport {
constructor(options: TransportOptions) {
Expand Down Expand Up @@ -252,6 +250,30 @@ object with your custom logic, will also take care of rate limiting and flushing

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).

### Node Transport Changes

To clean up the options interface, we now require users to pass down transport related options under the `transportOptions` key. The options that
were changed were `caCerts`, `httpProxy`, and `httpsProxy`. In addition, `httpProxy` and `httpsProxy` were unified to a single option under
the `transportOptions` key, `proxy`.

```ts
// New in v7:
Sentry.init({
dsn: '...',
transportOptions: {
caCerts: getMyCaCert(),
proxy: 'http://example.com',
},
});

// Before:
Sentry.init({
dsn: '...',
caCerts: getMyCaCert(),
httpsProxy: 'http://example.com',
})
```

## Enum Changes

Given that enums have a high bundle-size impact, our long term goal is to eventually remove all enums from the SDK in
Expand Down
15 changes: 4 additions & 11 deletions packages/node/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
import { ClientOptions, Options } from '@sentry/types';

import { NodeTransportOptions } from './transports';

export interface BaseNodeOptions {
/** Sets an optional server name (device name) */
serverName?: string;

/** Set a HTTP proxy that should be used for outbound requests. */
httpProxy?: string;

/** Set a HTTPS proxy that should be used for outbound requests. */
httpsProxy?: string;

/** HTTPS proxy certificates path */
caCerts?: string;

/** Callback that is executed when a fatal global error occurs. */
onFatalError?(error: Error): void;
}
Expand All @@ -21,10 +14,10 @@ export interface BaseNodeOptions {
* Configuration options for the Sentry Node SDK
* @see @sentry/types Options for more information.
*/
export interface NodeOptions extends Options, BaseNodeOptions {}
export interface NodeOptions extends Options<NodeTransportOptions>, BaseNodeOptions {}

/**
* Configuration options for the Sentry Node SDK Client class
* @see NodeClient for more information.
*/
export interface NodeClientOptions extends ClientOptions, BaseNodeOptions {}
export interface NodeClientOptions extends ClientOptions<NodeTransportOptions>, BaseNodeOptions {}