File tree 3 files changed +37
-26
lines changed
3 files changed +37
-26
lines changed Original file line number Diff line number Diff line change @@ -11,28 +11,6 @@ describe('Hub', () => {
11
11
jest . useRealTimers ( ) ;
12
12
} ) ;
13
13
14
- describe ( 'getTransaction' , ( ) => {
15
- test ( 'simple invoke' , ( ) => {
16
- const hub = new Hub ( new BrowserClient ( { tracesSampleRate : 1 } ) ) ;
17
- const transaction = hub . startTransaction ( { name : 'foo' } ) ;
18
- hub . configureScope ( scope => {
19
- scope . setSpan ( transaction ) ;
20
- } ) ;
21
- hub . configureScope ( s => {
22
- expect ( s . getTransaction ( ) ) . toBe ( transaction ) ;
23
- } ) ;
24
- } ) ;
25
-
26
- test ( 'not invoke' , ( ) => {
27
- const hub = new Hub ( new BrowserClient ( { tracesSampleRate : 1 } ) ) ;
28
- const transaction = hub . startTransaction ( { name : 'foo' } ) ;
29
- hub . configureScope ( s => {
30
- expect ( s . getTransaction ( ) ) . toBeUndefined ( ) ;
31
- } ) ;
32
- transaction . finish ( ) ;
33
- } ) ;
34
- } ) ;
35
-
36
14
describe ( 'spans' , ( ) => {
37
15
describe ( 'sampling' , ( ) => {
38
16
test ( 'set tracesSampleRate 0 on span' , ( ) => {
Original file line number Diff line number Diff line change
1
+ import { BrowserClient } from '@sentry/browser' ;
2
+ import { Hub } from '@sentry/hub' ;
3
+
4
+ import { addExtensionMethods } from '../src/hubextensions' ;
5
+
6
+ addExtensionMethods ( ) ;
7
+
8
+ describe ( 'Scope' , ( ) => {
9
+ afterEach ( ( ) => {
10
+ jest . resetAllMocks ( ) ;
11
+ jest . useRealTimers ( ) ;
12
+ } ) ;
13
+
14
+ describe ( 'getTransaction' , ( ) => {
15
+ test ( 'simple invoke' , ( ) => {
16
+ const hub = new Hub ( new BrowserClient ( { tracesSampleRate : 1 } ) ) ;
17
+ const transaction = hub . startTransaction ( { name : 'foo' } ) ;
18
+ hub . configureScope ( scope => {
19
+ scope . setSpan ( transaction ) ;
20
+ } ) ;
21
+ hub . configureScope ( s => {
22
+ expect ( s . getTransaction ( ) ) . toBe ( transaction ) ;
23
+ } ) ;
24
+ } ) ;
25
+
26
+ test ( 'not invoke' , ( ) => {
27
+ const hub = new Hub ( new BrowserClient ( { tracesSampleRate : 1 } ) ) ;
28
+ const transaction = hub . startTransaction ( { name : 'foo' } ) ;
29
+ hub . configureScope ( s => {
30
+ expect ( s . getTransaction ( ) ) . toBeUndefined ( ) ;
31
+ } ) ;
32
+ transaction . finish ( ) ;
33
+ } ) ;
34
+ } ) ;
35
+ } ) ;
Original file line number Diff line number Diff line change @@ -230,10 +230,8 @@ export class Scope implements ScopeInterface {
230
230
*/
231
231
public getTransaction ( ) : Transaction | undefined {
232
232
const span = this . getSpan ( ) as Span & { spanRecorder : { spans : Span [ ] } } ;
233
- if ( span ) {
234
- if ( span . spanRecorder && span . spanRecorder . spans [ 0 ] ) {
235
- return span . spanRecorder . spans [ 0 ] as Transaction ;
236
- }
233
+ if ( span && span . spanRecorder && span . spanRecorder . spans [ 0 ] ) {
234
+ return span . spanRecorder . spans [ 0 ] as Transaction ;
237
235
}
238
236
return undefined ;
239
237
}
You can’t perform that action at this time.
0 commit comments