@@ -11,7 +11,7 @@ describe('React Router v4', () => {
11
11
startTransactionOnPageLoad ?: boolean ;
12
12
startTransactionOnLocationChange ?: boolean ;
13
13
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 } ] {
15
15
const options = {
16
16
matchPath : _opts && _opts . routes !== undefined ? matchPath : undefined ,
17
17
routes : undefined ,
@@ -22,13 +22,16 @@ describe('React Router v4', () => {
22
22
const history = createMemoryHistory ( ) ;
23
23
const mockFinish = jest . fn ( ) ;
24
24
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 } ) ;
26
29
reactRouterV4Instrumentation ( history , options . routes , options . matchPath ) (
27
30
mockStartTransaction ,
28
31
options . startTransactionOnPageLoad ,
29
32
options . startTransactionOnLocationChange ,
30
33
) ;
31
- return [ mockStartTransaction , history , { mockSetName, mockFinish } ] ;
34
+ return [ mockStartTransaction , history , { mockSetName, mockFinish, mockSetMetadata } ] ;
32
35
}
33
36
34
37
it ( 'starts a pageload transaction when instrumentation is started' , ( ) => {
@@ -38,6 +41,7 @@ describe('React Router v4', () => {
38
41
name : '/' ,
39
42
op : 'pageload' ,
40
43
tags : { 'routing.instrumentation' : 'react-router-v4' } ,
44
+ metadata : { source : 'url' } ,
41
45
} ) ;
42
46
} ) ;
43
47
@@ -66,6 +70,7 @@ describe('React Router v4', () => {
66
70
name : '/about' ,
67
71
op : 'navigation' ,
68
72
tags : { 'routing.instrumentation' : 'react-router-v4' } ,
73
+ metadata : { source : 'url' } ,
69
74
} ) ;
70
75
71
76
act ( ( ) => {
@@ -76,6 +81,7 @@ describe('React Router v4', () => {
76
81
name : '/features' ,
77
82
op : 'navigation' ,
78
83
tags : { 'routing.instrumentation' : 'react-router-v4' } ,
84
+ metadata : { source : 'url' } ,
79
85
} ) ;
80
86
} ) ;
81
87
@@ -153,11 +159,12 @@ describe('React Router v4', () => {
153
159
name : '/users/123' ,
154
160
op : 'navigation' ,
155
161
tags : { 'routing.instrumentation' : 'react-router-v4' } ,
162
+ metadata : { source : 'url' } ,
156
163
} ) ;
157
164
} ) ;
158
165
159
166
it ( 'normalizes transaction name with custom Route' , ( ) => {
160
- const [ mockStartTransaction , history , { mockSetName } ] = createInstrumentation ( ) ;
167
+ const [ mockStartTransaction , history , { mockSetName, mockSetMetadata } ] = createInstrumentation ( ) ;
161
168
const SentryRoute = withSentryRouting ( Route ) ;
162
169
const { getByText } = render (
163
170
< Router history = { history } >
@@ -179,13 +186,15 @@ describe('React Router v4', () => {
179
186
name : '/users/123' ,
180
187
op : 'navigation' ,
181
188
tags : { 'routing.instrumentation' : 'react-router-v4' } ,
189
+ metadata : { source : 'url' } ,
182
190
} ) ;
183
191
expect ( mockSetName ) . toHaveBeenCalledTimes ( 2 ) ;
184
192
expect ( mockSetName ) . toHaveBeenLastCalledWith ( '/users/:userid' ) ;
193
+ expect ( mockSetMetadata ) . toHaveBeenLastCalledWith ( { source : 'route' } ) ;
185
194
} ) ;
186
195
187
196
it ( 'normalizes nested transaction names with custom Route' , ( ) => {
188
- const [ mockStartTransaction , history , { mockSetName } ] = createInstrumentation ( ) ;
197
+ const [ mockStartTransaction , history , { mockSetName, mockSetMetadata } ] = createInstrumentation ( ) ;
189
198
const SentryRoute = withSentryRouting ( Route ) ;
190
199
const { getByText } = render (
191
200
< Router history = { history } >
@@ -207,9 +216,11 @@ describe('React Router v4', () => {
207
216
name : '/organizations/1234/v1/758' ,
208
217
op : 'navigation' ,
209
218
tags : { 'routing.instrumentation' : 'react-router-v4' } ,
219
+ metadata : { source : 'url' } ,
210
220
} ) ;
211
221
expect ( mockSetName ) . toHaveBeenCalledTimes ( 2 ) ;
212
222
expect ( mockSetName ) . toHaveBeenLastCalledWith ( '/organizations/:orgid/v1/:teamid' ) ;
223
+ expect ( mockSetMetadata ) . toHaveBeenLastCalledWith ( { source : 'route' } ) ;
213
224
214
225
act ( ( ) => {
215
226
history . push ( '/organizations/543' ) ;
@@ -221,9 +232,11 @@ describe('React Router v4', () => {
221
232
name : '/organizations/543' ,
222
233
op : 'navigation' ,
223
234
tags : { 'routing.instrumentation' : 'react-router-v4' } ,
235
+ metadata : { source : 'url' } ,
224
236
} ) ;
225
237
expect ( mockSetName ) . toHaveBeenCalledTimes ( 3 ) ;
226
238
expect ( mockSetName ) . toHaveBeenLastCalledWith ( '/organizations/:orgid' ) ;
239
+ expect ( mockSetMetadata ) . toHaveBeenLastCalledWith ( { source : 'route' } ) ;
227
240
} ) ;
228
241
229
242
it ( 'matches with route object' , ( ) => {
@@ -253,6 +266,7 @@ describe('React Router v4', () => {
253
266
name : '/organizations/:orgid/v1/:teamid' ,
254
267
op : 'navigation' ,
255
268
tags : { 'routing.instrumentation' : 'react-router-v4' } ,
269
+ metadata : { source : 'route' } ,
256
270
} ) ;
257
271
258
272
act ( ( ) => {
@@ -263,6 +277,7 @@ describe('React Router v4', () => {
263
277
name : '/organizations/:orgid' ,
264
278
op : 'navigation' ,
265
279
tags : { 'routing.instrumentation' : 'react-router-v4' } ,
280
+ metadata : { source : 'route' } ,
266
281
} ) ;
267
282
} ) ;
268
283
} ) ;
0 commit comments