66 TransactionContext ,
77 TransactionMetadata ,
88} from '@sentry/types' ;
9- import { dropUndefinedKeys , isInstanceOf , logger } from '@sentry/utils' ;
9+ import { dropUndefinedKeys , logger } from '@sentry/utils' ;
1010
1111import { Span as SpanClass , SpanRecorder } from './span' ;
1212
@@ -21,7 +21,7 @@ export class Transaction extends SpanClass implements TransactionInterface {
2121 /**
2222 * The reference to the current hub.
2323 */
24- private readonly _hub : Hub = ( getCurrentHub ( ) as unknown ) as Hub ;
24+ private readonly _hub : Hub ;
2525
2626 private _trimEnd ?: boolean ;
2727
@@ -35,16 +35,14 @@ export class Transaction extends SpanClass implements TransactionInterface {
3535 public constructor ( transactionContext : TransactionContext , hub ?: Hub ) {
3636 super ( transactionContext ) ;
3737
38- if ( isInstanceOf ( hub , Hub ) ) {
39- this . _hub = hub as Hub ;
40- }
41-
4238 this . name = transactionContext . name || '' ;
43-
4439 this . metadata = transactionContext . metadata || { } ;
4540 this . _trimEnd = transactionContext . trimEnd ;
41+ this . _hub = hub || getCurrentHub ( ) ;
4642
47- // this is because transactions are also spans, and spans have a transaction pointer
43+ // this is because transactions are also spans, and spans have a transaction pointer (it doesn't get set in `super`
44+ // because theoretically you can create a span without a transaction, though at the moment it doesn't do you much
45+ // good)
4846 this . transaction = this ;
4947 }
5048
0 commit comments