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 @@ -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 @@ -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