@@ -30,48 +30,71 @@ describe('Hub', () => {
30
30
} ) ;
31
31
32
32
describe ( 'transaction creation' , ( ) => {
33
+ const hub = new Hub (
34
+ new BrowserClient ( {
35
+ dsn :
'https://[email protected] /12312012' ,
36
+ environment : 'dogpark' ,
37
+ release : 'off.leash.trail' ,
38
+ } ) ,
39
+ ) ;
40
+
33
41
it ( 'uses inherited values when given in transaction context' , ( ) => {
34
42
const transactionContext = {
35
- name : 'dogpark ' ,
43
+ name : 'FETCH /ball ' ,
36
44
traceId : '12312012123120121231201212312012' ,
37
45
parentSpanId : '1121201211212012' ,
38
- metadata : { tracestate : { sentry : 'sentry=doGsaREgReaT' } } ,
46
+ metadata : { tracestate : { sentry : 'sentry=doGsaREgReaT' , thirdparty : 'maisey=silly;charlie=goofy' } } ,
39
47
} ;
40
- const hub = new Hub ( new BrowserClient ( { tracesSampleRate : 1 } ) ) ;
48
+
41
49
const transaction = hub . startTransaction ( transactionContext ) ;
42
50
43
- expect ( transaction ) . toEqual (
44
- expect . objectContaining ( {
45
- name : 'dogpark' ,
46
- traceId : '12312012123120121231201212312012' ,
47
- parentSpanId : '1121201211212012' ,
48
- metadata : expect . objectContaining ( { tracestate : { sentry : 'sentry=doGsaREgReaT' } } ) ,
49
- } ) ,
50
- ) ;
51
+ expect ( transaction ) . toEqual ( expect . objectContaining ( transactionContext ) ) ;
51
52
} ) ;
52
53
53
- it ( 'creates a new tracestate value if not given one in transaction context' , ( ) => {
54
- const environment = 'dogpark' ;
55
- const release = 'off.leash.park' ;
56
- const hub = new Hub (
57
- new BrowserClient ( {
58
- dsn :
'https://[email protected] /12312012' ,
59
- release,
60
- environment,
61
- } ) ,
62
- ) ;
54
+ it ( 'creates a new tracestate value if no tracestate data in transaction context' , ( ) => {
63
55
const transaction = hub . startTransaction ( { name : 'FETCH /ball' } ) ;
64
56
65
57
const b64Value = computeTracestateValue ( {
66
58
traceId : transaction . traceId ,
67
- environment,
68
- release,
59
+ environment : 'dogpark' ,
60
+ release : 'off.leash.trail' ,
69
61
publicKey : 'dogsarebadatkeepingsecrets' ,
70
62
} ) ;
71
63
72
64
expect ( transaction . metadata ?. tracestate ?. sentry ) . toEqual ( `sentry=${ b64Value } ` ) ;
73
65
} ) ;
74
66
67
+ it ( 'creates a new tracestate value if tracestate data in transaction context only contains third party data' , ( ) => {
68
+ const transactionContext = {
69
+ name : 'FETCH /ball' ,
70
+ traceId : '12312012123120121231201212312012' ,
71
+ parentSpanId : '1121201211212012' ,
72
+ metadata : { tracestate : { thirdparty : 'maisey=silly;charlie=goofy' } } ,
73
+ } ;
74
+
75
+ const transaction = hub . startTransaction ( transactionContext ) ;
76
+
77
+ const b64Value = computeTracestateValue ( {
78
+ traceId : transaction . traceId ,
79
+ environment : 'dogpark' ,
80
+ release : 'off.leash.trail' ,
81
+ publicKey : 'dogsarebadatkeepingsecrets' ,
82
+ } ) ;
83
+
84
+ expect ( transaction ) . toEqual (
85
+ expect . objectContaining ( {
86
+ metadata : {
87
+ tracestate : {
88
+ // a new value for `sentry` is created
89
+ sentry : `sentry=${ b64Value } ` ,
90
+ // the third-party value isn't lost
91
+ thirdparty : 'maisey=silly;charlie=goofy' ,
92
+ } ,
93
+ } ,
94
+ } ) ,
95
+ ) ;
96
+ } ) ;
97
+
75
98
it ( 'uses default environment if none given' , ( ) => {
76
99
const release = 'off.leash.park' ;
77
100
initSDK ( {
0 commit comments