toucan-js icon indicating copy to clipboard operation
toucan-js copied to clipboard

setTransactionName not implemented in scope

Open MattIPv4 opened this issue 3 years ago • 1 comments
trafficstars

sentry.getScope().setTransactionName('whatever'); results TypeError: sentry.getScope(...).setTransactionName is not a function.

MattIPv4 avatar Oct 23 '22 16:10 MattIPv4

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;
};

MattIPv4 avatar Oct 23 '22 16:10 MattIPv4

Thanks for filing! This should be fixed now in 3.0.0

Please reopen if this is still an issue.

robertcepa avatar Dec 06 '22 07:12 robertcepa