@@ -638,7 +638,7 @@ describe('browserTracingIntegration', () => {
638638 expect ( getCurrentScope ( ) . getScopeData ( ) . transactionName ) . toBe ( 'test navigation span' ) ;
639639 } ) ;
640640
641- it ( "resets the scopes' propagationContexts" , ( ) => {
641+ it ( "updates the scopes' propagationContexts on a navigation " , ( ) => {
642642 const client = new BrowserClient (
643643 getDefaultBrowserClientOptions ( {
644644 integrations : [ browserTracingIntegration ( ) ] ,
@@ -675,6 +675,45 @@ describe('browserTracingIntegration', () => {
675675 expect ( newIsolationScopePropCtx ?. traceId ) . not . toEqual ( oldIsolationScopePropCtx ?. traceId ) ;
676676 expect ( newCurrentScopePropCtx ?. traceId ) . not . toEqual ( oldCurrentScopePropCtx ?. traceId ) ;
677677 } ) ;
678+
679+ it ( "saves the span's sampling decision and its DSC on the propagationContext when the span finishes" , ( ) => {
680+ const client = new BrowserClient (
681+ getDefaultBrowserClientOptions ( {
682+ tracesSampleRate : 1 ,
683+ integrations : [ browserTracingIntegration ( { instrumentPageLoad : false } ) ] ,
684+ } ) ,
685+ ) ;
686+ setCurrentClient ( client ) ;
687+ client . init ( ) ;
688+
689+ const navigationSpan = startBrowserTracingNavigationSpan ( client , {
690+ name : 'mySpan' ,
691+ attributes : { [ SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ] : 'route' } ,
692+ } ) ;
693+
694+ const propCtxBeforeEnd = getCurrentScope ( ) . getPropagationContext ( ) ;
695+ expect ( propCtxBeforeEnd ) . toStrictEqual ( {
696+ spanId : expect . stringMatching ( / [ a - f 0 - 9 ] { 16 } / ) ,
697+ traceId : expect . stringMatching ( / [ a - f 0 - 9 ] { 32 } / ) ,
698+ } ) ;
699+
700+ navigationSpan ! . end ( ) ;
701+
702+ const propCtxAfterEnd = getCurrentScope ( ) . getPropagationContext ( ) ;
703+ expect ( propCtxAfterEnd ) . toStrictEqual ( {
704+ spanId : propCtxBeforeEnd ?. spanId ,
705+ traceId : propCtxBeforeEnd ?. traceId ,
706+ sampled : true ,
707+ dsc : {
708+ environment : 'production' ,
709+ public_key : 'examplePublicKey' ,
710+ sample_rate : '1' ,
711+ sampled : 'true' ,
712+ transaction : 'mySpan' ,
713+ trace_id : propCtxBeforeEnd ?. traceId ,
714+ } ,
715+ } ) ;
716+ } ) ;
678717 } ) ;
679718
680719 describe ( 'using the <meta> tag data' , ( ) => {
0 commit comments