@sentry/integrations
Version:
Pluggable integrations that can be used to enhance JS SDKs
59 lines (49 loc) • 1.44 kB
JavaScript
/** 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();
export { Transaction };
//# sourceMappingURL=transaction.js.map