transaction.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { convertIntegrationFnToClass } from '@sentry/core';
  2. const INTEGRATION_NAME = 'Transaction';
  3. const transactionIntegration = (() => {
  4. return {
  5. name: INTEGRATION_NAME,
  6. // TODO v8: Remove this
  7. setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
  8. processEvent(event) {
  9. const frames = _getFramesFromEvent(event);
  10. // use for loop so we don't have to reverse whole frames array
  11. for (let i = frames.length - 1; i >= 0; i--) {
  12. const frame = frames[i];
  13. if (frame.in_app === true) {
  14. event.transaction = _getTransaction(frame);
  15. break;
  16. }
  17. }
  18. return event;
  19. },
  20. };
  21. }) ;
  22. /**
  23. * Add node transaction to the event.
  24. * @deprecated This integration will be removed in v8.
  25. */
  26. // eslint-disable-next-line deprecation/deprecation
  27. const Transaction = convertIntegrationFnToClass(INTEGRATION_NAME, transactionIntegration)
  28. ;
  29. function _getFramesFromEvent(event) {
  30. const exception = event.exception && event.exception.values && event.exception.values[0];
  31. return (exception && exception.stacktrace && exception.stacktrace.frames) || [];
  32. }
  33. function _getTransaction(frame) {
  34. return frame.module || frame.function ? `${frame.module || '?'}/${frame.function || '?'}` : '<unknown>';
  35. }
  36. export { Transaction };
  37. //# sourceMappingURL=transaction.js.map