File tree Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -217,11 +217,7 @@ export class Scope implements ScopeInterface {
217217 * @inheritDoc
218218 */
219219 public getTransaction ( ) : Transaction | undefined {
220- const span = this . getSpan ( ) as Span & { spanRecorder : { spans : Span [ ] } } ;
221- if ( span && span . spanRecorder && span . spanRecorder . spans [ 0 ] ) {
222- return span . spanRecorder . spans [ 0 ] as Transaction ;
223- }
224- return undefined ;
220+ return this . getSpan ( ) as Transaction ;
225221 }
226222
227223 /**
Original file line number Diff line number Diff line change @@ -23,9 +23,23 @@ describe('Hub', () => {
2323 } ) ;
2424
2525 describe ( 'getTransaction()' , ( ) => {
26- it ( 'should find a transaction which has been set on the scope' , ( ) => {
26+ it ( 'should find a transaction which has been set on the scope if sampled = true ' , ( ) => {
2727 const hub = new Hub ( new BrowserClient ( { tracesSampleRate : 1 } ) ) ;
2828 const transaction = hub . startTransaction ( { name : 'dogpark' } ) ;
29+ transaction . sampled = true ;
30+
31+ hub . configureScope ( scope => {
32+ scope . setSpan ( transaction ) ;
33+ } ) ;
34+
35+ expect ( hub . getScope ( ) ?. getTransaction ( ) ) . toBe ( transaction ) ;
36+ } ) ;
37+
38+ it ( 'should find a transaction which has been set on the scope if sampled = false' , ( ) => {
39+ const hub = new Hub ( new BrowserClient ( { tracesSampleRate : 1 } ) ) ;
40+ const transaction = hub . startTransaction ( { name : 'dogpark' } ) ;
41+ transaction . sampled = false ;
42+
2943 hub . configureScope ( scope => {
3044 scope . setSpan ( transaction ) ;
3145 } ) ;
You can’t perform that action at this time.
0 commit comments