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 {
212
212
* @inheritDoc
213
213
*/
214
214
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 ;
220
216
}
221
217
222
218
/**
Original file line number Diff line number Diff line change @@ -32,6 +32,16 @@ describe('Hub', () => {
32
32
expect ( hub . getScope ( ) ?. getTransaction ( ) ) . toBe ( transaction ) ;
33
33
} ) ;
34
34
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
+
35
45
it ( "should not find an open transaction if it's not on the scope" , ( ) => {
36
46
const hub = new Hub ( new BrowserClient ( { tracesSampleRate : 1 } ) ) ;
37
47
hub . startTransaction ( { name : 'dogpark' } ) ;
You can’t perform that action at this time.
0 commit comments