Skip to content

Commit 23623b2

Browse files
authored
Update Remix Hydrogen Docs (#12931)
1 parent 85eb422 commit 23623b2

File tree

1 file changed

+64
-20
lines changed
  • docs/platforms/javascript/guides/remix/frameworks

1 file changed

+64
-20
lines changed

docs/platforms/javascript/guides/remix/frameworks/hydrogen.mdx

+64-20
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,19 @@ If you're using the Shopify Hydrogen framework, you can use the Sentry Remix SDK
77

88
## 1. Installing Sentry Remix SDK
99

10-
First, install the Sentry Remix SDK in your application. We recommend using the Sentry wizard to automatically install the SDK:
10+
First, install the Sentry Remix SDK with your package manager:
1111

12-
```bash
13-
npx @sentry/wizard@latest -i remix
12+
```bash {tabTitle:npm}
13+
npm install @sentry/remix --save
14+
```
15+
16+
```bash {tabTitle:yarn}
17+
yarn add @sentry/remix
1418
```
1519

16-
If the wizard doesn't work for you, you can also [set up the Remix SDK manually](/platforms/javascript/guides/remix/manual-setup/).
20+
```bash {tabTitle:pnpm}
21+
pnpm add @sentry/remix
22+
```
1723

1824
## 2. Installing Sentry Cloudflare SDK
1925

@@ -33,11 +39,19 @@ yarn add @sentry/cloudflare
3339
pnpm add @sentry/cloudflare
3440
```
3541

42+
## 3. Instrumenting Your Server
3643

3744
Then update your `server.ts` file to use the `wrapRequestHandler` method:
3845

3946
```ts {filename:server.ts}
40-
import { wrapRequestHandler } from "@sentry/cloudflare";
47+
import { wrapRequestHandler } from "@sentry/cloudflare/request";
48+
import { instrumentBuild } from "@sentry/remix/cloudflare";
49+
// Virtual entry point for the app
50+
import * as remixBuild from 'virtual:remix/server-build';
51+
52+
// Instrument your server build with Sentry
53+
// and use the instrumented build inside the fetch handler
54+
const instrumentedBuild = instrumentBuild(remixBuild)
4155

4256
/**
4357
* Export a fetch handler in module format.
@@ -66,24 +80,54 @@ export default {
6680
};
6781
```
6882

69-
To remove errors relating to `node:async_hooks` (which is included in the sdk, but not used by `wrapRequestHandler`), add a custom vite plugin to your `vite.config.ts` file that will alias it to an empty module:
83+
## 4. Instrumenting Your Client
7084

71-
```ts {filename:vite.config.ts}
72-
export function removeAsyncHooksPlugin(): Plugin {
73-
return {
74-
name: "remove-async-hooks",
75-
load: (id) => {
76-
if (id === "node:async_hooks") {
77-
return "export default {}";
78-
}
79-
},
80-
};
85+
Wrap your Remix root component using `withSentry`:
86+
87+
```tsx {filename:root.tsx}
88+
import { withSentry } from "@sentry/remix/cloudflare";
89+
90+
function App({ children }) {
91+
return <>{children}</>;
8192
}
8293

83-
export default defineConfig({
84-
plugins: [
85-
removeAsyncHooksPlugin(),
86-
// rest of your plugins
94+
// Pass `useEffect`, `useLocation` and `useMatches` hooks to `withSentry`
95+
export default withSentry(App, useEffect, useLocation, useMatches);
96+
```
97+
98+
99+
Finally, update your `entry.client.tsx` file to initialize Sentry SDK on the client:
100+
101+
```tsx {filename:entry.client.tsx}
102+
import * as Sentry from "@sentry/remix/cloudflare";
103+
104+
Sentry.init({
105+
dsn: "___PUBLIC_DSN___",
106+
integrations: [
107+
Sentry.browserTracingIntegration({
108+
useEffect,
109+
useLocation,
110+
useMatches,
111+
}),
112+
// Replay is only available in the client
113+
Sentry.replayIntegration(),
87114
],
115+
116+
// Set tracesSampleRate to 1.0 to capture 100%
117+
// of transactions for tracing.
118+
// We recommend adjusting this value in production
119+
// Learn more at
120+
// https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate
121+
tracesSampleRate: 1.0,
122+
123+
// Set `tracePropagationTargets` to control for which URLs distributed tracing should be enabled
124+
tracePropagationTargets: ["localhost", /^https:\/\/yourserver\.io\/api/],
125+
126+
// Capture Replay for 10% of all sessions,
127+
// plus for 100% of sessions with an error
128+
// Learn more at
129+
// https://docs.sentry.io/platforms/javascript/session-replay/configuration/#general-integration-configuration
130+
replaysSessionSampleRate: 0.1,
131+
replaysOnErrorSampleRate: 1.0,
88132
});
89133
```

0 commit comments

Comments
 (0)