Skip to content

Commit 18d7ba7

Browse files
feat: Add docs for Shopify Hydrogen (#11580)
Co-authored-by: Alex Krawiec <[email protected]>
1 parent dd9c7cd commit 18d7ba7

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
title: Shopify Hydrogen Guide
3+
description: "Learn how to use the Sentry Remix SDK to instrument your Shopify Hydrogen app."
4+
---
5+
6+
If you're using the Shopify Hydrogen framework, you can use the Sentry Remix SDK to add Sentry instrumentation to your app.
7+
8+
First, install the Sentry Remix SDK in your application. We recommend using the Sentry wizard to automatically install the SDK:
9+
10+
```bash
11+
npx @sentry/wizard@latest -i remix
12+
```
13+
14+
If the wizard doesn't work for you, you can also [set up the Remix SDK manually](/platforms/javascript/guides/remix/manual-setup/).
15+
16+
After installing the Sentry Remix SDK, delete the newly generated `instrumentation.server.mjs` file and all newly generated code from `entry.server.tsx`. This instrumentation is not needed because you are going to use the Sentry Cloudflare SDK for server-side instrumentation.
17+
18+
Now you can install the Sentry Cloudflare SDK. First, install the SDK with your package manager:
19+
20+
<PlatformContent includePath="getting-started-install" />
21+
22+
Then update your `server.ts` file to use the `wrapRequestHandler` method:
23+
24+
```ts {filename:server.ts}
25+
import { wrapRequestHandler } from "@sentry/cloudflare";
26+
27+
/**
28+
* Export a fetch handler in module format.
29+
*/
30+
export default {
31+
async fetch(
32+
request: Request,
33+
env: Env,
34+
executionContext: ExecutionContext
35+
): Promise<Response> {
36+
return wrapRequestHandler(
37+
{
38+
options: {
39+
dsn: "YOUR_DSN_HERE",
40+
tracesSampleRate: 1.0,
41+
},
42+
// Need to cast to any because this is not on cloudflare
43+
request: request as any,
44+
context: executionContext,
45+
},
46+
async () => {
47+
// request handling logic
48+
}
49+
);
50+
},
51+
};
52+
```
53+
54+
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:
55+
56+
```ts {filename:vite.config.ts}
57+
export function removeAsyncHooksPlugin(): Plugin {
58+
return {
59+
name: "remove-async-hooks",
60+
load: (id) => {
61+
if (id === "node:async_hooks") {
62+
return "export default {}";
63+
}
64+
},
65+
};
66+
}
67+
68+
export default defineConfig({
69+
plugins: [
70+
removeAsyncHooksPlugin(),
71+
// rest of your plugins
72+
],
73+
});
74+
```
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
title: Cloudflare SDK Framework Guide
3+
description: "Learn how to set up the Remix SDK with popular Frameworks like Hydrogen."
4+
---
5+
6+
You can use the Sentry Remix SDK to setup Sentry with frameworks like Shopify Hydrogen.
7+
8+
<PageGrid />

0 commit comments

Comments
 (0)