console.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import * as util from 'util';
  2. import { defineIntegration, convertIntegrationFnToClass, getClient, addBreadcrumb } from '@sentry/core';
  3. import { addConsoleInstrumentationHandler, severityLevelFromString } from '@sentry/utils';
  4. const INTEGRATION_NAME = 'Console';
  5. const _consoleIntegration = (() => {
  6. return {
  7. name: INTEGRATION_NAME,
  8. // TODO v8: Remove this
  9. setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
  10. setup(client) {
  11. addConsoleInstrumentationHandler(({ args, level }) => {
  12. if (getClient() !== client) {
  13. return;
  14. }
  15. addBreadcrumb(
  16. {
  17. category: 'console',
  18. level: severityLevelFromString(level),
  19. message: util.format.apply(undefined, args),
  20. },
  21. {
  22. input: [...args],
  23. level,
  24. },
  25. );
  26. });
  27. },
  28. };
  29. }) ;
  30. const consoleIntegration = defineIntegration(_consoleIntegration);
  31. /**
  32. * Console module integration.
  33. * @deprecated Use `consoleIntegration()` instead.
  34. */
  35. // eslint-disable-next-line deprecation/deprecation
  36. const Console = convertIntegrationFnToClass(INTEGRATION_NAME, consoleIntegration)
  37. ;
  38. // eslint-disable-next-line deprecation/deprecation
  39. export { Console, consoleIntegration };
  40. //# sourceMappingURL=console.js.map