toucan-js
toucan-js copied to clipboard
setTransactionName not implemented in scope
trafficstars
sentry.getScope().setTransactionName('whatever'); results TypeError: sentry.getScope(...).setTransactionName is not a function.
I ended up monkey-patching this in at runtime for myself, so I could make use of it:
const scopeProto = Object.getPrototypeOf(sentry.getScope());
scopeProto.setTransactionName = function (name) {
this.adapter.setTransactionName(name);
};
const adapterProto = Object.getPrototypeOf(sentry.getScope().adapter);
const apply = adapterProto.applyToEventSync;
adapterProto.applyToEventSync = function (event) {
const applied = apply.call(this, event);
if (this._transactionName) applied.transaction = this._transactionName;
return applied;
};