Skip to content

Commit 922e9b1

Browse files
AbhiPrasadMichaelDeBoeyonurtemizkanvladanpaunovic
authored
feat(remix): Enable Remix SDK (#5327)
Enables the publishing of the Sentry Remix SDK. We also rename `upload-sourcemaps` -> `sentry-upload-sourcemaps`, and add a small README for instructions. Co-authored-by: Michaël De Boey <info@michaeldeboey.be> Co-authored-by: Onur Temizkan <onur@narval.co.uk> Co-authored-by: Vladan Paunovic <vladan.paunovic.bg@gmail.com>
1 parent b0efcb8 commit 922e9b1

File tree

5 files changed

+128
-6
lines changed

5 files changed

+128
-6
lines changed

.craft.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ targets:
2525
cacheControl: 'public, max-age=31536000'
2626
- name: github
2727
includeNames: /^sentry-.*$/
28-
excludeNames: /^sentry-remix-.*$/
2928
- name: npm
30-
excludeNames: /^sentry-remix-.*.tgz$/
3129
- name: registry
3230
sdks:
3331
'npm:@sentry/browser':

.github/ISSUE_TEMPLATE/bug.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: 🐞 Bug Report
22
description: Tell us about something that's not working the way we (probably) intend.
3-
labels: 'Type: Bug'
3+
labels: "Type: Bug"
44
body:
55
- type: checkboxes
66
attributes:
@@ -32,6 +32,7 @@ body:
3232
- "@sentry/ember"
3333
- "@sentry/gatsby"
3434
- "@sentry/nextjs"
35+
- "@sentry/remix"
3536
- "@sentry/node"
3637
- "@sentry/react"
3738
- "@sentry/serverless"

packages/remix/README.md

Lines changed: 125 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,128 @@
66

77
# Official Sentry SDK for Remix
88

9-
This SDK is work in progress, and should not be used before officially released.
9+
[![npm version](https://img.shields.io/npm/v/@sentry/nextjs.svg)](https://www.npmjs.com/package/@sentry/remix)
10+
[![npm dm](https://img.shields.io/npm/dm/@sentry/nextjs.svg)](https://www.npmjs.com/package/@sentry/remix)
11+
[![npm dt](https://img.shields.io/npm/dt/@sentry/nextjs.svg)](https://www.npmjs.com/package/@sentry/remix)
12+
[![typedoc](https://img.shields.io/badge/docs-typedoc-blue.svg)](http://getsentry.github.io/sentry-javascript/)
13+
14+
This SDK is considering experimental and in an alpha state. It may experience breaking changes. Please reach out on [GitHub](https://github.com/getsentry/sentry-javascript/issues/new/choose) if you have any feedback/concerns.
15+
## General
16+
17+
This package is a wrapper around `@sentry/node` for the server and `@sentry/react` for the client, with added functionality related to Remix.
18+
19+
To use this SDK, initialize Sentry in your Remix entry points for both the client and server.
20+
21+
```ts
22+
// entry.client.tsx
23+
24+
import { useLocation, useMatches } from "@remix-run/react";
25+
import * as Sentry from "@sentry/remix";
26+
import { useEffect } from "react";
27+
28+
Sentry.init({
29+
dsn: "__DSN__",
30+
tracesSampleRate: 1,
31+
integrations: [
32+
new Sentry.BrowserTracing({
33+
routingInstrumentation: Sentry.remixRouterInstrumentation(
34+
useEffect,
35+
useLocation,
36+
useMatches,
37+
),
38+
}),
39+
],
40+
// ...
41+
});
42+
```
43+
44+
```ts
45+
// entry.server.tsx
46+
47+
import { prisma } from "~/db.server";
48+
49+
import * as Sentry from "@sentry/remix";
50+
51+
Sentry.init({
52+
dsn: "__DSN__",
53+
tracesSampleRate: 1,
54+
integrations: [new Sentry.Integrations.Prisma({ client: prisma })],
55+
// ...
56+
});
57+
```
58+
59+
Also, wrap your Remix root, with Sentry's `ErrorBoundary` component to catch React component errors, and `withSentryRouteTracing` to get parameterized router transactions.
60+
61+
```ts
62+
// root.tsx
63+
64+
import {
65+
Links,
66+
LiveReload,
67+
Meta,
68+
Outlet,
69+
Scripts
70+
ScrollRestoration,
71+
} from "@remix-run/react";
72+
73+
import { ErrorBoundary, withSentryRouteTracing } from "@sentry/remix";
74+
75+
function App() {
76+
return (
77+
<ErrorBoundary>
78+
<html>
79+
<head>
80+
<Meta />
81+
<Links />
82+
</head>
83+
<body>
84+
<Outlet />
85+
<ScrollRestoration />
86+
<Scripts />
87+
<LiveReload />
88+
</body>
89+
</html>
90+
</ErrorBoundary>
91+
);
92+
}
93+
94+
export default withSentryRouteTracing(App);
95+
```
96+
97+
To set context information or send manual events, use the exported functions of `@sentry/remix`.
98+
99+
```ts
100+
import * as Sentry from '@sentry/remix';
101+
102+
// Set user information, as well as tags and further extras
103+
Sentry.configureScope(scope => {
104+
scope.setExtra('battery', 0.7);
105+
scope.setTag('user_mode', 'admin');
106+
scope.setUser({ id: '4711' });
107+
// scope.clear();
108+
});
109+
110+
// Add a breadcrumb for future events
111+
Sentry.addBreadcrumb({
112+
message: 'My Breadcrumb',
113+
// ...
114+
});
115+
116+
// Capture exceptions, messages or manual events
117+
Sentry.captureMessage('Hello, world!');
118+
Sentry.captureException(new Error('Good bye'));
119+
Sentry.captureEvent({
120+
message: 'Manual',
121+
stacktrace: [
122+
// ...
123+
],
124+
});
125+
```
126+
127+
## Sourcemaps and Releases
128+
129+
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.
130+
131+
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`.
132+
133+
For more advanced configuration, [directly use `sentry-cli` to upload source maps.](https://github.com/getsentry/sentry-cli).

packages/remix/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"author": "Sentry",
88
"license": "MIT",
99
"bin": {
10-
"upload-sourcemaps": "scripts/upload-sourcemaps.js"
10+
"sentry-upload-sourcemaps": "scripts/sentry-upload-sourcemaps.js"
1111
},
1212
"engines": {
1313
"node": ">=14"
@@ -16,7 +16,6 @@
1616
"module": "build/esm/index.server.js",
1717
"browser": "build/esm/index.client.js",
1818
"types": "build/types/index.server.d.ts",
19-
"private": true,
2019
"dependencies": {
2120
"@sentry/cli": "2.2.0",
2221
"@sentry/core": "7.3.1",

0 commit comments

Comments
 (0)