8000 s/onunhandledpromiserejection/onunhandledrejection/g and minor handle… · lordnox/sentry-javascript@673b65c · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Jan 8, 2025. It is now read-only.

Commit 673b65c

Browse files
committed
s/onunhandledpromiserejection/onunhandledrejection/g and minor handler fixes
1 parent 8853d2b commit 673b65c

File tree

3 files changed

+14
-17
lines changed

3 files changed

+14
-17
lines changed

packages/browser/src/backend.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ export class BrowserBackend implements Backend {
105105
},
106106
};
107107

108-
console.log(event);
109-
110108
return event;
111109
}
112110

@@ -127,8 +125,6 @@ export class BrowserBackend implements Backend {
127125
};
128126
}
129127

130-
console.log(event);
131-
132128
return event;
133129
}
134130

packages/browser/src/integrations/globalhandlers.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ export class GlobalHandlers implements Integration {
1818
public constructor(
1919
private options: {
2020
onerror: boolean;
21-
onunhandledpromiserejection: boolean;
21+
onunhandledrejection: boolean;
2222
} = {
2323
onerror: true,
24-
onunhandledpromiserejection: true,
24+
onunhandledrejection: true,
2525
},
2626
) {}
2727
/**
@@ -51,24 +51,22 @@ export class GlobalHandlers implements Integration {
5151
installGlobalHandler();
5252
}
5353

54-
if (this.options.onunhandledpromiserejection) {
55-
logger.log('Global Handler attached: onunhandledpromiserejection');
54+
if (this.options.onunhandledrejection) {
55+
logger.log('Global Handler attached: onunhandledrejection');
5656
installGlobalUnhandledRejectionHandler();
5757
}
5858
}
5959

6060
/** TODO */
6161
private eventFromGlobalHandler(stacktrace: TraceKitStackTrace): SentryEvent {
6262
const event = eventFromStacktrace(stacktrace);
63-
console.log(event);
64-
// TODO: Make a distinction between 'onunhandledrejection' and 'onerror'
6563
return {
6664
...event,
6765
exception: {
6866
...event.exception,
6967
mechanism: {
7068
handled: false,
71-
type: 'onerror',
69+
type: stacktrace.mode === 'onerror' ? 'onerror' : 'onunhandledrejection',
7270
},
7371
},
7472
};

packages/browser/src/parsers.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,18 @@ export function prepareFramesForEvent(stack: TraceKitStackFrame[]): StackFrame[]
5757
return [];
5858
}
5959

60-
return stack
61-
.filter(
62-
// TODO: This could be smarter
63-
frame => !frame.func.includes('captureMessage') && !frame.func.includes('captureException'),
64-
)
60+
let localStack = stack;
61+
62+
// TODO: This could be smarter
63+
if (localStack[0].func.includes('captureMessage') || localStack[0].func.includes('captureException')) {
64+
localStack = localStack.slice(1);
65+
}
66+
67+
return localStack
6568
.map(
6669
(frame: TraceKitStackFrame): StackFrame => ({
6770
colno: frame.column,
68-
filename: frame.url || stack[0].url,
71+
filename: frame.url || localStack[0].url,
6972
function: frame.func || '?',
7073
in_app: true,
7174
lineno: frame.line,

0 commit comments

Comments
 (0)
0