UNPKG

@sentry/integrations

Version:
61 lines (50 loc) 1.51 kB
Object.defineProperty(exports, '__esModule', { value: true }); /** Add node transaction to the event */ class Transaction {constructor() { Transaction.prototype.__init.call(this); } /** * @inheritDoc */ static __initStatic() {this.id = 'Transaction';} /** * @inheritDoc */ __init() {this.name = Transaction.id;} /** * @inheritDoc */ setupOnce(addGlobalEventProcessor, getCurrentHub) { addGlobalEventProcessor(event => { const self = getCurrentHub().getIntegration(Transaction); if (self) { return self.process(event); } return event; }); } /** * @inheritDoc */ process(event) { const frames = this._getFramesFromEvent(event); // use for loop so we don't have to reverse whole frames array for (let i = frames.length - 1; i >= 0; i--) { const frame = frames[i]; if (frame.in_app === true) { event.transaction = this._getTransaction(frame); break; } } return event; } /** JSDoc */ _getFramesFromEvent(event) { const exception = event.exception && event.exception.values && event.exception.values[0]; return (exception && exception.stacktrace && exception.stacktrace.frames) || []; } /** JSDoc */ _getTransaction(frame) { return frame.module || frame.function ? `${frame.module || '?'}/${frame.function || '?'}` : '<unknown>'; } } Transaction.__initStatic(); exports.Transaction = Transaction; //# sourceMappingURL=transaction.js.map