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 11import { 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 */
511export 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 } ) ;
You can’t perform that action at this time.
0 commit comments