Skip to content

Commit 20e7447

Browse files
authored
fix: Minor issues (#1420)
* fix: Get global object fixed in hub Fixes #1419 * fix: TransportOptions differences between node/browser * fix: Event interface extra:any * fix: Global naming conflict
1 parent 84ba07d commit 20e7447

File tree

8 files changed

+21
-45
lines changed

8 files changed

+21
-45
lines changed

packages/hub/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"access": "public"
1616
},
1717
"dependencies": {
18-
"@sentry/types": "4.0.0-beta.0"
18+
"@sentry/types": "4.0.0-beta.0",
19+
"@sentry/utils": "4.0.0-beta.0"
1920
},
2021
"devDependencies": {
2122
"jest": "^22.4.3",

packages/hub/src/global.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
1+
import { getGlobalObject } from '@sentry/utils/misc';
12
import { API_VERSION, Hub } from './hub';
23
import { Carrier } from './interfaces';
34

4-
/** Global interface helper for type safety. */
5-
interface Global {
6-
__SENTRY__: Carrier;
7-
}
8-
9-
declare var global: Global;
10-
11-
global.__SENTRY__ = global.__SENTRY__ || {
12-
hub: undefined,
13-
};
14-
155
/** Returns the global shim registry. */
166
export function getMainCarrier(): Carrier {
17-
return global.__SENTRY__;
7+
const carrier: any = getGlobalObject();
8+
carrier.__SENTRY__ = carrier.__SENTRY__ || {
9+
hub: undefined,
10+
};
11+
return carrier.__SENTRY__;
1812
}
1913

2014
/**

packages/node/src/backend.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Backend, DSN, Options, SentryError } from '@sentry/core';
22
import { addBreadcrumb, captureEvent } from '@sentry/minimal';
33
import { SentryEvent, SentryResponse } from '@sentry/types';
44
import { Raven } from './raven';
5-
import { HTTPSTransport, HTTPTransport, TransportOptions } from './transports';
5+
import { HTTPSTransport, HTTPTransport } from './transports';
66

77
/** Extension to the Function type. */
88
interface FunctionExt extends Function {
@@ -34,11 +34,6 @@ export interface NodeOptions extends Options {
3434

3535
/** Callback that is executed when a fatal global error occurs. */
3636
onFatalError?(error: Error): void;
37-
38-
/**
39-
* @inheritDoc
40-
*/
41-
transportOptions?: TransportOptions;
4237
}
4338

4439
/** The Sentry Node SDK Backend. */

packages/node/src/transports/base.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import {
44
SentryResponse,
55
Status,
66
Transport,
7-
TransportOptions as BaseOptions,
7+
TransportOptions,
88
} from '@sentry/types';
9-
import { serialize } from '@sentry/utils/src/object';
9+
import { serialize } from '@sentry/utils/object';
1010
import * as http from 'http';
1111
import * as https from 'https';
1212
import { getDefaultHub, NodeClient } from '../index';
@@ -19,14 +19,6 @@ export interface HTTPRequest {
1919
): http.ClientRequest;
2020
}
2121

22-
/** Transport options */
23-
export interface TransportOptions extends BaseOptions {
24-
/** Options for http.agent default: { keepAlive: true, maxSockets: 100 } */
25-
agentOptions?: http.AgentOptions;
26-
/** Define custom headers */
27-
headers?: http.IncomingHttpHeaders;
28-
}
29-
3022
/** Base Transport class implementation */
3123
export abstract class BaseTransport implements Transport {
3224
/** DSN object */

packages/node/src/transports/http.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
import { SentryEvent, SentryResponse } from '@sentry/types';
1+
import { SentryEvent, SentryResponse, TransportOptions } from '@sentry/types';
22
import * as http from 'http';
3-
import { BaseTransport, TransportOptions } from './base';
3+
import { BaseTransport } from './base';
44

55
/** /** Node http module transport */
66
export class HTTPTransport extends BaseTransport {
77
/** Create a new instance and set this.agent */
88
public constructor(public options: TransportOptions) {
99
super(options);
10-
this.client = new http.Agent(
11-
this.options.agentOptions
12-
? this.options.agentOptions
13-
: { keepAlive: true, maxSockets: 100 },
14-
);
10+
this.client = new http.Agent({ keepAlive: true, maxSockets: 100 });
1511
}
1612

1713
/**

packages/node/src/transports/https.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
import { SentryEvent, SentryResponse } from '@sentry/types';
1+
import { SentryEvent, SentryResponse, TransportOptions } from '@sentry/types';
22
import * as https from 'https';
3-
import { BaseTransport, TransportOptions } from './base';
3+
import { BaseTransport } from './base';
44

55
/** Node https module transport */
66
export class HTTPSTransport extends BaseTransport {
77
/** Create a new instance and set this.agent */
88
public constructor(public options: TransportOptions) {
99
super(options);
10-
this.client = new https.Agent(
11-
this.options.agentOptions
12-
? this.options.agentOptions
13-
: { keepAlive: true, maxSockets: 100 },
14-
);
10+
this.client = new https.Agent({ keepAlive: true, maxSockets: 100 });
1511
}
1612

1713
/**

packages/node/src/transports/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export { BaseTransport, TransportOptions } from './base';
1+
export { BaseTransport } from './base';
22
export { HTTPTransport } from './http';
33
export { HTTPSTransport } from './https';

packages/types/src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export interface SentryEvent {
141141
breadcrumbs?: Breadcrumb[];
142142
contexts?: { [key: string]: object };
143143
tags?: { [key: string]: string };
144-
extra?: { [key: string]: object };
144+
extra?: { [key: string]: any };
145145
user?: User;
146146
}
147147

@@ -162,6 +162,8 @@ export interface SentryResponse {
162162
/** TODO */
163163
export interface TransportOptions {
164164
dsn: DSNLike;
165+
/** Define custom headers */
166+
headers?: object;
165167
}
166168

167169
/** TODO */

0 commit comments

Comments
 (0)