debug.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. Object.defineProperty(exports, '__esModule', { value: true });
  2. const core = require('@sentry/core');
  3. const utils = require('@sentry/utils');
  4. const INTEGRATION_NAME = 'Debug';
  5. const _debugIntegration = ((options = {}) => {
  6. const _options = {
  7. debugger: false,
  8. stringify: false,
  9. ...options,
  10. };
  11. return {
  12. name: INTEGRATION_NAME,
  13. // TODO v8: Remove this
  14. setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
  15. setup(client) {
  16. if (!client.on) {
  17. return;
  18. }
  19. client.on('beforeSendEvent', (event, hint) => {
  20. if (_options.debugger) {
  21. // eslint-disable-next-line no-debugger
  22. debugger;
  23. }
  24. /* eslint-disable no-console */
  25. utils.consoleSandbox(() => {
  26. if (_options.stringify) {
  27. console.log(JSON.stringify(event, null, 2));
  28. if (hint && Object.keys(hint).length) {
  29. console.log(JSON.stringify(hint, null, 2));
  30. }
  31. } else {
  32. console.log(event);
  33. if (hint && Object.keys(hint).length) {
  34. console.log(hint);
  35. }
  36. }
  37. });
  38. /* eslint-enable no-console */
  39. });
  40. },
  41. };
  42. }) ;
  43. const debugIntegration = core.defineIntegration(_debugIntegration);
  44. /**
  45. * Integration to debug sent Sentry events.
  46. * This integration should not be used in production.
  47. *
  48. * @deprecated Use `debugIntegration()` instead.
  49. */
  50. // eslint-disable-next-line deprecation/deprecation
  51. const Debug = core.convertIntegrationFnToClass(INTEGRATION_NAME, debugIntegration)
  52. ;
  53. exports.Debug = Debug;
  54. exports.debugIntegration = debugIntegration;
  55. //# sourceMappingURL=debug.js.map