getsentry / sentry-wizard

Sentry Project Setup Wizard
MIT License
190 stars 48 forks source link

[Next.js] instrumentation file is placed in the wrong location when both `/pages` and `/src/pages` paths exist #633

Closed Pikachews closed 2 months ago

Pikachews commented 2 months ago

Environment

What version are you running? Etc. @sentry/wizard@3.25.2

Steps to Reproduce

  1. Have a Next.js application using the Pages router
  2. Have both a /pages and /src/pages directory
  3. Run the wizard with instrumentation enabled

Expected Result

The instrumentation.ts file should be created at /instrumentation.ts (in the project root) and be recognized by the Next.js framework.

Actual Result

The instrumentation.ts file was created at /src/instrumentation.ts and is not recognized by the Next.js framework. Manually moving the file allows Next.js to properly recognize the file.


According to the Next.js docs:

The instrumentation file should be in the root of your project and not inside the app or pages directory. If you're using the src folder, then place the file inside src alongside pages and app.

But this seems to be inaccurate, as when both the /pages and /src directory are present, the instrumentation file appears to be read from the project root, instead of from /src.

Lms24 commented 2 months ago

Hey @Pikachews thanks for writing in!

But this seems to be inaccurate, as when both the /pages and /src directory are present, the instrumentation file appears to be read from the project root, instead of from /src.

Hmm that's interesting. Coincidentally we've been looking at the placement of instrumentation.ts very recently. I'm therefore gonna tag @onurtemizkan - could you take a look at this?

onurtemizkan commented 2 months ago

Thanks for reporting @Pikachews, #629 will fix this.