Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions docs/platforms/javascript/guides/nuxt/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ categories:
- server
---

<Alert level="warning">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Alert box is also in the manual-setup file

This SDK is currently in **beta**. Beta features are still in progress and may
have bugs. Please reach out on
[GitHub](https://github.com/getsentry/sentry-javascript/issues/new/choose) if
you have any feedback or concerns.
</Alert>

<PlatformContent includePath="getting-started-prerequisites" />

## Step 1: Install
Expand Down Expand Up @@ -58,14 +51,29 @@ To test the server side as well, refer to the "Verify" section in the [Manual se

</Expandable>

To test Sentry on the server side, you first need to build your project since Sentry's server-side monitoring **doesn't work in development mode**.\
Then run your project and make sure to load Sentry on the server side by explicitly adding it via [`--import`](/platforms/javascript/guides/nuxt/install/cli-import/):
To test Sentry on the server side, you can run your Nuxt application in either production or development mode.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also have this information in manual-setup.mdx. It's only showing when you enable the Tracing onboarding option.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the manual-setup file, you can replace:

Once you have your test code in place, you need to build your project since Sentry's server-side monitoring doesn't work in development mode. Then start your app and make sure to load Sentry on the server side by explicitly adding the Sentry server config in the build output via --import.

with the content you created here (including the new subsections) if this makes sense to you.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it a bit - it's okay that this is only included with error monitoring.

We recommend testing in production mode as it most closely resembles your deployed application's environment.

### Run in Production Mode (recommended)

After building with `nuxi build`, run your project and make sure to load Sentry on the server side by explicitly adding it via `--import` (read more about this flag in [Installation Methods](/platforms/javascript/guides/nuxt/install))

```
# Start your app after building your project with `nuxi build`
node --import ./.output/server/sentry.server.config.mjs .output/server/index.mjs
```

### Run in Development Mode

The server config file is generated in the `.nuxt` directory the first time you run `nuxt dev`. If you delete your `.nuxt` directory, you'll need to run `nuxt dev` once without the `NODE_OPTIONS` variable to regenerate it.

If you only want to use Sentry on the client-side or only need basic error monitoring on the server side, you can omit the --import flag when running your application.

```
# Run the dev server with the --import flag after running `nuxt dev` once (without the flag)
NODE_OPTIONS='--import ./.nuxt/dev/sentry.server.config.mjs' nuxt dev
```

After building and running your project:

1. Open the example page `/sentry-example-page` in your browser. For most Nuxt applications, this will be at localhost.
Expand Down
6 changes: 5 additions & 1 deletion docs/platforms/javascript/guides/nuxt/install/cli-import.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ Check out the guide for using <PlatformLink to="/install/limited-server-tracing"

## Initializing Sentry with `--import`

By default, the SDK will add the Sentry server config to the build output (typically, `.output/server/sentry.server.config.mjs`).
By default, the SDK will add the Sentry server config to the build output (typically, `.output/server/sentry.server.config.mjs` or ` ./.nuxt/dev/sentry.server.config.mjs` during development).

<Alert>
To find the exact path to the built Sentry server config file, enable `debug` mode in your Sentry configuration within `nuxt.config.ts`. Sentry will then print the exact path during the build process.
</Alert>
Comment on lines +27 to +29
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to include this Alert in the "Verify your setup" section?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you think this is vital information for the quick start guide then go for it!

But I think we need more context, so maybe include parts of the previous sentence in the alert. Something like:

<Alert>
By default, the SDK will add the Sentry server config to the build output. To find the exact path to this file, enable `debug` mode in your Sentry configuration within `nuxt.config.ts`. Sentry will then print the exact path during the build process.
</Alert>


### 1. Adding `--import` to `node` command

Expand Down
2 changes: 0 additions & 2 deletions docs/platforms/javascript/guides/nuxt/install/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ sidebar_order: 1.5
description: "Review our alternate installation methods."
---



Nuxt uses ES Modules for server-side builds, which requires Sentry to register Node [customization hooks](https://nodejs.org/api/module.html#customization-hooks).
Those customization hooks need to be registered before the rest of the application.

Expand Down
5 changes: 5 additions & 0 deletions docs/platforms/javascript/guides/nuxt/manual-setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ This allows you to access the DSN using `useRuntimeConfig().public.sentry.dsn`.

### Configure Server-side Sentry

<Alert>
Are you deploying to Cloudflare? Continue with the [Cloudflare-specific
setup](/platforms/javascript/guides/cloudflare/frameworks/nuxt/#setup).
</Alert>

Add a `sentry.server.config.ts` file to the root of your project and add the following initialization code to it:

```javascript {filename:sentry.server.config.ts}
Expand Down
Loading