1
1
import { Event , TransactionSamplingMethod } from '@sentry/types' ;
2
+ import { computeTracestate } from '@sentry/utils' ;
2
3
3
4
import { API } from '../../src/api' ;
4
5
import { eventToSentryRequest } from '../../src/request' ;
@@ -34,17 +35,22 @@ describe('eventToSentryRequest', () => {
34
35
it ( 'injects correct data for transaction events' , ( ) => {
35
36
const eventId = '1231201211212012' ;
36
37
const traceId = '0908201304152013' ;
38
+ const environment = 'dogpark' ;
39
+ const release = 'off.leash.park' ;
40
+
37
41
const event = {
38
42
contexts : { trace : { trace_id : traceId , span_id : '12261980' , op : 'pageload' } } ,
39
- environment : 'dogpark' ,
43
+ environment,
40
44
event_id : eventId ,
41
- release : 'off.leash.park' ,
45
+ release,
42
46
spans : [ ] ,
43
- tracestate :
44
- 'ewAiAGUAbgB2AGkAcgBvAG4AbQBlAG4AdAAiADoAIgBkAG8AZwBwAGEAcgBrACIALAAiAHAAdQBiAGwAaQBjAF8AawBlAHkAIgA6ACIA' +
45
- 'ZABvAGcAcwBhAHIAZQBiAGEAZABhAHQAawBlAGUAcABpAG4AZwBzAGUAYwByAGUAdABzACIALAAiAHIAZQBsAGUAYQBzAGUAIgA6ACIA' +
46
- 'bwBmAGYALgBsAGUAYQBzAGgALgBwAGEAcgBrACIAfQA.' ,
47
47
transaction : '/dogs/are/great/' ,
48
+ tracestate : computeTracestate ( {
49
+ trace_id : traceId ,
50
+ environment,
51
+ public_key : 'dogsarebadatkeepingsecrets' ,
52
+ release,
53
+ } ) ,
48
54
type : 'transaction' ,
49
55
user : { id : '1121' , username : 'CharlieDog' , ip_address : '11.21.20.12' } ,
50
56
} ;
@@ -63,15 +69,16 @@ describe('eventToSentryRequest', () => {
63
69
expect ( result . url ) . toEqual (
64
70
'https://squirrelchasers.ingest.sentry.io/api/12312012/envelope/?sentry_key=dogsarebadatkeepingsecrets&sentry_version=7' ,
65
71
) ;
72
+
66
73
expect ( envelope . envelopeHeader ) . toEqual ( {
67
74
event_id : eventId ,
68
75
sent_at : expect . any ( String ) ,
69
- trace_id : traceId ,
70
- trace : JSON . stringify ( {
71
- environment : 'dogpark' ,
76
+ trace : {
77
+ trace_id : traceId ,
78
+ environment,
72
79
public_key : 'dogsarebadatkeepingsecrets' ,
73
- release : 'off.leash.park' ,
74
- } ) ,
80
+ release,
81
+ } ,
75
82
} ) ;
76
83
expect ( envelope . itemHeader ) . toEqual ( {
77
84
type : 'transaction' ,
0 commit comments