|
4 | 4 | </a> |
5 | 5 | </p> |
6 | 6 |
|
7 | | -> NOTICE: This package is in beta state and may be subject to breaking changes. |
8 | | -
|
9 | 7 | # Official Sentry SDK for Nitro |
10 | 8 |
|
11 | 9 | [](https://www.npmjs.com/package/@sentry/nitro) |
12 | 10 | [](https://www.npmjs.com/package/@sentry/nitro) |
13 | 11 | [](https://www.npmjs.com/package/@sentry/nitro) |
14 | 12 |
|
15 | | -## Links |
16 | | - |
17 | | -- [Official Nitro SDK Docs](https://docs.sentry.io/platforms/javascript/guides/nitro/) |
18 | | -- [Example Nitro app](https://github.com/getsentry/sentry-javascript/tree/develop/dev-packages/e2e-tests/test-applications/nitro-3) |
19 | | - |
20 | | -## Compatibility |
21 | | - |
22 | | -The minimum supported version of Nitro is `3.0.260415-beta`. |
23 | | - |
24 | | -## General |
25 | | - |
26 | | -This package is a wrapper around `@sentry/node` with added instrumentation for Nitro's features like: |
27 | | - |
28 | | -- HTTP handlers and error capturing. |
29 | | -- [Middleware instrumentation](https://nitro.build/guide/routing#middleware). |
30 | | - <!-- - [Database instrumentation](https://nitro.build/guide/database). --> |
31 | | - <!-- - [KV Storage](https://nitro.build/guide/storage) and [Cache](https://nitro.build/guide/cache) instrumentation. --> |
32 | | - |
33 | | -## Manual Setup |
34 | | - |
35 | | -### 1. Prerequisites & Installation |
36 | | - |
37 | | -1. Install the Sentry Nitro SDK: |
38 | | - |
39 | | - ```bash |
40 | | - # Using npm |
41 | | - npm install @sentry/nitro |
42 | | - |
43 | | - # Using yarn |
44 | | - yarn add @sentry/nitro |
45 | | - |
46 | | - # Using pnpm |
47 | | - pnpm add @sentry/nitro |
48 | | - ``` |
49 | | - |
50 | | -### 2. Build-Time Nitro Config Setup |
51 | | - |
52 | | -1. Import `withSentryConfig` from `@sentry/nitro` and call it with your Nitro config. |
53 | | - |
54 | | -#### In `nitro.config.ts` |
| 13 | +The official Sentry SDK for monitoring Nitro applications. |
55 | 14 |
|
56 | | -If you are using a dedicated `nitro.config.ts` file, you can import `withSentryConfig` from `@sentry/nitro` and call it with your Nitro config. |
57 | | - |
58 | | -```javascript |
59 | | -import { defineNitroConfig } from 'nitro/config'; |
60 | | -import { withSentryConfig } from '@sentry/nitro'; |
61 | | - |
62 | | -const config = defineNitroConfig({ |
63 | | - // ... |
64 | | -}); |
65 | | - |
66 | | -export default withSentryConfig(config, { |
67 | | - // Sentry Build Options |
68 | | -}); |
69 | | -``` |
70 | | - |
71 | | -#### In `vite.config.ts` |
72 | | - |
73 | | -If you are using Nitro as a Vite plugin, you can import `withSentryConfig` from `@sentry/nitro` and call it with your Nitro config. |
74 | | - |
75 | | -```ts |
76 | | -import { defineConfig } from 'vite'; |
77 | | -import { nitro } from 'nitro/vite'; |
78 | | -import { withSentryConfig } from '@sentry/nitro'; |
79 | | - |
80 | | -export default defineConfig({ |
81 | | - plugins: [nitro()], |
82 | | - nitro: withSentryConfig( |
83 | | - { |
84 | | - // Nitro options |
85 | | - }, |
86 | | - { |
87 | | - // Sentry Build Options |
88 | | - }, |
89 | | - ), |
90 | | -}); |
91 | | -``` |
92 | | - |
93 | | -### 3. Sentry Config Setup |
94 | | - |
95 | | -Create an `instrument.mjs` file in your project root to initialize the Sentry SDK: |
96 | | - |
97 | | -```javascript |
98 | | -import * as Sentry from '@sentry/nitro'; |
99 | | - |
100 | | -Sentry.init({ |
101 | | - dsn: '__YOUR_DSN__', |
102 | | - tracesSampleRate: 1.0, |
103 | | -}); |
104 | | -``` |
105 | | - |
106 | | -Then use `--import` in `NODE_OPTIONS` to load the instrumentation before your app code: |
107 | | - |
108 | | -```bash |
109 | | -NODE_OPTIONS='--import ./instrument.mjs' npx nitro dev |
110 | | -``` |
111 | | - |
112 | | -This works with any Nitro command (`nitro dev`, `nitro preview`, or a production start script). |
113 | | - |
114 | | -## Uploading Source Maps |
| 15 | +> NOTICE: This package is in beta state and may be subject to breaking changes. |
115 | 16 |
|
116 | | -The `withSentryConfig` function automatically configures source map uploading when the `authToken`, `org`, and `project` |
117 | | -options are provided: |
| 17 | +## Documentation |
118 | 18 |
|
119 | | -```javascript |
120 | | -export default withSentryConfig(config, { |
121 | | - org: 'your-sentry-org', |
122 | | - project: 'your-sentry-project', |
123 | | - authToken: process.env.SENTRY_AUTH_TOKEN, |
124 | | -}); |
125 | | -``` |
| 19 | +- [Getting started](https://docs.sentry.io/platforms/javascript/guides/nitro/) |
| 20 | +- [Configuration](https://docs.sentry.io/platforms/javascript/guides/nitro/configuration/) |
126 | 21 |
|
127 | | -## Troubleshoot |
| 22 | +## Support |
128 | 23 |
|
129 | | -If you encounter any issues with error tracking or integrations, refer to the official [Sentry Nitro SDK documentation](https://docs.sentry.io/platforms/javascript/guides/nitro/). If the documentation does not provide the necessary information, consider opening an issue on GitHub. |
| 24 | +- [Report a bug](https://github.com/getsentry/sentry-javascript/issues/new/choose) |
| 25 | +- [Contributing](https://github.com/getsentry/sentry-javascript/blob/develop/CONTRIBUTING.md) |
0 commit comments