Skip to content

Commit ff5d848

Browse files
committed
node/browser: Attach stacktrace to captureMessage only when enabled
1 parent c7bc589 commit ff5d848

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

options-matrix.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
| repos | Configures the repository spec for events | yes | all | YES |
77
| dist | Sets the distribution for all events | yes | all | YES |
88
| server_name | Sets an optional server name (device name) | no | node | YES |
9-
| attach_stacktrace | Attaches stacktraces to pure capture message / log integrations | no | all | NO |
9+
| attach_stacktrace | Attaches stacktraces to pure capture message / log integrations | no | all | YES |
1010
| ignore_errors | A list of filters for errors not to send | yes | all | KINDA |
1111
| max_breadcrumbs | Maximum number of breadcrumbs to record (0 = disable) | yes | all | YES |
1212
| sample_rate | A global sample rate to apply to all events (0 - 1) | yes | all | YES |

packages/browser/src/backend.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export class BrowserBackend implements Backend {
117117
message,
118118
};
119119

120-
if (syntheticException) {
120+
if (this.options.attachStacktrace && syntheticException) {
121121
const stacktrace = computeStackTrace(syntheticException);
122122
const frames = prepareFramesForEvent(stacktrace.stack);
123123
event.stacktrace = {

packages/core/src/interfaces.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ export interface Options {
8484
/** A global sample rate to apply to all events (0 - 1). */
8585
sampleRate?: number;
8686

87+
/** Attaches stacktraces to pure capture message / log integrations */
88+
attachStacktrace?: boolean;
89+
8790
/**
8891
* A callback invoked during event submission, allowing to cancel the process.
8992
* If unspecified, all events will be sent to Sentry.

packages/node/src/backend.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,19 @@ export class NodeBackend implements Backend {
7171
* @inheritDoc
7272
*/
7373
public async eventFromMessage(message: string, syntheticException: Error | null): Promise<SentryEvent> {
74-
const stack = syntheticException ? await extractStackFromError(syntheticException) : [];
75-
const frames = await parseStack(stack);
7674
const event: SentryEvent = {
75+
fingerprint: [message],
7776
message,
78-
stacktrace: {
79-
frames: prepareFramesForEvent(frames),
80-
},
8177
};
8278

79+
if (this.options.attachStacktrace && syntheticException) {
80+
const stack = syntheticException ? await extractStackFromError(syntheticException) : [];
81+
const frames = await parseStack(stack);
82+
event.stacktrace = {
83+
frames: prepareFramesForEvent(frames),
84+
};
85+
}
86+
8387
return this.applyClientOptions(event);
8488
}
8589

0 commit comments

Comments
 (0)