Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next.js 13 app dir API route handlers #7228

Closed
Tracked by #6726
lforst opened this issue Feb 20, 2023 · 12 comments · Fixed by #8832
Closed
Tracked by #6726

Next.js 13 app dir API route handlers #7228

lforst opened this issue Feb 20, 2023 · 12 comments · Fixed by #8832
Assignees
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK Type: Improvement

Comments

@lforst
Copy link
Member

lforst commented Feb 20, 2023

Problem Statement

Next.js released app dir route handlers: https://beta.nextjs.org/docs/routing/route-handlers

We should auto-instrument them.

Solution Brainstorm

We can add wrapper templates that wrap these files.

Stuff to consider:

  • Static vs. dynamic routes
  • Connected Traces
  • Dynamic Route Segments
  • Redirects
  • Streaming responses
@tomelliot
Copy link

As a temporary fix, I'm looking at using wrapApiHandlerWithSentry. Is it possible to use this with dynamic routes?

@rsolomon
Copy link

@tomelliot Have you had luck getting wrapApiHandlerWithSentry to play nicely with app routes?

@tomelliot
Copy link

@rsolomon sorry no progress to report

@FadiAboMsalam
Copy link

Any update on this 🤔
am using app directory with latest "@sentry/nextjs": "^7.60.1"
But still no luck

@lforst
Copy link
Member Author

lforst commented Jul 31, 2023

It's simply not implemented yet. It's on our backlog.

@AbhiPrasad
Copy link
Member

Released with v7.67.0 of the Next.js SDK. Feedback greatly appreciated! https://changelog.getsentry.com/announcements/nextjs-sdk-now-supports-route-handlers

@dmudro
Copy link

dmudro commented Sep 24, 2023

thanks @AbhiPrasad, the new implementation helps a lot.

assuming there is no need to wrap route handlers with wrapRouteHandlerWithSentry as it's all handled by the Sentry Next SDK automatically, correct?

@lforst
Copy link
Member Author

lforst commented Sep 25, 2023

@dmudro route handlers should be wrapped automatically as long as autoInstrumentServerFunctions is not set to false.

@cyrus-za
Copy link

@lforst this isnt forking for me. I get all of my normal routes in my sentry performance tracing, but none of my api routes. Am I doing something wrong? I am using instrumentation.ts from the v8 migration docs and got tracing enabled in my sentry.client.ts

@AbhiPrasad
Copy link
Member

@cyrus-za a lot has changed with Next.js itself and the SDK since we released support for this. Could you open a new GH issue and fill out the template? Thanks!

@cyrus-za
Copy link

cyrus-za commented Jul 5, 2024

This is solved for me. Turns out I had instrumentation.ts in the root rather than my src directory

@lforst
Copy link
Member Author

lforst commented Jul 8, 2024

For future lurkers: If you have problems and stumble onto this issue, please open a new issue with reproduction steps!

@getsentry getsentry locked as resolved and limited conversation to collaborators Jul 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK Type: Improvement
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

8 participants