Skip to content

fix(nextjs): Handle pathname being passed in object in instrumentServer#5782

Merged
lobsterkatie merged 1 commit intomasterfrom
kmclb-nextjs-fix-path-parameterization-in-instrument-server
Sep 22, 2022
Merged

fix(nextjs): Handle pathname being passed in object in instrumentServer#5782
lobsterkatie merged 1 commit intomasterfrom
kmclb-nextjs-fix-path-parameterization-in-instrument-server

Conversation

@lobsterkatie
Copy link
Copy Markdown
Member

@lobsterkatie lobsterkatie commented Sep 20, 2022

In nextjs version 12.2.6, the signature of findPageComponents which we wrap in instrumentServer changed, from accepting individual parameters to accepting an options object. This changes our wrapping to accommodate that, and as a result fixes transactions started by instrumentServer being parameterized as [ object Object ]. For backwards compatibility with older versions of next, individual parameters also continue to be accepted.

const wrappedMethod = async function (this: Server, parameterizedPath: string, ...args: any[]): Promise<any> {
const wrappedMethod = async function (
this: Server,
parameterizedPath: string | { pathname: string },
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add a comment here explaining that the two different types come from two different nextjs versions.

@lobsterkatie lobsterkatie force-pushed the kmclb-nextjs-fix-path-parameterization-in-instrument-server branch from 4497932 to 9582902 Compare September 21, 2022 16:09
@lobsterkatie lobsterkatie merged commit fa8c15b into master Sep 22, 2022
@lobsterkatie lobsterkatie deleted the kmclb-nextjs-fix-path-parameterization-in-instrument-server branch September 22, 2022 03:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants