1 | import { consoleSandbox } from '@sentry/utils';
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | class Debug {
|
8 | |
9 |
|
10 |
|
11 | static __initStatic() {this.id = 'Debug';}
|
12 |
|
13 | |
14 |
|
15 |
|
16 | __init() {this.name = Debug.id;}
|
17 |
|
18 | constructor(options) {Debug.prototype.__init.call(this);
|
19 | this._options = {
|
20 | debugger: false,
|
21 | stringify: false,
|
22 | ...options,
|
23 | };
|
24 | }
|
25 |
|
26 | |
27 |
|
28 |
|
29 | setupOnce(addGlobalEventProcessor, getCurrentHub) {
|
30 | addGlobalEventProcessor((event, hint) => {
|
31 | const self = getCurrentHub().getIntegration(Debug);
|
32 | if (self) {
|
33 | if (self._options.debugger) {
|
34 |
|
35 | debugger;
|
36 | }
|
37 |
|
38 |
|
39 | consoleSandbox(() => {
|
40 | if (self._options.stringify) {
|
41 | console.log(JSON.stringify(event, null, 2));
|
42 | if (Object.keys(hint).length) {
|
43 | console.log(JSON.stringify(hint, null, 2));
|
44 | }
|
45 | } else {
|
46 | console.log(event);
|
47 | if (Object.keys(hint).length) {
|
48 | console.log(hint);
|
49 | }
|
50 | }
|
51 | });
|
52 |
|
53 | }
|
54 | return event;
|
55 | });
|
56 | }
|
57 | } Debug.__initStatic();
|
58 |
|
59 | export { Debug };
|
60 |
|