File tree Expand file tree Collapse file tree 1 file changed +40
-4
lines changed
packages/core/src/integrations/pluggable Expand file tree Collapse file tree 1 file changed +40
-4
lines changed Original file line number Diff line number Diff line change 1
1
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
+ }
3
9
4
10
/** JSDoc */
5
11
export class Debug implements Integration {
@@ -8,14 +14,44 @@ export class Debug implements Integration {
8
14
*/
9
15
public name : string = 'Debug' ;
10
16
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
+
11
31
/**
12
32
* @inheritDoc
13
33
*/
14
34
public install ( ) : void {
15
35
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
+ }
19
55
return event ;
20
56
} ) ;
21
57
} ) ;
You can’t perform that action at this time.
0 commit comments