-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add docs for Shopify Hydrogen (#11580)
Co-authored-by: Alex Krawiec <[email protected]>
- Loading branch information
1 parent
dd9c7cd
commit 18d7ba7
Showing
2 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
docs/platforms/javascript/guides/remix/frameworks/hydrogen.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
--- | ||
title: Shopify Hydrogen Guide | ||
description: "Learn how to use the Sentry Remix SDK to instrument your Shopify Hydrogen app." | ||
--- | ||
|
||
If you're using the Shopify Hydrogen framework, you can use the Sentry Remix SDK to add Sentry instrumentation to your app. | ||
|
||
First, install the Sentry Remix SDK in your application. We recommend using the Sentry wizard to automatically install the SDK: | ||
|
||
```bash | ||
npx @sentry/wizard@latest -i remix | ||
``` | ||
|
||
If the wizard doesn't work for you, you can also [set up the Remix SDK manually](/platforms/javascript/guides/remix/manual-setup/). | ||
|
||
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. | ||
|
||
Now you can install the Sentry Cloudflare SDK. First, install the SDK with your package manager: | ||
|
||
<PlatformContent includePath="getting-started-install" /> | ||
|
||
Then update your `server.ts` file to use the `wrapRequestHandler` method: | ||
|
||
```ts {filename:server.ts} | ||
import { wrapRequestHandler } from "@sentry/cloudflare"; | ||
|
||
/** | ||
* Export a fetch handler in module format. | ||
*/ | ||
export default { | ||
async fetch( | ||
request: Request, | ||
env: Env, | ||
executionContext: ExecutionContext | ||
): Promise<Response> { | ||
return wrapRequestHandler( | ||
{ | ||
options: { | ||
dsn: "YOUR_DSN_HERE", | ||
tracesSampleRate: 1.0, | ||
}, | ||
// Need to cast to any because this is not on cloudflare | ||
request: request as any, | ||
context: executionContext, | ||
}, | ||
async () => { | ||
// request handling logic | ||
} | ||
); | ||
}, | ||
}; | ||
``` | ||
|
||
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: | ||
|
||
```ts {filename:vite.config.ts} | ||
export function removeAsyncHooksPlugin(): Plugin { | ||
return { | ||
name: "remove-async-hooks", | ||
load: (id) => { | ||
if (id === "node:async_hooks") { | ||
return "export default {}"; | ||
} | ||
}, | ||
}; | ||
} | ||
|
||
export default defineConfig({ | ||
plugins: [ | ||
removeAsyncHooksPlugin(), | ||
// rest of your plugins | ||
], | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
title: Cloudflare SDK Framework Guide | ||
description: "Learn how to set up the Remix SDK with popular Frameworks like Hydrogen." | ||
--- | ||
|
||
You can use the Sentry Remix SDK to setup Sentry with frameworks like Shopify Hydrogen. | ||
|
||
<PageGrid /> |