1
1
import { BrowserClient } from '@sentry/browser' ;
2
2
import { Hub , Scope } from '@sentry/hub' ;
3
- import { Span , Transaction } from '@sentry/types' ;
4
3
5
4
import { addExtensionMethods } from '../src/hubextensions' ;
6
5
@@ -21,21 +20,18 @@ describe('Hub', () => {
21
20
} ) ;
22
21
test ( 'set tracesSampleRate 0 on transaction' , ( ) => {
23
22
const hub = new Hub ( new BrowserClient ( { tracesSampleRate : 0 } ) ) ;
24
- // @ts -ignore
25
- const transaction = hub . startSpan ( { name : 'foo' } ) as any ;
23
+ const transaction = hub . startTransaction ( { name : 'foo' } ) ;
26
24
expect ( transaction . sampled ) . toBe ( false ) ;
27
25
} ) ;
28
26
test ( 'set tracesSampleRate 1 on transaction' , ( ) => {
29
27
const hub = new Hub ( new BrowserClient ( { tracesSampleRate : 1 } ) ) ;
30
- // @ts -ignore
31
- const transaction = hub . startSpan ( { name : 'foo' } ) as any ;
28
+ const transaction = hub . startTransaction ( { name : 'foo' } ) ;
32
29
expect ( transaction . sampled ) . toBeTruthy ( ) ;
33
30
} ) ;
34
31
test ( 'set tracesSampleRate should be propergated to children' , ( ) => {
35
32
const hub = new Hub ( new BrowserClient ( { tracesSampleRate : 0 } ) ) ;
36
- // @ts -ignore
37
- const transaction = hub . startSpan ( { name : 'foo' } ) as any ;
38
- const child = transaction . startChild ( { op : 1 } ) ;
33
+ const transaction = hub . startTransaction ( { name : 'foo' } ) ;
34
+ const child = transaction . startChild ( { op : 'test' } ) ;
39
35
expect ( child . sampled ) . toBeFalsy ( ) ;
40
36
} ) ;
41
37
} ) ;
@@ -49,8 +45,7 @@ describe('Hub', () => {
49
45
50
46
test ( 'simple standalone Transaction' , ( ) => {
51
47
const hub = new Hub ( new BrowserClient ( { tracesSampleRate : 1 } ) ) ;
52
- // @ts -ignore
53
- const transaction = hub . startSpan ( { name : 'transaction' } ) as Transaction ;
48
+ const transaction = hub . startTransaction ( { name : 'transaction' } ) ;
54
49
expect ( transaction . spanId ) . toBeTruthy ( ) ;
55
50
// tslint:disable-next-line: no-unbound-method
56
51
expect ( transaction . setName ) . toBeTruthy ( ) ;
@@ -71,8 +66,7 @@ describe('Hub', () => {
71
66
test ( 'create a child if there is a Span already on the scope' , ( ) => {
72
67
const myScope = new Scope ( ) ;
73
68
const hub = new Hub ( new BrowserClient ( { tracesSampleRate : 1 } ) , myScope ) ;
74
- // @ts -ignore
75
- const transaction = hub . startSpan ( { name : 'transaction' } ) as Transaction ;
69
+ const transaction = hub . startTransaction ( { name : 'transaction' } ) ;
76
70
hub . configureScope ( scope => {
77
71
scope . setSpan ( transaction ) ;
78
72
} ) ;
0 commit comments