From a5478833853a38385dbf49e78599b5df6c76dc93 Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Thu, 10 Feb 2022 07:01:46 -0500 Subject: [PATCH] fix(vue): Check if route name is defined before casting (#4530) Ref: https://github.com/getsentry/sentry-javascript/pull/4483 `to.name` can be undefined, so we should guard against it --- packages/vue/src/router.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/vue/src/router.ts b/packages/vue/src/router.ts index a6cb76685c69..fd070afa8ca3 100644 --- a/packages/vue/src/router.ts +++ b/packages/vue/src/router.ts @@ -54,7 +54,7 @@ export function vueRouterInstrumentation(router: VueRouter): VueRouterInstrument if (startTransactionOnPageLoad && isPageLoadNavigation) { startTransaction({ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - name: to.name.toString() || to.path, + name: (to.name && to.name.toString()) || to.path, op: 'pageload', tags, data, @@ -64,7 +64,7 @@ export function vueRouterInstrumentation(router: VueRouter): VueRouterInstrument if (startTransactionOnLocationChange && !isPageLoadNavigation) { startTransaction({ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - name: to.name.toString() || (to.matched[0] && to.matched[0].path) || to.path, + name: (to.name && to.name.toString()) || (to.matched[0] && to.matched[0].path) || to.path, op: 'navigation', tags, data,