@@ -3,6 +3,16 @@ import type { Transaction, TransactionContext, TransactionSource } from '@sentry
33
44import { getActiveTransaction } from './tracing' ;
55
6+ interface VueRouterInstrumationOptions {
7+ /**
8+ * What to use for route labels.
9+ * By default, we use route.name (if set) and else the path.
10+ *
11+ * Default: 'name'
12+ */
13+ routeLabel : 'name' | 'path' ;
14+ }
15+
616export type VueRouterInstrumentation = < T extends Transaction > (
717 startTransaction : ( context : TransactionContext ) => T | undefined ,
818 startTransactionOnPageLoad ?: boolean ,
@@ -35,9 +45,15 @@ interface VueRouter {
3545/**
3646 * Creates routing instrumentation for Vue Router v2, v3 and v4
3747 *
48+ * You can optionally pass in an options object with the available option:
49+ * * `routeLabel`: Set this to `route` to opt-out of using `route.name` for transaction names.
50+ *
3851 * @param router The Vue Router instance that is used
3952 */
40- export function vueRouterInstrumentation ( router : VueRouter ) : VueRouterInstrumentation {
53+ export function vueRouterInstrumentation (
54+ router : VueRouter ,
55+ options : Partial < VueRouterInstrumationOptions > = { } ,
56+ ) : VueRouterInstrumentation {
4157 return (
4258 startTransaction : ( context : TransactionContext ) => Transaction | undefined ,
4359 startTransactionOnPageLoad : boolean = true ,
@@ -81,7 +97,7 @@ export function vueRouterInstrumentation(router: VueRouter): VueRouterInstrument
8197 // Determine a name for the routing transaction and where that name came from
8298 let transactionName : string = to . path ;
8399 let transactionSource : TransactionSource = 'url' ;
84- if ( to . name ) {
100+ if ( to . name && options . routeLabel !== 'path' ) {
85101 transactionName = to . name . toString ( ) ;
86102 transactionSource = 'custom' ;
87103 } else if ( to . matched [ 0 ] && to . matched [ 0 ] . path ) {
0 commit comments