Skip to content

Commit 3e0544e

Browse files
committed
fix: Transports, Add additional info in hint for global errros
1 parent 09bbdbc commit 3e0544e

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

packages/browser/src/integrations/globalhandlers.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { logger } from '@sentry/core';
2-
import { captureEvent } from '@sentry/minimal';
2+
import { getCurrentHub } from '@sentry/hub';
33
import { Integration, SentryEvent } from '@sentry/types';
44
import { eventFromStacktrace } from '../parsers';
55
import {
@@ -29,7 +29,7 @@ export class GlobalHandlers implements Integration {
2929
* @inheritDoc
3030
*/
3131
public install(): void {
32-
subscribe((stack: TraceKitStackTrace) => {
32+
subscribe((stack: TraceKitStackTrace, _: boolean, error: Error) => {
3333
// TODO: use stack.context to get a valuable information from TraceKit, eg.
3434
// [
3535
// 0: " })"
@@ -47,7 +47,7 @@ export class GlobalHandlers implements Integration {
4747
if (shouldIgnoreOnError()) {
4848
return;
4949
}
50-
captureEvent(this.eventFromGlobalHandler(stack));
50+
getCurrentHub().captureEvent(this.eventFromGlobalHandler(stack), { originalException: error, data: stack });
5151
});
5252

5353
if (this.options.onerror) {

packages/browser/src/integrations/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export function wrap(
7979
});
8080
});
8181

82-
getCurrentHub().captureException(ex);
82+
getCurrentHub().captureException(ex, { originalException: ex });
8383
});
8484

8585
throw ex;

packages/browser/test/transports/fetch.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ describe('FetchTransport', () => {
4141
expect(
4242
fetch.calledWith(transportUrl, {
4343
body: JSON.stringify(payload),
44-
keepalive: true,
4544
method: 'POST',
4645
referrerPolicy: 'origin',
4746
}),
@@ -60,7 +59,6 @@ describe('FetchTransport', () => {
6059
expect(
6160
fetch.calledWith(transportUrl, {
6261
body: JSON.stringify(payload),
63-
keepalive: true,
6462
method: 'POST',
6563
referrerPolicy: 'origin',
6664
}),

packages/hub/src/hub.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,12 @@ export class Hub {
201201
* Captures a manually created event and sends it to Sentry.
202202
*
203203
* @param event The event to send to Sentry.
204+
* @param hint May contain additional informartion about the original exception.
204205
*/
205-
public captureEvent(event: SentryEvent): string {
206+
public captureEvent(event: SentryEvent, hint?: SentryEventHint): string {
206207
const eventId = (this._lastEventId = uuid4());
207208
this.invokeClientAsync('captureEvent', event, {
209+
...hint,
208210
event_id: eventId,
209211
});
210212
return eventId;

packages/node/src/handlers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export function errorHandler(): (
192192
next(error);
193193
return;
194194
}
195-
getHubFromCarrier(req).captureException(error);
195+
getHubFromCarrier(req).captureException(error, { originalException: error });
196196
next(error);
197197
};
198198
}
@@ -229,7 +229,7 @@ export function makeErrorHandler(
229229
}));
230230
});
231231

232-
getCurrentHub().captureException(error);
232+
getCurrentHub().captureException(error, { originalException: error });
233233

234234
if (!calledFatalError) {
235235
calledFatalError = true;

packages/node/src/integrations/onunhandledrejection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class OnUnhandledRejection implements Integration {
3939
}
4040
scope.setExtra('unhandledPromiseRejection', true);
4141
});
42-
getCurrentHub().captureException(reason);
42+
getCurrentHub().captureException(reason, { originalException: promise });
4343
});
4444
}
4545
}

0 commit comments

Comments
 (0)