Skip to content

Commit e8ba6b4

Browse files
committed
allow extractTransaction to take a custom transaction value
1 parent e0c4edc commit e8ba6b4

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

packages/utils/src/requestdata.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,17 +175,22 @@ export function extractPathForTransaction(
175175
type TransactionNamingScheme = 'path' | 'methodPath' | 'handler';
176176

177177
/** 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+
179184
switch (type) {
180185
case 'path': {
181-
return extractPathForTransaction(req, { path: true })[0];
186+
return extractPathForTransaction(req, { path: true, customRoute })[0];
182187
}
183188
case 'handler': {
184189
return (req.route && req.route.stack && req.route.stack[0] && req.route.stack[0].name) || '<anonymous>';
185190
}
186191
case 'methodPath':
187192
default: {
188-
return extractPathForTransaction(req, { path: true, method: true })[0];
193+
return extractPathForTransaction(req, { path: true, method: true, customRoute })[0];
189194
}
190195
}
191196
}
@@ -393,7 +398,7 @@ export function addRequestDataToEvent(
393398
if (include.transaction && !event.transaction) {
394399
// TODO do we even need this anymore?
395400
// TODO make this work for nextjs
396-
event.transaction = extractTransaction(req, include.transaction);
401+
event.transaction = extractTransaction(req, { type: include.transaction });
397402
}
398403

399404
return event;

0 commit comments

Comments
 (0)