-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
docs(js): Create Nuxt Quick Start guide for wizard installation #13286
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,6 +1,6 @@ | ||||||
| --- | ||||||
| title: Nuxt | ||||||
| description: Nuxt is a framework for full-stack web apps and websites. Learn how to set it up with Sentry. | ||||||
| description: Learn how to set up and configure Sentry in your Nuxt application using the installation wizard, capture your first errors, and view them in Sentry. | ||||||
| sdk: sentry.javascript.nuxt | ||||||
| categories: | ||||||
| - javascript | ||||||
|
|
@@ -9,128 +9,90 @@ categories: | |||||
| --- | ||||||
|
|
||||||
| <Alert level="warning"> | ||||||
| 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. | ||||||
| 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> | ||||||
|
|
||||||
| Sentry's Nuxt SDK enables automatic reporting of errors and performance data. | ||||||
|
|
||||||
| ## Compatibility | ||||||
|
|
||||||
| The Sentry Nuxt SDK supports Nuxt version `3.7.0` and above. For best results, we recommend | ||||||
| using Nuxt `3.14.0` or later, which includes updated dependencies critical to the SDK's functionality. | ||||||
|
|
||||||
| <PlatformContent includePath="getting-started-prerequisites" /> | ||||||
|
|
||||||
| ## Install | ||||||
|
|
||||||
| Sentry captures data by using an SDK within your application’s runtime. | ||||||
| ## Step 1: Install | ||||||
|
|
||||||
| We recommend installing the SDK by running our installation wizard in the root directory of your project: | ||||||
| To install Sentry using the installation wizard, run the following command within your project: | ||||||
|
|
||||||
| ```bash | ||||||
| npx @sentry/wizard@latest -i nuxt | ||||||
| ``` | ||||||
|
|
||||||
| The wizard will prompt you to log in to Sentry. It will then automatically do the following steps for you: | ||||||
| The wizard then guides you through the setup process, asking you to enable additional (optional) Sentry features for your application beyond error monitoring. | ||||||
|
|
||||||
| - create or update Nuxt files with the default Sentry configuration: | ||||||
| - `sentry.(client|server).config.ts` to initialize the SDK | ||||||
| - `nuxt.config.ts` to add build options to add source maps upload and auto-instrumentation via Vite plugins. | ||||||
| - create a `.env.sentry-build-plugin` file with an auth token to upload source maps (this file is automatically added to `.gitignore`) | ||||||
| - add an example page to your frontend app and your server to verify your Sentry setup | ||||||
| <PlatformContent includePath="getting-started-features-expandable" /> | ||||||
|
|
||||||
| After the wizard setup is completed, the SDK will automatically capture unhandled errors, and monitor performance. | ||||||
| This guide assumes that you enable all features and allow the wizard to create an example page or component. You can add or remove features at any time, but setting them up now will save you the effort of configuring them manually later. | ||||||
|
|
||||||
| You can also <PlatformLink to="/usage/">manually capture errors</PlatformLink>. | ||||||
| <Expandable title="What does the installation wizard change inside your application?"> | ||||||
| - Creates `sentry.(client|server).config.ts` to initialize the SDK | ||||||
| - Creates or updates your `nuxt.config.ts` to add build options to add source maps upload and auto-instrumentation via Vite plugins | ||||||
| - Creates `.env.sentry-build-plugin` with an auth token to upload source maps (this file is automatically added to `.gitignore`) | ||||||
| - Adds an example page and route to your application to help verify your Sentry setup | ||||||
| - If it couldn't create a page, the wizard adds an example component instead | ||||||
|
|
||||||
| <Alert> | ||||||
| If the setup through the wizard doesn't work for you, you can also <PlatformLink to="/manual-setup/">set up the SDK manually</PlatformLink>. | ||||||
| </Alert> | ||||||
| </Expandable> | ||||||
|
|
||||||
| ## Configure | ||||||
| ## Step 2: Verify Your Setup | ||||||
|
|
||||||
| Configuration should happen as early as possible in your application's lifecycle. | ||||||
| If you haven't tested your Sentry configuration yet, let's do it now. You can confirm that Sentry is working properly and sending data to your Sentry project by using the example page created by the installation wizard. | ||||||
|
|
||||||
| To complete your configuration, add <PlatformLink to="/configuration/options/">options</PlatformLink> to your `Sentry.init()` calls. | ||||||
| <Expandable level="warning" title="The wizard created an example component instead of a page."> | ||||||
| The wizard creates a `SentryErrorButton` component when it fails to add an example page to your project. This usually happens if you don't have a `app.vue` file or if that file does not contain the `NuxtPage` component. To verify your setup, follow these steps before continuing with the next section, "View Captured Data in Sentry": | ||||||
|
|
||||||
| Here, you'll also be able to set context data, which includes data about the <PlatformLink to="/enriching-events/identify-user/">user</PlatformLink>, <PlatformLink to="/enriching-events/tags/">tags</PlatformLink>, or even <PlatformLink to="/enriching-events/context/">arbitrary data</PlatformLink>, all of which will be added to every event sent to Sentry. | ||||||
| 1. Add the `SentryErrorButton` component to a page and open it in your browser. For most Nuxt applications, this will be at localhost. | ||||||
| 2. Click the "Throw Sample Error" button, which triggers an error and starts a performance trace on the client side. | ||||||
|
|
||||||
| ## Verify | ||||||
| To test the server side as well, refer to the "Verify" section in the [Manual setup guide](/platforms/javascript/guides/nuxt/manual-setup/). | ||||||
|
Collaborator
Author
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. For a potential future update:
Collaborator
Author
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. @s1gr1d can you help answer ⬆ this question?
Member
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. In the example page that is created in the Nuxt wizard, there is also a call to an API route which is created by the wizard as well. But all of this is only created when the wizard detects the But I think it should be fine to create the component and the API route 🤔 So the component could call the API
Collaborator
Author
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. Thanks, @s1gr1d! I'll leave this as is for now 👍 |
||||||
|
|
||||||
| This snippet includes an intentional error, so you can test that everything is working as soon as you set it up. | ||||||
| </Expandable> | ||||||
|
|
||||||
| ### Server-side | ||||||
| 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/): | ||||||
|
|
||||||
| Sentry can only be loaded on the server-side by being explicitly added via `--import`. | ||||||
| Check out the <PlatformLink to="/install/cli-import">`--import` CLI flag</PlatformLink> docs for setup instructions. | ||||||
| ``` | ||||||
| # Start your app after building your project with `nuxi build` | ||||||
| node --import ./.output/server/sentry.server.config.mjs .output/server/index.mjs | ||||||
| ``` | ||||||
|
|
||||||
| To verify that Sentry works on the server-side, add the following snippet on the server-side: | ||||||
| After building and running your project: | ||||||
|
|
||||||
| ```js {tabTitle:Nitro} {filename:server/api/sentry-example.get.ts} | ||||||
| export default defineEventHandler(event => { | ||||||
| throw new Error("Sentry Example API Route Error"); | ||||||
| }); | ||||||
| ``` | ||||||
| 1. Open the example page `/sentry-example-page` in your browser. For most Nuxt applications, this will be at localhost. | ||||||
|
Member
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 write the full path here? Since it's always on localhost 🤔
Suggested change
|
||||||
| 2. Click the "Throw sample error" button. This triggers two errors: | ||||||
| - a frontend error | ||||||
| - an error within the API route | ||||||
|
|
||||||
| If you want to test server-side monitoring locally, build your project and run: | ||||||
| ``` | ||||||
| # Start your app after building your project with `nuxi build` | ||||||
| node --import ./.output/server/sentry.server.config.mjs .output/server/index.mjs | ||||||
| ``` | ||||||
| Sentry captures both of these errors for you. Additionally, the button click starts a performance trace to measure the time it takes for the API request to complete. | ||||||
|
|
||||||
| <Alert level="warning"> | ||||||
| Sentry server-side monitoring **doesn't work in development mode!** | ||||||
| ### View Captured Data in Sentry | ||||||
|
|
||||||
| If you experience any issues with the server-side setup, check out <PlatformLink to="/troubleshooting">Troubleshooting</PlatformLink> | ||||||
| or read through the different <PlatformLink to="/install">installation methods</PlatformLink>. | ||||||
| </Alert> | ||||||
| Now, head over to your project on [Sentry.io](https://sentry.io/) to view the collected data (it takes a couple of moments for the data to appear). | ||||||
|
|
||||||
| ### Client-side | ||||||
|
|
||||||
| Add the following snippet on the client-side: | ||||||
|
|
||||||
| ```html {tabTitle:Vue} {filename:pages/example-error.vue} | ||||||
| <script setup> | ||||||
| import * as Sentry from '@sentry/nuxt'; | ||||||
|
|
||||||
| function triggerClientError() { | ||||||
| throw new Error("Nuxt Button Error"); | ||||||
| }; | ||||||
|
|
||||||
| function getSentryData() { | ||||||
| Sentry.startSpan( | ||||||
| { | ||||||
| name: 'Example Frontend Span', | ||||||
| op: 'test' | ||||||
| }, | ||||||
| async () => { | ||||||
| await $fetch('/api/sentry-example'); | ||||||
| } | ||||||
| ) | ||||||
| } | ||||||
| </script> | ||||||
|
|
||||||
| <template> | ||||||
| <button id="errorBtn" @click="triggerClientError"> | ||||||
| Throw Client Error | ||||||
| </button> | ||||||
| <button type="button" @click="getSentryData"> | ||||||
| Throw Server Error | ||||||
| </button> | ||||||
| </template> | ||||||
| ``` | ||||||
| <PlatformContent includePath="getting-started-browser-sandbox-warning" /> | ||||||
|
|
||||||
| <PlatformContent includePath="getting-started-verify-locate-data" /> | ||||||
|
|
||||||
| <Alert> | ||||||
| ## Next Steps | ||||||
|
|
||||||
| Learn more about manually capturing an error or message in our <PlatformLink to="/usage/">Usage documentation</PlatformLink>. | ||||||
| At this point, you should have integrated Sentry into your Nuxt application and should already be sending error and performance data to your Sentry project. | ||||||
|
|
||||||
| </Alert> | ||||||
| Now's a good time to customize your setup and look into more advanced topics. Our next recommended steps for you are: | ||||||
|
|
||||||
| To view and resolve the recorded error, log into [sentry.io](https://sentry.io) and select your project. Clicking on the error's title will open a page where you can see detailed information and mark it as resolved. | ||||||
| - Learn how to [manually capture errors](/platforms/javascript/guides/nuxt/usage/) | ||||||
| - Continue to [customize your configuration](/platforms/javascript/guides/nuxt/configuration/) | ||||||
| - Get familiar with [Sentry's product features](/product) like tracing, insights, and alerts | ||||||
| - Learn how to [track your Vue components or your Pinia store](/platforms/javascript/guides/nuxt/features/) | ||||||
|
|
||||||
| ## Next Steps | ||||||
| <Expandable permalink={false} title="Are you having problems setting up the SDK?"> | ||||||
|
|
||||||
| - If you encountered issues with our installation wizard, try [setting up Sentry manually](/platforms/javascript/guides/nuxt/manual-setup/) | ||||||
| - [Get support](https://sentry.zendesk.com/hc/en-us/) | ||||||
|
|
||||||
| - Track your Vue Components or your Pinia store by [adding support for client features](/platforms/javascript/guides/nuxt/features/) | ||||||
| - In case you experience any issues during setup or startup, check out <PlatformLink to="/troubleshooting">Troubleshooting</PlatformLink> | ||||||
| or read through the different <PlatformLink to="/install">installation methods</PlatformLink>. | ||||||
| </Expandable> | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <Expandable title="Want to learn more about these features?"> | ||
|
|
||
| - [**Issues**](/product/issues) (always enabled): Sentry's core error monitoring product that automatically reports errors, | ||
| uncaught exceptions, and unhandled rejections. If you have something that | ||
| looks like an exception, Sentry can capture it. | ||
| - [**Tracing**](/product/tracing): Track software performance while seeing the | ||
| impact of errors across multiple systems. For example, distributed tracing | ||
| allows you to follow a request from the frontend to the backend and back. | ||
| - [**Session Replay**](/product/explore/session-replay/web): | ||
| Get to the root cause of an issue faster by viewing a video-like reproduction | ||
| of what was happening in the user's browser before, during, and after the | ||
| problem. | ||
|
|
||
| </Expandable> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <Expandable title="Want to learn more about these features?"> | ||
|
|
||
| - [**Issues**](/product/issues) (always enabled): Sentry's core error monitoring product that automatically reports errors, | ||
| uncaught exceptions, and unhandled rejections. If you have something that | ||
| looks like an exception, Sentry can capture it. | ||
| - [**Tracing**](/product/tracing): Track software performance while seeing the | ||
| impact of errors across multiple systems. For example, distributed tracing | ||
| allows you to follow a request from the frontend to the backend and back. | ||
| - [**Profiling**](/product/explore/profiling/): Gain deeper insight than traditional tracing without custom instrumentation, letting you discover slow-to-execute or resource-intensive functions in your app. | ||
|
|
||
| </Expandable> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| ## Prerequisites | ||
|
|
||
| You need: | ||
|
|
||
| - A Sentry [account](https://sentry.io/signup/) and [project](/product/projects/) | ||
| - Your application up and running | ||
| - Nuxt version `3.7.0` or above (`3.14.0`+ recommended) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| <Expandable title="Need help locating the captured errors in your Sentry project?"> | ||
|
|
||
| 1. Open the [**Issues**](https://sentry.io/orgredirect/organizations/:orgslug/issues) page and select an error from the issues list to view the full details and context of this error. For an interactive UI walkthrough, click [here](/product/sentry-basics/integrate-frontend/generate-first-error/#ui-walkthrough). | ||
| 2. Open the [**Traces**](https://sentry.io/orgredirect/organizations/:orgslug/traces) page and select a trace to reveal more information about each span, its duration, and any errors. For an interactive UI walkthrough, click [here](/product/sentry-basics/distributed-tracing/generate-first-error/#ui-walkthrough). | ||
| 3. Open the [**Profiles**](https://sentry.io/orgredirect/organizations/:orgslug/profiling) page, select a transaction, and then a profile ID to view its flame graph. For more information, click [here](/product/explore/profiling/profile-details/). | ||
|
|
||
| </Expandable> |
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.
I created a new platform-include for this content and updated existing quick start guides to use it