@@ -638,7 +638,7 @@ describe('browserTracingIntegration', () => {
638
638
expect ( getCurrentScope ( ) . getScopeData ( ) . transactionName ) . toBe ( 'test navigation span' ) ;
639
639
} ) ;
640
640
641
- it ( "resets the scopes' propagationContexts" , ( ) => {
641
+ it ( "updates the scopes' propagationContexts on a navigation " , ( ) => {
642
642
const client = new BrowserClient (
643
643
getDefaultBrowserClientOptions ( {
644
644
integrations : [ browserTracingIntegration ( ) ] ,
@@ -675,6 +675,45 @@ describe('browserTracingIntegration', () => {
675
675
expect ( newIsolationScopePropCtx ?. traceId ) . not . toEqual ( oldIsolationScopePropCtx ?. traceId ) ;
676
676
expect ( newCurrentScopePropCtx ?. traceId ) . not . toEqual ( oldCurrentScopePropCtx ?. traceId ) ;
677
677
} ) ;
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
+ } ) ;
678
717
} ) ;
679
718
680
719
describe ( 'using the <meta> tag data' , ( ) => {
0 commit comments