You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/hono/README.md
+63-4Lines changed: 63 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,7 +29,18 @@ npm install @sentry/hono
29
29
30
30
## Setup (Cloudflare Workers)
31
31
32
-
### 1. Enable Node.js compatibility
32
+
### 1. Install Peer Dependency
33
+
34
+
Additionally to `@sentry/hono`, install the `@sentry/cloudflare` package:
35
+
36
+
```bashbash
37
+
npm install --save @sentry/cloudflare
38
+
```
39
+
40
+
Make sure the installed version always stays in sync. The `@sentry/cloudflare` package is a required peer dependency when using `@sentry/hono/cloudflare`.
41
+
You won't import `@sentry/cloudflare` directly in your code, but it needs to be installed in your project.
42
+
43
+
### 2. Enable Node.js compatibility
33
44
34
45
Set the `nodejs_compat` compatibility flag in your `wrangler.jsonc`/`wrangler.toml` config. This is because the SDK needs access to the `AsyncLocalStorage` API to work correctly.
35
46
@@ -43,7 +54,7 @@ Set the `nodejs_compat` compatibility flag in your `wrangler.jsonc`/`wrangler.to
43
54
compatibility_flags = ["nodejs_compat"]
44
55
```
45
56
46
-
### 2. Initialize Sentry in your Hono app
57
+
### 3. Initialize Sentry in your Hono app
47
58
48
59
Initialize the Sentry Hono middleware as early as possible in your app:
49
60
@@ -85,7 +96,18 @@ export default app;
85
96
86
97
## Setup (Node)
87
98
88
-
### 1. Initialize Sentry in your Hono app
99
+
### 1. Install Peer Dependency
100
+
101
+
Additionally to `@sentry/hono`, install the `@sentry/node` package:
102
+
103
+
```bashbash
104
+
npm install --save @sentry/node
105
+
```
106
+
107
+
Make sure the installed version always stays in sync. The `@sentry/node` package is a required peer dependency when using `@sentry/hono/node`.
108
+
You won't import `@sentry/node` directly in your code, but it needs to be installed in your project.
109
+
110
+
### 2. Initialize Sentry in your Hono app
89
111
90
112
Initialize the Sentry Hono middleware as early as possible in your app:
91
113
@@ -109,7 +131,7 @@ app.use(
109
131
serve(app);
110
132
```
111
133
112
-
### 2. Add `preload` script to start command
134
+
### 3. Add `preload` script to start command
113
135
114
136
To ensure that Sentry can capture spans from third-party libraries (e.g. database clients) used in your Hono app, Sentry needs to wrap these libraries as early as possible.
Read more about this preload script in the docs: https://docs.sentry.io/platforms/javascript/guides/hono/install/late-initialization/#late-initialization-with-esm
151
+
152
+
## Setup (Bun)
153
+
154
+
### 1. Install Peer Dependency
155
+
156
+
Additionally to `@sentry/hono`, install the `@sentry/bun` package:
157
+
158
+
```bashbash
159
+
npm install --save @sentry/bun
160
+
```
161
+
162
+
Make sure the installed version always stays in sync. The `@sentry/bun` package is a required peer dependency when using `@sentry/hono/bun`.
163
+
You won't import `@sentry/bun` directly in your code, but it needs to be installed in your project.
164
+
165
+
### 2. Initialize Sentry in your Hono app
166
+
167
+
Initialize the Sentry Hono middleware as early as possible in your app:
168
+
169
+
```ts
170
+
import { Hono } from'hono';
171
+
import { serve } from'@hono/node-server';
172
+
import { sentry } from'@sentry/hono/bun';
173
+
174
+
const app =newHono();
175
+
176
+
// Initialize Sentry middleware right after creating the app
177
+
app.use(
178
+
sentry(app, {
179
+
dsn: '__DSN__', // or process.env.SENTRY_DSN or Bun.env.SENTRY_DSN
0 commit comments