Repository navigation
Expand file tree
/
Copy pathdebug.ts
More file actions
63 lines (56 loc) · 1.34 KB
/
Copy pathdebug.ts
File metadata and controls
63 lines (56 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { Event, EventHint, EventProcessor, Hub, Integration } from '@sentry/types';
/** JSDoc */
interface DebugOptions {
stringify?: boolean;
debugger?: boolean;
}
/** JSDoc */
export class Debug implements Integration {
/**
* @inheritDoc
*/
public name: string = Debug.id;
/**
* @inheritDoc
*/
public static id: string = 'Debug';
/** JSDoc */
private readonly _options: DebugOptions;
/**
* @inheritDoc
*/
public constructor(options?: DebugOptions) {
this._options = {
debugger: false,
stringify: false,
...options,
};
}
/**
* @inheritDoc
*/
public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void {
addGlobalEventProcessor((event: Event, hint?: EventHint) => {
const self = getCurrentHub().getIntegration(Debug);
if (self) {
// tslint:disable:no-console
// tslint:disable:no-debugger
if (self._options.debugger) {
debugger;
}
if (self._options.stringify) {
console.log(JSON.stringify(event, null, 2));
if (hint) {
console.log(JSON.stringify(hint, null, 2));
}
} else {
console.log(event);
if (hint) {
console.log(hint);
}
}
}
return event;
});
}
}