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.28.0
Important Changes
- Beta release of official NestJS SDK
This release contains the beta version of @sentry/nestjs
! For details on how to use it, check out the
README. Any feedback/bug reports
are greatly appreciated, please reach out on GitHub.
- fix(browser): Remove faulty LCP, FCP and FP normalization logic (#13502)
This release fixes a bug in the @sentry/browser
package and all SDKs depending on this package (e.g. @sentry/react
or @sentry/nextjs
) that caused the SDK to send incorrect web vital values for the LCP, FCP and FP vitals. The SDK
previously incorrectly processed the original values as they were reported from the browser. When updating your SDK to
this version, you might experience an increase in LCP, FCP and FP values, which potentially leads to a decrease in your
performance score in the Web Vitals Insights module in Sentry. This is because the previously reported values were
smaller than the actually measured values. We apologize for the inconvenience!
Other Changes
- feat(nestjs): Add
SentryGlobalGraphQLFilter
(#13545) - feat(nestjs): Automatic instrumentation of nestjs interceptors after route execution (#13264)
- feat(nextjs): Add
bundleSizeOptimizations
to build options (#13323) - feat(nextjs): Stabilize
captureRequestError
(#13550) - feat(nuxt): Wrap config in nuxt context (#13457)
- feat(profiling): Expose profiler as top level primitive (#13512)
- feat(replay): Add layout shift to CLS replay data (#13386)
- feat(replay): Upgrade rrweb packages to 2.26.0 (#13483)
- fix(cdn): Do not mangle _metadata (#13426)
- fix(cdn): Fix SDK source for CDN bundles (#13475)
- fix(nestjs): Check arguments before instrumenting with
@Injectable
(#13544) - fix(nestjs): Ensure exception and host are correctly passed on when using @WithSentry (#13564)
- fix(node): Suppress tracing for transport request execution rather than transport creation (#13491)
- fix(replay): Consider more things as DOM mutations for dead clicks (#13518)
- fix(vue): Correctly obtain component name (#13484)
Work in this release was contributed by @leopoldkristjansson, @mhuggins and @filips123. Thank you for your
contributions!