Skip to content

Commit 6e54b2f

Browse files
committed
fix: Use addExceptionTypeValue in helpers
1 parent 3cd6e79 commit 6e54b2f

File tree

4 files changed

+10
-36
lines changed

4 files changed

+10
-36
lines changed

packages/browser/src/integrations/globalhandlers.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,6 @@ export class GlobalHandlers implements Integration {
103103
data.name = stacktrace.name;
104104
}
105105

106-
const newEvent: Event = {
107-
...event,
108-
};
109-
110106
const client = getCurrentHub().getClient();
111107
const maxValueLength = (client && client.getOptions().maxValueLength) || 250;
112108

@@ -116,12 +112,12 @@ export class GlobalHandlers implements Integration {
116112
const fallbackType = stacktrace.mechanism === 'onunhandledrejection' ? 'UnhandledRejection' : 'Error';
117113

118114
// This makes sure we have type/value in every exception
119-
addExceptionTypeValue(newEvent, fallbackValue, fallbackType, {
115+
addExceptionTypeValue(event, fallbackValue, fallbackType, {
120116
data,
121117
handled: false,
122118
type: stacktrace.mechanism,
123119
});
124120

125-
return newEvent;
121+
return event;
126122
}
127123
}

packages/browser/src/integrations/helpers.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { captureException, getCurrentHub, withScope } from '@sentry/core';
22
import { Event as SentryEvent, Mechanism, WrappedFunction } from '@sentry/types';
3-
import { htmlTreeAsString } from '@sentry/utils/misc';
3+
import { addExceptionTypeValue, htmlTreeAsString } from '@sentry/utils/misc';
44
import { normalize } from '@sentry/utils/object';
55

66
const debounceDuration: number = 1000;
@@ -91,11 +91,7 @@ export function wrap(
9191
const processedEvent = { ...event };
9292

9393
if (options.mechanism) {
94-
processedEvent.exception = processedEvent.exception || {};
95-
processedEvent.exception.values = processedEvent.exception.values || [];
96-
processedEvent.exception.values[0] = processedEvent.exception.values[0] || {};
97-
processedEvent.exception.values[0].mechanism =
98-
processedEvent.exception.values[0].mechanism || options.mechanism;
94+
addExceptionTypeValue(processedEvent, undefined, undefined, options.mechanism);
9995
}
10096

10197
processedEvent.extra = {

packages/node/src/backend.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { BaseBackend, Dsn, getCurrentHub } from '@sentry/core';
2-
import { Event, EventHint, Options, Mechanism, Severity, Transport } from '@sentry/types';
2+
import { Event, EventHint, Mechanism, Options, Severity, Transport } from '@sentry/types';
33
import { isError, isPlainObject } from '@sentry/utils/is';
44
import { addExceptionTypeValue } from '@sentry/utils/misc';
55
import { normalizeToSize } from '@sentry/utils/object';
@@ -109,17 +109,11 @@ export class NodeBackend extends BaseBackend<NodeOptions> {
109109

110110
return new SyncPromise<Event>(resolve =>
111111
parseError(ex as Error, this.options).then(event => {
112-
const newEvent = event;
113-
addExceptionTypeValue(
114-
{
115-
...newEvent,
116-
event_id: hint && hint.event_id,
117-
},
118-
undefined,
119-
undefined,
120-
mechanism,
121-
);
122-
resolve(newEvent);
112+
addExceptionTypeValue(event, undefined, undefined, mechanism);
113+
resolve({
114+
...event,
115+
event_id: hint && hint.event_id,
116+
});
123117
}),
124118
);
125119
}

packages/node/test/manual/index.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)