Skip to main content

Sentry

@spree/dashboard-sentry reports errors from the admin dashboard and the seller panel. Install it in each app you deploy:
Then start it from the app’s entry module, src/main.tsx, before the app renders:
Use the DSN of a browser (React) Sentry project. It is public by design, and with no DSN the call does nothing, so the same build runs with Sentry on or off. initDashboardSentry takes any Sentry browser option, plus: VITE_ values are compiled into the browser bundle, so set them when you build, not only when you run the server. Call it the same way in the seller panel’s src/main.tsx. What gets reported:
  • Uncaught errors and unhandled promise rejections.
  • Errors a page throws while rendering or loading data, including the ones the panel’s error screen catches and shows.
  • The signed-in user’s ID and email, cleared on sign-out.
  • A panel tag, admin or seller, so both apps can share one Sentry project. Events raised while the app starts are tagged too.
Not-found pages and redirects are not errors and are skipped. Single-use tokens in password reset, email confirmation and invitation links are replaced with redacted in error events and breadcrumbs before they leave the browser, after your own beforeSend and beforeBreadcrumb run. The plugin turns on error reporting only. Tracing, Session Replay and other Sentry features stay off unless you pass their options. Token redaction does not cover them: replays and trace spans can record the page URL, including a reset or invitation token.

Readable stack traces

A production build is minified, so its stack traces are unreadable until Sentry has the build’s source maps. Upload them at build time with Sentry’s Vite plugin:
  • SENTRY_AUTH_TOKEN is read only while building, in Node, so it never reaches the browser bundle. Keep it out of VITE_ variables, which are.
  • sourcemap: 'hidden' writes the maps without linking them from the bundle, and filesToDeleteAfterUpload removes them once uploaded, so they are not deployed with the app.
  • The plugin also sets the release on each event, so initDashboardSentry needs no release option.
  • Without SENTRY_AUTH_TOKEN the plugin skips the upload, so local builds work without it.
Use the seller panel’s spreeSellerDashboardPlugin() in its own vite.config.ts the same way.

Another service

An error-tracking plugin needs two things from the dashboard:
  • errorReporters in defineDashboardPlugin, keyed by a unique id. Each one is called with every error the panel’s error screens catch. These errors never reach window.onerror, where most error trackers listen.
  • The app.root slot, rendered once inside the signed-in session, to attach the user to reports.
An error boundary of your own reports the same way: pass reportCaughtError from @spree/dashboard-core as the onCatch of RouteErrorBoundary or TanStack Router’s CatchBoundary. Call defineDashboardPlugin from a function the host calls in its entry module, as initDashboardSentry does, or mark the package as a dashboard plugin so both panels load it on install — see Distributing plugins.