Skip to content

Commit afd1054

Browse files
authored
ref(tracing): Remove legacy method of getting transaction from scope (#4394)
In #2952, a new way of pulling the currently-active transaction off of the scope was introduced. That new way is no longer so new, and the legacy way was left in place at that time only out of an (over-)abundance of caution. It's time we removed it, both for ease of reading and for the few bytes we'll gain in bundle size reduction.
1 parent b981a58 commit afd1054

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

packages/hub/src/scope.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -266,21 +266,10 @@ export class Scope implements ScopeInterface {
266266
* @inheritDoc
267267
*/
268268
public getTransaction(): Transaction | undefined {
269-
// often, this span will be a transaction, but it's not guaranteed to be
270-
const span = this.getSpan() as undefined | (Span & { spanRecorder: { spans: Span[] } });
271-
272-
// try it the new way first
273-
if (span && span.transaction) {
274-
return span.transaction;
275-
}
276-
277-
// fallback to the old way (known bug: this only finds transactions with sampled = true)
278-
if (span && span.spanRecorder && span.spanRecorder.spans[0]) {
279-
return span.spanRecorder.spans[0] as Transaction;
280-
}
281-
282-
// neither way found a transaction
283-
return undefined;
269+
// Often, this span (if it exists at all) will be a transaction, but it's not guaranteed to be. Regardless, it will
270+
// have a pointer to the currently-active transaction.
271+
const span = this.getSpan();
272+
return span && span.transaction;
284273
}
285274

286275
/**

0 commit comments

Comments
 (0)