@@ -28,12 +28,7 @@ function traceHeaders(): { [key: string]: string } {
28
28
*
29
29
* @param context Properties with which the span should be created
30
30
*/
31
- function startSpan ( context : SpanContext | TransactionContext ) : Transaction | Span {
32
- // @ts -ignore
33
- const hub = this as Hub ;
34
- const scope = hub . getScope ( ) ;
35
- const client = hub . getClient ( ) ;
36
-
31
+ function startSpan ( this : Hub , context : SpanContext | TransactionContext ) : Transaction | Span {
37
32
// This is our safeguard so people always get a Transaction in return.
38
33
// We set `_isTransaction: true` in {@link Sentry.startTransaction} to have a runtime check
39
34
// if the user really wanted to create a Transaction.
@@ -45,8 +40,9 @@ function startSpan(context: SpanContext | TransactionContext): Transaction | Spa
45
40
46
41
if ( ( context as TransactionContext ) . name ) {
47
42
// We are dealing with a Transaction
48
- const transaction = new Transaction ( context as TransactionContext , hub ) ;
43
+ const transaction = new Transaction ( context as TransactionContext , this ) ;
49
44
45
+ const client = this . getClient ( ) ;
50
46
// We only roll the dice on sampling for root spans of transactions because all child spans inherit this state
51
47
if ( transaction . sampled === undefined ) {
52
48
const sampleRate = ( client && client . getOptions ( ) . tracesSampleRate ) || 0 ;
@@ -66,6 +62,7 @@ function startSpan(context: SpanContext | TransactionContext): Transaction | Spa
66
62
return transaction ;
67
63
}
68
64
65
+ const scope = this . getScope ( ) ;
69
66
if ( scope ) {
70
67
// If there is a Span on the Scope we start a child and return that instead
71
68
const parentSpan = scope . getSpan ( ) ;
0 commit comments