@@ -166,7 +166,8 @@ function _startTransaction(
166166 transactionContext : TransactionContext ,
167167 customSamplingContext ?: CustomSamplingContext ,
168168) : Transaction {
169- const options = this . getClient ( ) ?. getOptions ( ) || { } ;
169+ const client = this . getClient ( ) ;
170+ const options = ( client && client . getOptions ( ) ) || { } ;
170171
171172 let transaction = new Transaction ( transactionContext , this ) ;
172173 transaction = sample ( transaction , options , {
@@ -175,7 +176,7 @@ function _startTransaction(
175176 ...customSamplingContext ,
176177 } ) ;
177178 if ( transaction . sampled ) {
178- transaction . initSpanRecorder ( options . _experiments ?. maxSpans as number ) ;
179+ transaction . initSpanRecorder ( options . _experiments && ( options . _experiments . maxSpans as number ) ) ;
179180 }
180181 return transaction ;
181182}
@@ -190,7 +191,8 @@ export function startIdleTransaction(
190191 onScope ?: boolean ,
191192 customSamplingContext ?: CustomSamplingContext ,
192193) : IdleTransaction {
193- const options = hub . getClient ( ) ?. getOptions ( ) || { } ;
194+ const client = hub . getClient ( ) ;
195+ const options = ( client && client . getOptions ( ) ) || { } ;
194196
195197 let transaction = new IdleTransaction ( transactionContext , hub , idleTimeout , onScope ) ;
196198 transaction = sample ( transaction , options , {
@@ -199,7 +201,7 @@ export function startIdleTransaction(
199201 ...customSamplingContext ,
200202 } ) ;
201203 if ( transaction . sampled ) {
202- transaction . initSpanRecorder ( options . _experiments ?. maxSpans as number ) ;
204+ transaction . initSpanRecorder ( options . _experiments && ( options . _experiments . maxSpans as number ) ) ;
203205 }
204206 return transaction ;
205207}
0 commit comments