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 {
217
217
* @inheritDoc
218
218
*/
219
219
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 ;
225
221
}
226
222
227
223
/**
Original file line number Diff line number Diff line change @@ -23,9 +23,23 @@ describe('Hub', () => {
23
23
} ) ;
24
24
25
25
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 ' , ( ) => {
27
27
const hub = new Hub ( new BrowserClient ( { tracesSampleRate : 1 } ) ) ;
28
28
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
+
29
43
hub . configureScope ( scope => {
30
44
scope . setSpan ( transaction ) ;
31
45
} ) ;
You can’t perform that action at this time.
0 commit comments