UNPKG

1.4 kBJavaScriptView Raw
1import { consoleSandbox } from '@sentry/utils';
2
3/**
4 * Integration to debug sent Sentry events.
5 * This integration should not be used in production
6 */
7class Debug {
8 /**
9 * @inheritDoc
10 */
11 static __initStatic() {this.id = 'Debug';}
12
13 /**
14 * @inheritDoc
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 * @inheritDoc
28 */
29 setupOnce(addGlobalEventProcessor, getCurrentHub) {
30 addGlobalEventProcessor((event, hint) => {
31 const self = getCurrentHub().getIntegration(Debug);
32 if (self) {
33 if (self._options.debugger) {
34 // eslint-disable-next-line no-debugger
35 debugger;
36 }
37
38 /* eslint-disable no-console */
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 /* eslint-enable no-console */
53 }
54 return event;
55 });
56 }
57} Debug.__initStatic();
58
59export { Debug };
60//# sourceMappingURL=debug.js.map