|
1 | 1 | To set up the Sentry SDK, register the Sentry Nuxt module and initialize the SDK for client and server. At build time, the Sentry Nuxt Module looks for the following two files:
|
2 | 2 |
|
3 |
| -- Client-Side: `sentry.client.config.(js|ts)` in the root containing `Sentry.init` |
4 |
| -- Server-Side: `instrument.server.mjs` in the `public` directory containing `Sentry.init` |
| 3 | +- Client-Side: `sentry.client.config.ts` in the root containing `Sentry.init` |
| 4 | +- Server-Side: `sentry.server.config.ts` in the root containing `Sentry.init` |
5 | 5 |
|
6 | 6 | In these files, you can specify the full range of <PlatformLink to="/configuration/options">Sentry SDK options</PlatformLink>.
|
7 | 7 |
|
@@ -44,40 +44,33 @@ Sentry.init({
|
44 | 44 | import * as Sentry from '@sentry/nuxt';
|
45 | 45 |
|
46 | 46 | Sentry.init({
|
47 |
| - dsn: "___PUBLIC_DSN___" |
| 47 | + dsn: "___PUBLIC_DSN___", |
| 48 | + |
| 49 | + // We recommend adjusting this value in production, or using tracesSampler |
| 50 | + // for finer control |
| 51 | + tracesSampleRate: 1.0 |
48 | 52 | });
|
49 | 53 | ```
|
50 | 54 |
|
51 | 55 | The Nuxt `useRuntimeConfig()` does not work in the Sentry server config due to technical reasons (the config file has to
|
52 | 56 | be loaded before Nuxt is loaded). To be able to use `process.env` you either have to add `--env-file=.env` to your node command
|
53 |
| -or use the `dotenv` package: |
54 | 57 |
|
55 |
| -```bash {tabTitle: env-file} |
56 |
| -node --env-file=.env --import ./.output/server/sentry.server.config.mjs .output/server/index.mjs |
| 58 | +```bash {tabTitle: node} |
| 59 | +node --env-file=.env .output/server/index.mjs |
57 | 60 | ```
|
58 | 61 |
|
| 62 | +or use the `dotenv` package: |
59 | 63 |
|
60 |
| - |
61 |
| -```javascript {tabTitle: dotenv} {filename:sentry.server.config.ts} {1,4} |
| 64 | +```javascript {tabTitle: Server Config} {filename:sentry.server.config.ts} {1,3} |
62 | 65 | import dotenv from 'dotenv';
|
63 |
| -import * as Sentry from '@sentry/nuxt'; |
64 | 66 |
|
65 | 67 | dotenv.config();
|
66 | 68 |
|
67 |
| -Sentry.init({ |
68 |
| - dsn: "___PUBLIC_DSN___" |
69 |
| -}); |
| 69 | +// ... rest of the file |
70 | 70 | ```
|
71 | 71 |
|
72 |
| -2. Add an [--import flag](https://nodejs.org/api/cli.html#--importmodule) to the Node options of your `node` command you run |
73 |
| -in production (not `nuxt preview`), so the file loads before any other imports (keep in mind the `.mjs` file ending). |
74 |
| -Depending on your setup, you might need to adjust the path to the `sentry.server.config.mjs` file: |
75 |
| - |
76 |
| -```json {filename:package.json} {4} |
77 |
| -{ |
78 |
| - "scripts": { |
79 |
| - "preview": "nuxt preview", |
80 |
| - "start": "node --import ./.output/server/sentry.server.config.mjs .output/server/index.mjs" |
81 |
| - } |
82 |
| -} |
83 |
| -``` |
| 72 | + |
| 73 | +<Alert level="warning"> |
| 74 | + In the beta state of the Nuxt SDK, some features may not work with certain deployment providers. Check the progress on GitHub: [Compatibility with different Deployment Platforms](https://github.com/getsentry/sentry-javascript/issues/14029) |
| 75 | +</Alert> |
| 76 | + |
0 commit comments