File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -212,11 +212,7 @@ export class Scope implements ScopeInterface {
212212 * @inheritDoc
213213 */
214214 public getTransaction ( ) : Transaction | undefined {
215- const span = this . getSpan ( ) as Span & { spanRecorder : { spans : Span [ ] } } ;
216- if ( span && span . spanRecorder && span . spanRecorder . spans [ 0 ] ) {
217- return span . spanRecorder . spans [ 0 ] as Transaction ;
218- }
219- return undefined ;
215+ return this . getSpan ( ) as Transaction ;
220216 }
221217
222218 /**
Original file line number Diff line number Diff line change @@ -32,6 +32,16 @@ describe('Hub', () => {
3232 expect ( hub . getScope ( ) ?. getTransaction ( ) ) . toBe ( transaction ) ;
3333 } ) ;
3434
35+ it ( 'should find an unsampled transaction which has been set on the scope' , ( ) => {
36+ const hub = new Hub ( new BrowserClient ( { tracesSampleRate : 1 } ) ) ;
37+ const transaction = hub . startTransaction ( { name : 'dogpark' , sampled : false } ) ;
38+ hub . configureScope ( scope => {
39+ scope . setSpan ( transaction ) ;
40+ } ) ;
41+
42+ expect ( hub . getScope ( ) ?. getTransaction ( ) ) . toBe ( transaction ) ;
43+ } ) ;
44+
3545 it ( "should not find an open transaction if it's not on the scope" , ( ) => {
3646 const hub = new Hub ( new BrowserClient ( { tracesSampleRate : 1 } ) ) ;
3747 hub . startTransaction ( { name : 'dogpark' } ) ;
You can’t perform that action at this time.
0 commit comments