transaction.js 1.4 KB

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