Skip to content

Commit 8675889

Browse files
committed
feat: Introduce stringify and debugger options in Debug integration
1 parent 17d8f88 commit 8675889

File tree

1 file changed

+40
-4
lines changed
  • packages/core/src/integrations/pluggable

1 file changed

+40
-4
lines changed

packages/core/src/integrations/pluggable/debug.ts

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { configureScope } from '@sentry/minimal';
2-
import { Integration, SentryEvent } from '@sentry/types';
2+
import { Integration, SentryEvent, SentryEventHint } from '@sentry/types';
3+
4+
/** JSDoc */
5+
interface DebugOptions {
6+
stringify?: boolean;
7+
debugger?: boolean;
8+
}
39

410
/** JSDoc */
511
export class Debug implements Integration {
@@ -8,14 +14,44 @@ export class Debug implements Integration {
814
*/
915
public name: string = 'Debug';
1016

17+
/** JSDoc */
18+
private readonly options: DebugOptions;
19+
20+
/**
21+
* @inheritDoc
22+
*/
23+
public constructor(options?: DebugOptions) {
24+
this.options = {
25+
debugger: false,
26+
stringify: false,
27+
...options,
28+
};
29+
}
30+
1131
/**
1232
* @inheritDoc
1333
*/
1434
public install(): void {
1535
configureScope(scope => {
16-
scope.addEventProcessor(async (event: SentryEvent) => {
17-
// tslint:disable-next-line:no-console
18-
console.log(event);
36+
scope.addEventProcessor(async (event: SentryEvent, hint?: SentryEventHint) => {
37+
// tslint:disable:no-console
38+
// tslint:disable:no-debugger
39+
40+
if (this.options.debugger) {
41+
debugger;
42+
}
43+
44+
if (this.options.stringify) {
45+
console.log(JSON.stringify(event, null, 2));
46+
if (hint) {
47+
console.log(JSON.stringify(hint, null, 2));
48+
}
49+
} else {
50+
console.log(event);
51+
if (hint) {
52+
console.log(hint);
53+
}
54+
}
1955
return event;
2056
});
2157
});

0 commit comments

Comments
 (0)