Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sentry/remix

Package Overview
Dependencies
Maintainers
12
Versions
254
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sentry/remix

Official Sentry SDK for Remix

  • 7.4.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
123K
increased by1.65%
Maintainers
12
Weekly downloads
 
Created
Source

Sentry

Official Sentry SDK for Remix

npm version npm dm npm dt typedoc

This SDK is considering experimental and in an alpha state. It may experience breaking changes. Please reach out on GitHub if you have any feedback/concerns.

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.

// entry.client.tsx

import { useLocation, useMatches } from "@remix-run/react";
import * as Sentry from "@sentry/remix";
import { useEffect } from "react";

Sentry.init({
  dsn: "__DSN__",
  tracesSampleRate: 1,
  integrations: [
    new Sentry.BrowserTracing({
        routingInstrumentation: Sentry.remixRouterInstrumentation(
            useEffect,
            useLocation,
            useMatches,
        ),
    }),
  ],
  // ...
});
// entry.server.tsx

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 Sentry's ErrorBoundary component to catch React component errors, and withSentryRouteTracing to get parameterized router transactions.

// root.tsx

import {
  Links,
  LiveReload,
  Meta,
  Outlet,
  Scripts
  ScrollRestoration,
} from "@remix-run/react";

import { ErrorBoundary, withSentryRouteTracing } from "@sentry/remix";

function App() {
    return (
      <ErrorBoundary>
        <html>
          <head>
            <Meta />
            <Links />
          </head>
          <body>
            <Outlet />
            <ScrollRestoration />
            <Scripts />
            <LiveReload />
          </body>
        </html>
      </ErrorBoundary>
  );
}

export default withSentryRouteTracing(App);

To set context information or send manual events, use the exported functions of @sentry/remix.

import * as Sentry from '@sentry/remix';

// Set user information, as well as tags and further extras
Sentry.configureScope(scope => {
  scope.setExtra('battery', 0.7);
  scope.setTag('user_mode', 'admin');
  scope.setUser({ id: '4711' });
  // scope.clear();
});

// Add a breadcrumb for future events
Sentry.addBreadcrumb({
  message: 'My Breadcrumb',
  // ...
});

// Capture exceptions, messages or manual events
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 --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..

FAQs

Package last updated on 01 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc