File tree Expand file tree Collapse file tree 3 files changed +37
-26
lines changed Expand file tree Collapse file tree 3 files changed +37
-26
lines changed Original file line number Diff line number Diff line change @@ -11,28 +11,6 @@ describe('Hub', () => {
1111 jest . useRealTimers ( ) ;
1212 } ) ;
1313
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-
3614 describe ( 'spans' , ( ) => {
3715 describe ( 'sampling' , ( ) => {
3816 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 {
230230 */
231231 public getTransaction ( ) : Transaction | undefined {
232232 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 ;
237235 }
238236 return undefined ;
239237 }
You can’t perform that action at this time.
0 commit comments