Skip to content

Commit 96598a8

Browse files
committed
fix(vue): Check if route name is defined before casting
Ref: #4483 `to.name` can be undefined, so we should guard against it
1 parent 5df78df commit 96598a8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/vue/src/router.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function vueRouterInstrumentation(router: VueRouter): VueRouterInstrument
5454
if (startTransactionOnPageLoad && isPageLoadNavigation) {
5555
startTransaction({
5656
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
57-
name: to.name.toString() || to.path,
57+
name: (to.name && to.name.toString()) || to.path,
5858
op: 'pageload',
5959
tags,
6060
data,
@@ -64,7 +64,7 @@ export function vueRouterInstrumentation(router: VueRouter): VueRouterInstrument
6464
if (startTransactionOnLocationChange && !isPageLoadNavigation) {
6565
startTransaction({
6666
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
67-
name: to.name.toString() || (to.matched[0] && to.matched[0].path) || to.path,
67+
name: (to.name && to.name.toString()) || (to.matched[0] && to.matched[0].path) || to.path,
6868
op: 'navigation',
6969
tags,
7070
data,

0 commit comments

Comments
 (0)