Next.js errors and traces on your machine, Sentry SDK as is
Keep the @sentry/nextjs setup you have and set the DSN in each Sentry.init call to http://sentry@127.0.0.1:8000/1. Errors from the browser and from the server side of your Next.js app then show up in Buggregator, with stack traces and breadcrumbs. Set tracesSampleRate: 1.0 and the traces come too. No Sentry account is needed.
Steps
1. Start Buggregator
docker run --pull always \
-p 127.0.0.1:8000:8000 \
ghcr.io/buggregator/server:latest2. Set the DSN in every config
@sentry/nextjs has a client config (instrumentation-client.ts), a server config (sentry.server.config.ts) and an edge config (sentry.edge.config.ts). Set the same options in each:
Sentry.init({
dsn: "http://sentry@127.0.0.1:8000/1",
tracesSampleRate: 1.0,
enableLogs: true,
});tracesSampleRate: 1.0 sends every trace. With a lower rate, traces are sampled away and never sent.
3. Pick the right host
The client config runs in your browser, so it always uses 127.0.0.1. The server config uses 127.0.0.1 when you run npm run dev on your machine. If the Next.js server runs in a Docker Compose container, its server config uses the service name instead:
dsn: "http://sentry@buggregator:8000/1",4. Throw an error and look
Open http://127.0.0.1:8000, then open your app and run this in the browser console:
setTimeout(() => { throw new Error("Check error"); });You see a Sentry error «Check error». On the Sentry page, the Traces tab shows the page load as a trace.
Why it works
@sentry/nextjs is built on Sentry's browser and Node.js SDKs, and Buggregator accepts the same protocol they send to Sentry. The DSN tells the SDK where to send; the number at the end puts events into the default project. No CORS setup is needed: Buggregator accepts requests from any origin by default.
Docs: docs.buggregator.dev/guides/frontend.html#nuxt-and-next-js
Requires Buggregator v2.9.0+
Related tips
- Sentry
React errors with the component stack, on your machine
Point @sentry/react at Buggregator and wrap your app in its ErrorBoundary. Errors arrive with the stack trace and the component stack. No CORS setup.
- Sentry
Express errors and traces locally with @sentry/node
Point @sentry/node at Buggregator and load it before Express. Route errors, request traces and logs of your Express app show up on your machine.
- Sentry
See a Laravel request's Sentry trace as a waterfall
Turn on Sentry tracing in Laravel and send it to Buggregator. Every span of a request shows on a timeline, and errors link to their trace.
- Sentry
Read Sentry Logs from PHP on your own machine
Point the Sentry PHP SDK at Buggregator with a numeric DSN and write lines with \Sentry\logger(). They show in the Logs tab locally, filtered by level.
Checked on with Buggregator v2.13.0