Skip to content

Commit 500a1f3

Browse files
authored
docs(nuxt): Manual setup for beta (#11614)
* docs(nuxt): Manual setup for beta * review comments * add note about different deployment providers
1 parent 1801f8e commit 500a1f3

File tree

3 files changed

+29
-25
lines changed

3 files changed

+29
-25
lines changed

platform-includes/getting-started-config/javascript.nuxt.mdx

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
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:
22

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`
55

66
In these files, you can specify the full range of <PlatformLink to="/configuration/options">Sentry SDK options</PlatformLink>.
77

@@ -44,40 +44,33 @@ Sentry.init({
4444
import * as Sentry from '@sentry/nuxt';
4545

4646
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
4852
});
4953
```
5054

5155
The Nuxt `useRuntimeConfig()` does not work in the Sentry server config due to technical reasons (the config file has to
5256
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:
5457

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
5760
```
5861

62+
or use the `dotenv` package:
5963

60-
61-
```javascript {tabTitle: dotenv} {filename:sentry.server.config.ts} {1,4}
64+
```javascript {tabTitle: Server Config} {filename:sentry.server.config.ts} {1,3}
6265
import dotenv from 'dotenv';
63-
import * as Sentry from '@sentry/nuxt';
6466

6567
dotenv.config();
6668

67-
Sentry.init({
68-
dsn: "___PUBLIC_DSN___"
69-
});
69+
// ... rest of the file
7070
```
7171

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+
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<Alert level="warning">
2-
This SDK is considered **experimental and in an alpha state**. It may experience breaking changes. Please reach out on
2+
This SDK is **in an beta state**. It may still experience changes in behavior. Please reach out on
33
[GitHub](https://github.com/getsentry/sentry-javascript/issues/new/choose) if you have any feedback or concerns.
44
</Alert>

platform-includes/getting-started-sourcemaps/javascript.nuxt.mdx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,14 @@ export default defineNuxtConfig({
2424
}
2525
});
2626
```
27+
28+
To upload source maps, the Sentry Nuxt Module will automatically enable source map generation in your project if it is not already enabled.
29+
However, you need to explicitly enable source map generation on the client-side. To do this, add the following code to your Nuxt configuration:
30+
31+
```javascript {filename:nuxt.config.ts} {2}
32+
export default defineNuxtConfig({
33+
sourcemap: { client: true }
34+
});
35+
```
36+
37+
This step is necessary because Nuxt sets default values for source maps ([Nuxt docs](https://nuxt.com/docs/api/nuxt-config#sourcemap)), and the Sentry Nuxt Module keeps these settings when they are explicitly defined.

0 commit comments

Comments
 (0)