-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat(nuxt): Add "Deployment Provider Setup" #11486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
--- | ||
title: Data Management | ||
description: Learn about different ways to scrub data within your SDK before it gets sent to Sentry. | ||
sidebar_order: 7 | ||
sidebar_order: 8 | ||
--- | ||
|
||
<PageGrid /> |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,97 @@ | ||||||||||||||||||||||||||||||||||
--- | ||||||||||||||||||||||||||||||||||
title: General | ||||||||||||||||||||||||||||||||||
sidebar_order: 1 | ||||||||||||||||||||||||||||||||||
description: "Learn about the general deployment setup when using Sentry." | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||
supported: | ||||||||||||||||||||||||||||||||||
- javascript.nuxt | ||||||||||||||||||||||||||||||||||
--- | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
<PlatformSection supported={['javascript.nuxt']}> | ||||||||||||||||||||||||||||||||||
Nuxt compiles all your code for the client and server side to ECMAScript modules (ESM) syntax ([learn more about ESM and Nuxt](https://nuxt.com/docs/guide/concepts/esm)). | ||||||||||||||||||||||||||||||||||
</PlatformSection> | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
Comment on lines
+8
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
It would be great if you could add a little more context here. Like a sentence or two explaining why a user would want to use this type of setup. Maybe something as simple as: Use this setup if you want to add Sentry to a Nuxt project in ESM syntax. (As the first line on the page.) |
||||||||||||||||||||||||||||||||||
Adding Sentry on the server-side for a project in ESM syntax is different from adding Sentry to a project in CommonJS (CJS) syntax. | ||||||||||||||||||||||||||||||||||
The Sentry initialization code needs to be loaded first when the application starts. | ||||||||||||||||||||||||||||||||||
Comment on lines
+13
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||
Preloading the Sentry server config file can be done with the Node [`--import`](https://nodejs.org/api/cli.html#--importmodule) CLI flag when starting the application. | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
Internally, Sentry uses a specific ESM loader hook "[import-in-the-middle/hook.mjs](https://www.npmjs.com/package/import-in-the-middle)" which is | ||||||||||||||||||||||||||||||||||
automatically added when you add the Sentry server-side config file with `--import`. This will automatically instrument all modules in your application. | ||||||||||||||||||||||||||||||||||
Comment on lines
+17
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. l: I am not sure if we need to/should include this - this is very much internal stuff that users don't really need to know/understand, and also could possibly change. IMHO it is enough to have the paragraph above, which states that sentry has to be initialized via There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tend to agree. I think wherever possible, we should only give the users the information they need most and avoid going too deep :) |
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
## Setup Sentry Server Config | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
As described above, there are some prerequisites for adding Sentry to a Nuxt project in ESM syntax: | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
1. The possibility to add the node `--import` CLI flag. | ||||||||||||||||||||||||||||||||||
2. Knowing the correct path to your Sentry server config file within your deployment environment (to add the path to the `--import` CLI flag). | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Comment on lines
+20
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||
3. The `hook.mjs` file is available under `node_modules/import-in-the-middle/hook.mjs` wherever your server-side code is executed. | ||||||||||||||||||||||||||||||||||
4. Running Node.js version 18.19.0 or higher (support for `--import`). | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Comment on lines
+26
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd make the version requirement (#4) the first requirement. |
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
### Adding the `--import` CLI flag | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
You can either add the flag directly to the `node` command when starting the application: | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
```bash | ||||||||||||||||||||||||||||||||||
node --import ./path/to/sentry-server-config.mjs ./path/to/index.mjs | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
or use the `NODE_OPTIONS` environment variable: | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
```bash | ||||||||||||||||||||||||||||||||||
NODE_OPTIONS="--import ./path/to/sentry-server-config.mjs" node ./path/to/index.mjs | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
If modifying the `node` command is not possible, you can also add the `NODE_OPTIONS` environment variable wherever you can set environment variables within your deployment environment. | ||||||||||||||||||||||||||||||||||
Make sure that this variable is only available during server runtime (not during build time). | ||||||||||||||||||||||||||||||||||
Comment on lines
+43
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
### `import-in-the-middle/hook.mjs` is available | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
Usually, the file `node_modules/import-in-the-middle/hook.mjs` is automatically available when installing dependencies. | ||||||||||||||||||||||||||||||||||
However, some deployment providers use custom node bundlers that might not include all `node_modules` in order to save storage. | ||||||||||||||||||||||||||||||||||
This is often done by tracing the node files and only including the necessary dependencies. Since Sentry has to include the `hook.mjs` file internally with `module.register()` it might not be discovered by some bundlers and therefore not included. | ||||||||||||||||||||||||||||||||||
If you get a warning that the `hook.mjs` file is not found, please report this in [the Sentry JS GitHub repo](https://github.com/getsentry/sentry-javascript/issues) or file an issue at your deployment provider. | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
Nitro (which is used by Nuxt and SolidStart on the server side) uses [`@vercel/nft`](https://github.com/vercel/nft) during the build. `@vercel/nft` includes files that are added with `module.register()` from version 0.27.4 onwards. | ||||||||||||||||||||||||||||||||||
Comment on lines
+48
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||
In case you get a runtime error along the lines `Cannot find module '/node_modules/import-in-the-middle/hook.mjs'`, make sure to add a resolution (yarn) or an override (npm/pnpm) for `@vercel/nft`: | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
we should probably mention npm first (generally) |
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
```json {tabTitle:yarn} {filename: package.json} | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we flip these around, npm first, then yarn? |
||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||
"resolutions": { | ||||||||||||||||||||||||||||||||||
"@vercel/nft": "^0.27.4" | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
```json {tabTitle:npm/pnpm} {filename: package.json} | ||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||
"overrides": { | ||||||||||||||||||||||||||||||||||
"@vercel/nft": "^0.27.4" | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
## Setup other environment variables | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
In case you are using environment variables in your project to set up Sentry don't forget to also add them inside your deployment environment: | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
```bash | ||||||||||||||||||||||||||||||||||
SENTRY_DSN="___PUBLIC_DSN___" | ||||||||||||||||||||||||||||||||||
SENTRY_AUTH_TOKEN="___ORG_AUTH_TOKEN___" | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
Comment on lines
+80
to
+81
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
extra new lines here |
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
## Exclude modules from import-in-the-middle | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
As all packages are wrapped under the hood by [import-in-the-middle](https://www.npmjs.com/package/import-in-the-middle), you might run into issues with certain packages. If you run into a problem with a package, you can skip instrumentation for it by configuring `registerEsmLoaderHooks` in your `Sentry.init()` config. | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
Comment on lines
+85
to
+86
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||
```javascript {tabTitle:ESM} {filename: instrument.mjs} | ||||||||||||||||||||||||||||||||||
import * as Sentry from "@sentry/node"; | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
Sentry.init({ | ||||||||||||||||||||||||||||||||||
dsn: "___PUBLIC_DSN___", | ||||||||||||||||||||||||||||||||||
registerEsmLoaderHooks: { | ||||||||||||||||||||||||||||||||||
// Provide a list of package names to exclude from instrumentation | ||||||||||||||||||||||||||||||||||
exclude: ["package-name"], | ||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||
``` |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,9 @@ | ||||||
--- | ||||||
title: Deployment Provider Setup | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. L: This is very much bike shedding, but what about just calling this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or, if we want to keep it generic, e.g. "Deploying your application" or something like this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
sidebar_order: 4 | ||||||
description: "Review our alternate installation methods." | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is probably left over from copying this file ;) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
supported: | ||||||
- javascript.nuxt | ||||||
--- | ||||||
|
||||||
<PageGrid /> |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,50 @@ | ||||||||||||||||||||||||
--- | ||||||||||||||||||||||||
title: Netlify | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||
sidebar_order: 10 | ||||||||||||||||||||||||
description: "Learn about running Sentry when deploying to Netlify." | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||
supported: | ||||||||||||||||||||||||
- javascript.nuxt | ||||||||||||||||||||||||
--- | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
<Alert level="warning"> | ||||||||||||||||||||||||
Deploying on Netlify is still experimental. Currently, not all Sentry features are supported on the server-side. Only your frontend will be monitored. | ||||||||||||||||||||||||
</Alert> | ||||||||||||||||||||||||
Comment on lines
+9
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
<Alert level="info"> | ||||||||||||||||||||||||
Before approaching the steps below, read the general documentation around <PlatformLink to="/deployment-provider-setup/general/">setting up Sentry on a deployment provider</PlatformLink> to get quick general overview of the process. | ||||||||||||||||||||||||
This page only shows Netlify-specific steps. | ||||||||||||||||||||||||
</Alert> | ||||||||||||||||||||||||
Comment on lines
+12
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
It's a bit jarring to have 2 different-colored alerts at the very beginning of the page. I think this sentence works better as a regular sentence rather than as an alert. |
||||||||||||||||||||||||
|
||||||||||||||||||||||||
## Approach 1: Adding the `--import` flag | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
<PlatformSection supported={['javascript.nuxt']}> | ||||||||||||||||||||||||
The server-side of Nuxt is deployed as a Netlify Function. So make sure to scope the environment variable `NODE_OPTIONS` to "Functions". | ||||||||||||||||||||||||
The path to the function is depending on your setup. When building the preset locally, the file is available at: `.netlify/functions-internal/server/sentry.server.config.mjs`. | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
Comment on lines
+19
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||
<Alert level="warning"> | ||||||||||||||||||||||||
The docs for this are still vague and we will update them as soon as we know more about which exact path to use for the `--import` flag. | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess what you want to say here is that the docs are not really ready/done here yet? "vague" implies for me that everything works but is not documented well 🤔 Maybe rather:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, does this work as of today? If it does not actually work we should not document it, and/or call out very specifically that it does not work! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 to @mydea. I think it's best not to document it if we know it doesn't work. |
||||||||||||||||||||||||
</Alert> | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
<Include name="common-imgs/netlify-env-variable" /> | ||||||||||||||||||||||||
</PlatformSection> | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
## Approach 2: Enable `experimental_basicServerTracing` | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
Enabling `experimental_basicServerTracing` can be used when adding the node option `--import` does not work. This however only comes with limited tracing functionality because Sentry server config is not **pre**loaded with `--import`. | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
<PlatformSection supported={['javascript.nuxt']}> | ||||||||||||||||||||||||
Enabling this option will automatically import the Sentry server config at the top of the server entry file (server entry: `.netlify/functions-internal/server/server.mjs`). | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
Comment on lines
+34
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||
```javascript {tabTitle: Nuxt Config} {filename: nuxt.config.ts} | ||||||||||||||||||||||||
export default defineNuxtConfig({ | ||||||||||||||||||||||||
sentry: { | ||||||||||||||||||||||||
// ... other options | ||||||||||||||||||||||||
experimental_basicServerTracing: true | ||||||||||||||||||||||||
}, | ||||||||||||||||||||||||
}) | ||||||||||||||||||||||||
``` | ||||||||||||||||||||||||
</PlatformSection> | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
--- | ||
title: Enriching Events | ||
description: Add additional context to your events to make them easier to debug. | ||
sidebar_order: 5 | ||
sidebar_order: 6 | ||
--- | ||
|
||
<PageGrid /> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.