@@ -175,17 +175,22 @@ export function extractPathForTransaction(
175
175
type TransactionNamingScheme = 'path' | 'methodPath' | 'handler' ;
176
176
177
177
/** JSDoc */
178
- function extractTransaction ( req : CrossPlatformRequest , type : boolean | TransactionNamingScheme ) : string {
178
+ function extractTransaction (
179
+ req : CrossPlatformRequest ,
180
+ options : { type : boolean | TransactionNamingScheme ; customRoute ?: string } ,
181
+ ) : string {
182
+ const { type, customRoute } = options ;
183
+
179
184
switch ( type ) {
180
185
case 'path' : {
181
- return extractPathForTransaction ( req , { path : true } ) [ 0 ] ;
186
+ return extractPathForTransaction ( req , { path : true , customRoute } ) [ 0 ] ;
182
187
}
183
188
case 'handler' : {
184
189
return ( req . route && req . route . stack && req . route . stack [ 0 ] && req . route . stack [ 0 ] . name ) || '<anonymous>' ;
185
190
}
186
191
case 'methodPath' :
187
192
default : {
188
- return extractPathForTransaction ( req , { path : true , method : true } ) [ 0 ] ;
193
+ return extractPathForTransaction ( req , { path : true , method : true , customRoute } ) [ 0 ] ;
189
194
}
190
195
}
191
196
}
@@ -393,7 +398,7 @@ export function addRequestDataToEvent(
393
398
if ( include . transaction && ! event . transaction ) {
394
399
// TODO do we even need this anymore?
395
400
// TODO make this work for nextjs
396
- event . transaction = extractTransaction ( req , include . transaction ) ;
401
+ event . transaction = extractTransaction ( req , { type : include . transaction } ) ;
397
402
}
398
403
399
404
return event ;
0 commit comments