Skip to content

Commit 1df4c1f

Browse files
authored
fix: Merge transportOptions correctly (getsentry#2153)
* meta: v5.5.0 changlog * fix: Merge transportOptions correctly
1 parent 1127cf4 commit 1df4c1f

File tree

4 files changed

+26
-15
lines changed

4 files changed

+26
-15
lines changed

CHANGELOG.md

+14-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,20 @@
22

33
## Unreleased
44

5-
- [browser]: feat: Try to read `window.SENTRY_RELEASE` to set release by default
6-
- [utils]: fix(utils): Add polyfill for Object.setPrototypeOf
5+
- None
6+
7+
## 5.5.0
8+
9+
- [core] fix: Store processing state for each `flush` call separately (#2143)
10+
- [scope] feat: Generate hint if not provided in the Hub calls (#2142)
11+
- [browser] feat: Read `window.SENTRY_RELEASE` to set release by default (#2132)
12+
- [browser] fix: Don't call `fn.handleEvent.bind` if `fn.handleEvent` does not exist (#2138)
13+
- [browser] fix: Correctly handle events that utilize `handleEvent` object (#2149)
14+
- [node] feat: Provide optional `shouldHandleError` option for node `errorHandler` (#2146)
15+
- [node] fix: Remove unsafe `any` from `NodeOptions` type (#2111)
16+
- [node] fix: Merge `transportOptions` correctly (#2151)
17+
- [utils] fix: Add polyfill for `Object.setPrototypeOf` (#2127)
18+
- [integrations] feat: `SessionDuration` integration (#2150)
719

820
## 5.4.3
921

packages/browser/src/backend.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ export class BrowserBackend extends BaseBackend<BrowserOptions> {
4949
return super._setupTransport();
5050
}
5151

52-
const transportOptions = this._options.transportOptions
53-
? this._options.transportOptions
54-
: { dsn: this._options.dsn };
52+
const transportOptions = {
53+
...this._options.transportOptions,
54+
dsn: this._options.dsn,
55+
};
5556

5657
if (this._options.transport) {
5758
return new this._options.transport(transportOptions);

packages/node/src/backend.ts

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { BaseBackend, Dsn, getCurrentHub } from '@sentry/core';
2-
import { Event, EventHint, Mechanism, Options, Severity, Transport } from '@sentry/types';
2+
import { Event, EventHint, Mechanism, Options, Severity, Transport, TransportOptions } from '@sentry/types';
33
import {
44
addExceptionTypeValue,
55
isError,
@@ -55,14 +55,13 @@ export class NodeBackend extends BaseBackend<NodeOptions> {
5555

5656
const dsn = new Dsn(this._options.dsn);
5757

58-
const transportOptions = this._options.transportOptions || { dsn };
59-
const clientOptions = ['httpProxy', 'httpsProxy', 'caCerts'];
60-
61-
for (const option of clientOptions) {
62-
if (this._options[option] || transportOptions[option]) {
63-
transportOptions[option] = transportOptions[option] || this._options[option];
64-
}
65-
}
58+
const transportOptions: TransportOptions = {
59+
...this._options.transportOptions,
60+
...(this._options.httpProxy && { httpProxy: this._options.httpProxy }),
61+
...(this._options.httpsProxy && { httpsProxy: this._options.httpsProxy }),
62+
...(this._options.caCerts && { caCerts: this._options.caCerts }),
63+
dsn: this._options.dsn,
64+
};
6665

6766
if (this._options.transport) {
6867
return new this._options.transport(transportOptions);

packages/types/src/transport.ts

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export type TransportClass<T extends Transport> = new (options: TransportOptions
2424

2525
/** JSDoc */
2626
export interface TransportOptions {
27-
[key: string]: any;
2827
/** Sentry DSN */
2928
dsn: DsnLike;
3029
/** Define custom headers */

0 commit comments

Comments
 (0)