File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -263,12 +263,14 @@ function computeRootMatch(pathname: string): Match {
263
263
export function withSentryRouting < P extends Record < string , any > , R extends React . ComponentType < P > > ( Route : R ) : R {
264
264
const componentDisplayName = ( Route as any ) . displayName || ( Route as any ) . name ;
265
265
266
- const activeRootSpan = getActiveRootSpan ( ) ;
267
-
268
266
const WrappedRoute : React . FC < P > = ( props : P ) => {
269
- if ( activeRootSpan && props && props . computedMatch && props . computedMatch . isExact ) {
270
- activeRootSpan . updateName ( props . computedMatch . path ) ;
271
- activeRootSpan . setAttribute ( SEMANTIC_ATTRIBUTE_SENTRY_SOURCE , 'route' ) ;
267
+ if ( props && props . computedMatch && props . computedMatch . isExact ) {
268
+ const route = props . computedMatch . path ;
269
+ const activeRootSpan = getActiveRootSpan ( ) ;
270
+ if ( activeRootSpan ) {
271
+ activeRootSpan . updateName ( route ) ;
272
+ activeRootSpan . setAttribute ( SEMANTIC_ATTRIBUTE_SENTRY_SOURCE , 'route' ) ;
273
+ }
272
274
}
273
275
274
276
// @ts -expect-error Setting more specific React Component typing for `R` generic above
You can’t perform that action at this time.
0 commit comments