linkederrors.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { defineIntegration, convertIntegrationFnToClass } from '@sentry/core';
  2. import { applyAggregateErrorsToEvent } from '@sentry/utils';
  3. import { exceptionFromError } from '../eventbuilder.js';
  4. const DEFAULT_KEY = 'cause';
  5. const DEFAULT_LIMIT = 5;
  6. const INTEGRATION_NAME = 'LinkedErrors';
  7. const _linkedErrorsIntegration = ((options = {}) => {
  8. const limit = options.limit || DEFAULT_LIMIT;
  9. const key = options.key || DEFAULT_KEY;
  10. return {
  11. name: INTEGRATION_NAME,
  12. // TODO v8: Remove this
  13. setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
  14. preprocessEvent(event, hint, client) {
  15. const options = client.getOptions();
  16. applyAggregateErrorsToEvent(
  17. // This differs from the LinkedErrors integration in core by using a different exceptionFromError function
  18. exceptionFromError,
  19. options.stackParser,
  20. options.maxValueLength,
  21. key,
  22. limit,
  23. event,
  24. hint,
  25. );
  26. },
  27. };
  28. }) ;
  29. const linkedErrorsIntegration = defineIntegration(_linkedErrorsIntegration);
  30. /**
  31. * Aggregrate linked errors in an event.
  32. * @deprecated Use `linkedErrorsIntegration()` instead.
  33. */
  34. // eslint-disable-next-line deprecation/deprecation
  35. const LinkedErrors = convertIntegrationFnToClass(INTEGRATION_NAME, linkedErrorsIntegration)
  36. ;
  37. export { LinkedErrors, linkedErrorsIntegration };
  38. //# sourceMappingURL=linkederrors.js.map