@@ -11,7 +11,7 @@ describe('React Router v4', () => {
1111 startTransactionOnPageLoad ?: boolean ;
1212 startTransactionOnLocationChange ?: boolean ;
1313 routes ?: RouteConfig [ ] ;
14- } ) : [ jest . Mock , any , { mockSetName : jest . Mock ; mockFinish : jest . Mock } ] {
14+ } ) : [ jest . Mock , any , { mockSetName : jest . Mock ; mockFinish : jest . Mock ; mockSetMetadata : jest . Mock } ] {
1515 const options = {
1616 matchPath : _opts && _opts . routes !== undefined ? matchPath : undefined ,
1717 routes : undefined ,
@@ -22,13 +22,16 @@ describe('React Router v4', () => {
2222 const history = createMemoryHistory ( ) ;
2323 const mockFinish = jest . fn ( ) ;
2424 const mockSetName = jest . fn ( ) ;
25- const mockStartTransaction = jest . fn ( ) . mockReturnValue ( { setName : mockSetName , finish : mockFinish } ) ;
25+ const mockSetMetadata = jest . fn ( ) ;
26+ const mockStartTransaction = jest
27+ . fn ( )
28+ . mockReturnValue ( { setName : mockSetName , finish : mockFinish , setMetadata : mockSetMetadata } ) ;
2629 reactRouterV4Instrumentation ( history , options . routes , options . matchPath ) (
2730 mockStartTransaction ,
2831 options . startTransactionOnPageLoad ,
2932 options . startTransactionOnLocationChange ,
3033 ) ;
31- return [ mockStartTransaction , history , { mockSetName, mockFinish } ] ;
34+ return [ mockStartTransaction , history , { mockSetName, mockFinish, mockSetMetadata } ] ;
3235 }
3336
3437 it ( 'starts a pageload transaction when instrumentation is started' , ( ) => {
@@ -38,6 +41,7 @@ describe('React Router v4', () => {
3841 name : '/' ,
3942 op : 'pageload' ,
4043 tags : { 'routing.instrumentation' : 'react-router-v4' } ,
44+ metadata : { source : 'url' } ,
4145 } ) ;
4246 } ) ;
4347
@@ -66,6 +70,7 @@ describe('React Router v4', () => {
6670 name : '/about' ,
6771 op : 'navigation' ,
6872 tags : { 'routing.instrumentation' : 'react-router-v4' } ,
73+ metadata : { source : 'url' } ,
6974 } ) ;
7075
7176 act ( ( ) => {
@@ -76,6 +81,7 @@ describe('React Router v4', () => {
7681 name : '/features' ,
7782 op : 'navigation' ,
7883 tags : { 'routing.instrumentation' : 'react-router-v4' } ,
84+ metadata : { source : 'url' } ,
7985 } ) ;
8086 } ) ;
8187
@@ -153,11 +159,12 @@ describe('React Router v4', () => {
153159 name : '/users/123' ,
154160 op : 'navigation' ,
155161 tags : { 'routing.instrumentation' : 'react-router-v4' } ,
162+ metadata : { source : 'url' } ,
156163 } ) ;
157164 } ) ;
158165
159166 it ( 'normalizes transaction name with custom Route' , ( ) => {
160- const [ mockStartTransaction , history , { mockSetName } ] = createInstrumentation ( ) ;
167+ const [ mockStartTransaction , history , { mockSetName, mockSetMetadata } ] = createInstrumentation ( ) ;
161168 const SentryRoute = withSentryRouting ( Route ) ;
162169 const { getByText } = render (
163170 < Router history = { history } >
@@ -179,13 +186,15 @@ describe('React Router v4', () => {
179186 name : '/users/123' ,
180187 op : 'navigation' ,
181188 tags : { 'routing.instrumentation' : 'react-router-v4' } ,
189+ metadata : { source : 'url' } ,
182190 } ) ;
183191 expect ( mockSetName ) . toHaveBeenCalledTimes ( 2 ) ;
184192 expect ( mockSetName ) . toHaveBeenLastCalledWith ( '/users/:userid' ) ;
193+ expect ( mockSetMetadata ) . toHaveBeenLastCalledWith ( { source : 'route' } ) ;
185194 } ) ;
186195
187196 it ( 'normalizes nested transaction names with custom Route' , ( ) => {
188- const [ mockStartTransaction , history , { mockSetName } ] = createInstrumentation ( ) ;
197+ const [ mockStartTransaction , history , { mockSetName, mockSetMetadata } ] = createInstrumentation ( ) ;
189198 const SentryRoute = withSentryRouting ( Route ) ;
190199 const { getByText } = render (
191200 < Router history = { history } >
@@ -207,9 +216,11 @@ describe('React Router v4', () => {
207216 name : '/organizations/1234/v1/758' ,
208217 op : 'navigation' ,
209218 tags : { 'routing.instrumentation' : 'react-router-v4' } ,
219+ metadata : { source : 'url' } ,
210220 } ) ;
211221 expect ( mockSetName ) . toHaveBeenCalledTimes ( 2 ) ;
212222 expect ( mockSetName ) . toHaveBeenLastCalledWith ( '/organizations/:orgid/v1/:teamid' ) ;
223+ expect ( mockSetMetadata ) . toHaveBeenLastCalledWith ( { source : 'route' } ) ;
213224
214225 act ( ( ) => {
215226 history . push ( '/organizations/543' ) ;
@@ -221,9 +232,11 @@ describe('React Router v4', () => {
221232 name : '/organizations/543' ,
222233 op : 'navigation' ,
223234 tags : { 'routing.instrumentation' : 'react-router-v4' } ,
235+ metadata : { source : 'url' } ,
224236 } ) ;
225237 expect ( mockSetName ) . toHaveBeenCalledTimes ( 3 ) ;
226238 expect ( mockSetName ) . toHaveBeenLastCalledWith ( '/organizations/:orgid' ) ;
239+ expect ( mockSetMetadata ) . toHaveBeenLastCalledWith ( { source : 'route' } ) ;
227240 } ) ;
228241
229242 it ( 'matches with route object' , ( ) => {
@@ -253,6 +266,7 @@ describe('React Router v4', () => {
253266 name : '/organizations/:orgid/v1/:teamid' ,
254267 op : 'navigation' ,
255268 tags : { 'routing.instrumentation' : 'react-router-v4' } ,
269+ metadata : { source : 'route' } ,
256270 } ) ;
257271
258272 act ( ( ) => {
@@ -263,6 +277,7 @@ describe('React Router v4', () => {
263277 name : '/organizations/:orgid' ,
264278 op : 'navigation' ,
265279 tags : { 'routing.instrumentation' : 'react-router-v4' } ,
280+ metadata : { source : 'route' } ,
266281 } ) ;
267282 } ) ;
268283} ) ;
0 commit comments