Skip to content

Commit 4497932

Browse files
committed
handle pathname being passed in object
1 parent 17e4cb8 commit 4497932

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

packages/nextjs/src/utils/instrumentServer.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,14 +329,21 @@ function makeWrappedMethodForGettingParameterizedPath(
329329
origMethod: ApiPageEnsurer | PageComponentFinder,
330330
): WrappedApiPageEnsurer | WrappedPageComponentFinder {
331331
// eslint-disable-next-line @typescript-eslint/no-explicit-any
332-
const wrappedMethod = async function (this: Server, parameterizedPath: string, ...args: any[]): Promise<any> {
332+
const wrappedMethod = async function (
333+
this: Server,
334+
parameterizedPath: string | { pathname: string },
335+
...args: any[]
336+
): Promise<any> {
333337
const transaction = getActiveTransaction();
334338

335339
// replace specific URL with parameterized version
336340
if (transaction && transaction.metadata.requestPath) {
337341
const origPath = transaction.metadata.requestPath;
338-
const newName = transaction.name.replace(origPath, parameterizedPath);
339-
transaction.setName(newName, 'route');
342+
const newPath = typeof parameterizedPath === 'string' ? parameterizedPath : parameterizedPath.pathname;
343+
if (newPath) {
344+
const newName = transaction.name.replace(origPath, newPath);
345+
transaction.setName(newName, 'route');
346+
}
340347
}
341348

342349
return origMethod.call(this, parameterizedPath, ...args);

0 commit comments

Comments
 (0)