Skip to content

Commit

Permalink
fix(vue): Check if route name is defined before casting (#4530)
Browse files Browse the repository at this point in the history
Ref: #4483

`to.name` can be undefined, so we should guard against it
  • Loading branch information
AbhiPrasad committed Feb 10, 2022
1 parent ff5595c commit a547883
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/vue/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit a547883

Please sign in to comment.