@@ -3,6 +3,16 @@ import type { Transaction, TransactionContext, TransactionSource } from '@sentry
3
3
4
4
import { getActiveTransaction } from './tracing' ;
5
5
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
+
6
16
export type VueRouterInstrumentation = < T extends Transaction > (
7
17
startTransaction : ( context : TransactionContext ) => T | undefined ,
8
18
startTransactionOnPageLoad ?: boolean ,
@@ -35,9 +45,15 @@ interface VueRouter {
35
45
/**
36
46
* Creates routing instrumentation for Vue Router v2, v3 and v4
37
47
*
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
+ *
38
51
* @param router The Vue Router instance that is used
39
52
*/
40
- export function vueRouterInstrumentation ( router : VueRouter ) : VueRouterInstrumentation {
53
+ export function vueRouterInstrumentation (
54
+ router : VueRouter ,
55
+ options : Partial < VueRouterInstrumationOptions > = { } ,
56
+ ) : VueRouterInstrumentation {
41
57
return (
42
58
startTransaction : ( context : TransactionContext ) => Transaction | undefined ,
43
59
startTransactionOnPageLoad : boolean = true ,
@@ -81,7 +97,7 @@ export function vueRouterInstrumentation(router: VueRouter): VueRouterInstrument
81
97
// Determine a name for the routing transaction and where that name came from
82
98
let transactionName : string = to . path ;
83
99
let transactionSource : TransactionSource = 'url' ;
84
- if ( to . name ) {
100
+ if ( to . name && options . routeLabel !== 'path' ) {
85
101
transactionName = to . name . toString ( ) ;
86
102
transactionSource = 'custom' ;
87
103
} else if ( to . matched [ 0 ] && to . matched [ 0 ] . path ) {
0 commit comments