@@ -3,10 +3,9 @@ import { BrowserClient } from '@sentry/browser';
3
3
import { getMainCarrier , Hub } from '@sentry/hub' ;
4
4
import * as hubModule from '@sentry/hub' ;
5
5
import * as utilsModule from '@sentry/utils' ; // for mocking
6
- import { base64ToUnicode , getGlobalObject , isNodeEnv , logger } from '@sentry/utils' ;
6
+ import { base64ToUnicode , computeTracestate , getGlobalObject , isNodeEnv , logger } from '@sentry/utils' ;
7
7
import * as nodeHttpModule from 'http' ;
8
8
9
- import { Transaction } from '../src' ;
10
9
import { BrowserTracing } from '../src/browser/browsertracing' ;
11
10
import { addExtensionMethods } from '../src/hubextensions' ;
12
11
import { extractTraceparentData , TRACEPARENT_REGEXP } from '../src/utils' ;
@@ -46,28 +45,27 @@ describe('Hub', () => {
46
45
expect ( transaction ) . toEqual ( expect . objectContaining ( transactionContext ) ) ;
47
46
} ) ;
48
47
49
- it ( 'creates a new tracestate value (with the right data) if not given one in transaction context' , ( ) => {
48
+ it ( 'creates a new tracestate value if not given one in transaction context' , ( ) => {
49
+ const environment = 'dogpark' ;
50
+ const release = 'off.leash.park' ;
50
51
const hub = new Hub (
51
52
new BrowserClient ( {
52
53
dsn :
'https://[email protected] /12312012' ,
53
54
tracesSampleRate : 1 ,
54
- release : 'off.leash.park' ,
55
- environment : 'dogpark' ,
55
+ release,
56
+ environment,
56
57
} ) ,
57
58
) ;
58
59
const transaction = hub . startTransaction ( { name : 'FETCH /ball' } ) ;
59
60
60
- const b64Value =
61
- 'ewAiAHAAdQBiAGwAaQBjAF8AawBlAHkAIgA6ACIAZABvAGcAcwBhAHIAZQBiAGEAZABhAHQAawBlAGUAcA' +
62
- 'BpAG4AZwBzAGUAYwByAGUAdABzACIALAAiAGUAbgB2AGkAcgBvAG4AbQBlAG4AdAAiADoAIgBkAG8AZwBwAGEAcgBrACIALAAiA' +
63
- 'HIAZQBsAGUAYQBzAGUAIgA6ACIAbwBmAGYALgBsAGUAYQBzAGgALgBwAGEAcgBrACIAfQA.' ;
64
-
65
- expect ( transaction . tracestate ) . toEqual ( b64Value ) ;
66
- expect ( JSON . parse ( base64ToUnicode ( b64Value . replace ( '.' , '=' ) ) ) ) . toEqual ( {
67
- environment : 'dogpark' ,
61
+ const b64Value = computeTracestate ( {
62
+ trace_id : transaction . traceId ,
63
+ environment,
64
+ release,
68
65
public_key : 'dogsarebadatkeepingsecrets' ,
69
- release : 'off.leash.park' ,
70
66
} ) ;
67
+
68
+ expect ( transaction . tracestate ) . toEqual ( b64Value ) ;
71
69
} ) ;
72
70
} ) ;
73
71
0 commit comments