@sentry/integrations
Version:
Pluggable integrations that can be used to enhance JS SDKs
61 lines (54 loc) • 1.4 kB
JavaScript
import { consoleSandbox } from '@sentry/utils';
/**
* Integration to debug sent Sentry events.
* This integration should not be used in production
*/
class Debug {
/**
* @inheritDoc
*/
static __initStatic() {this.id = 'Debug';}
/**
* @inheritDoc
*/
__init() {this.name = Debug.id;}
constructor(options) {;Debug.prototype.__init.call(this);
this._options = {
debugger: false,
stringify: false,
...options,
};
}
/**
* @inheritDoc
*/
setupOnce(addGlobalEventProcessor, getCurrentHub) {
addGlobalEventProcessor((event, hint) => {
const self = getCurrentHub().getIntegration(Debug);
if (self) {
if (self._options.debugger) {
// eslint-disable-next-line no-debugger
debugger;
}
/* eslint-disable no-console */
consoleSandbox(() => {
if (self._options.stringify) {
console.log(JSON.stringify(event, null, 2));
if (Object.keys(hint).length) {
console.log(JSON.stringify(hint, null, 2));
}
} else {
console.log(event);
if (Object.keys(hint).length) {
console.log(hint);
}
}
});
/* eslint-enable no-console */
}
return event;
});
}
} Debug.__initStatic();
export { Debug };
//# sourceMappingURL=debug.js.map