Official Sentry SDK for Remix
General
This package is a wrapper around @sentry/node
for the server and @sentry/react
for the client, with added
functionality related to Remix.
To use this SDK, initialize Sentry in your Remix entry points for both the client and server.
import { useLocation, useMatches } from '@remix-run/react';
import * as Sentry from '@sentry/remix';
import { useEffect } from 'react';
Sentry.init({
dsn: '__DSN__',
tracesSampleRate: 1,
integrations: [
Sentry.browserTracingIntegration({
useEffect,
useLocation,
useMatches,
}),
],
});
import { prisma } from '~/db.server';
import * as Sentry from '@sentry/remix';
Sentry.init({
dsn: '__DSN__',
tracesSampleRate: 1,
integrations: [new Sentry.Integrations.Prisma({ client: prisma })],
});
Also, wrap your Remix root with withSentry
to catch React component errors and to get parameterized router
transactions.
import {
Links,
LiveReload,
Meta,
Outlet,
Scripts,
ScrollRestoration,
} from "@remix-run/react";
import { withSentry } from "@sentry/remix";
function App() {
return (
<html>
<head>
<Meta />
<Links />
</head>
<body>
<Outlet />
<ScrollRestoration />
<Scripts />
<LiveReload />
</body>
</html>
);
}
export default withSentry(App);
You can disable or configure ErrorBoundary
using a second parameter to withSentry
.
withSentry(App, {
wrapWithErrorBoundary: false
});
withSentry(App, {
errorBoundaryOptions: {
fallback: <p>An error has occurred</p>
}
});
To set context information or send manual events, use the exported functions of @sentry/remix
.
import * as Sentry from '@sentry/remix';
Sentry.setExtra('battery', 0.7);
Sentry.setTag('user_mode', 'admin');
Sentry.setUser({ id: '4711' });
Sentry.addBreadcrumb({
message: 'My Breadcrumb',
});
Sentry.captureMessage('Hello, world!');
Sentry.captureException(new Error('Good bye'));
Sentry.captureEvent({
message: 'Manual',
stacktrace: [
],
});
Sourcemaps and Releases
The Remix SDK provides a script that automatically creates a release and uploads sourcemaps. To generate sourcemaps with
Remix, you need to call remix build
with the --sourcemap
option.
On release, call sentry-upload-sourcemaps
to upload source maps and create a release. To see more details on how to
use the command, call sentry-upload-sourcemaps --help
.
For more advanced configuration,
directly use sentry-cli
to upload source maps..
8.0.0-beta.5
This beta release contains various bugfixes and improvements for the v8 beta cycle.
Important Changes
- feat(svelte): Add Svelte 5 support (#11807)
We now officially support Svelte 5.
- feat(browser): Send standalone fetch and XHR spans if there's no active parent span (#11783)
Starting with this version, spans for outgoing fetch/xhr requests will be captured even if no pageload/navigation span
is ongoing. This means that you will be able to have a more complete trace, especially for web applications that make a
lot of HTTP requests on longer lived pages.
Other Changes
- feat(astro): Add
transactionName
to isolation scope for requests (#11786) - feat(browser): Create standalone INP spans via
startInactiveSpan
(#11788) - feat(core): Add
trace
envelope header to span envelope (#11699) - feat(core): Add options to start standalone (segment) spans via
start*Span
APIs (#11696) - feat(core): Set default scope for BaseClient methods (#11775)
- feat(core): Wrap cron
withMonitor
callback in withIsolationScope
(#11797) - feat(feedback): New feedback button design (#11641)
- feat(nextjs): Add
transactionName
to isolation scope for Next.js server side features (#11782) - feat(nextjs): Mute webpack warnings about critical dependencies inside
@opentelemetry/instrumentation
(#11810) - feat(node): Upgrade @prisma/instrumentation to 5.13.0 (#11779)
- feat(react): type error as unknown in ErrorBoundary (#11819)
- feat(remix): Add
wrapHandleErrorWithSentry
(#10370) - feat(remix): Set
formData
as action
span data. (#10836) - feat(remix): Update scope
transactionName
for Remix server features (#11784) - fix(angular): Call
showReportDialog
in root context (#11703) - fix(core): Capture only failed console.assert calls (#11799)
- fix(ember): Ensure unnecessary spans are avoided (#11846)
- fix(feedback): Clarify the difference between createWidget and create Form in the feedback public api (#11838)
- fix(feedback): Fix feedback type (#11787)
- fix(feedback): Vendor preact into bundle (#11845)
- fix(remix): Rethrow
loader
, action
and documentRequest
errors (#11793) - ref: Always return an immediately generated event ID from
captureException()
, captureMessage()
, and
captureEvent()
(#11805) - ref(core): Remove transaction name extraction from
requestDataIntegration
(#11513) - ref(svelte): Use
onlyIfParent
for recording component update spans (#11809)