-
Notifications
You must be signed in to change notification settings - Fork 827
✨ RUM Browser - Add Nuxt Integration #2987
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
Open
BeltranBulbarellaDD
wants to merge
4
commits into
master
Choose a base branch
from
beltran.bulbarella/browser-sdk-nuxt-plugin
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+153
−1
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # CHANGELOG - Nuxt | ||
|
|
||
| ## 1.0.0 | ||
|
|
||
| **Added**: | ||
|
|
||
| * Initial Nuxt RUM Integration Tile. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| # RUM Browser Monitoring - Nuxt integration | ||
|
|
||
| ## Overview | ||
|
|
||
| The Datadog RUM Nuxt integration provides framework-specific instrumentation to help you monitor and debug Nuxt applications. This integration adds: | ||
|
|
||
| - **Automatic route change detection** for Nuxt file-based routing | ||
| - **View name normalization** that converts dynamic route segments into parameterized names (for example, `/user/123` becomes `/user/[id]`) | ||
| - **Error reporting** through both Vue's global error handler and Nuxt's `app:error` hook | ||
| - **Full-stack visibility** by correlating frontend performance with backend traces and logs | ||
|
|
||
| Combined with Datadog RUM's core capabilities, you can debug performance bottlenecks, track user journeys, monitor Core Web Vitals, and analyze every user session with context. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| This integration requires Nuxt v3 or v4, Vue v3.5+, and Vue Router v4+. | ||
|
|
||
| ## Setup | ||
|
|
||
| Start by setting up [Datadog RUM][1] in your Nuxt application. | ||
|
|
||
| After setting up RUM, add the [RUM-Nuxt plugin][2] to the Browser SDK. | ||
|
|
||
| ## Basic usage | ||
|
|
||
| Create a client-side Nuxt plugin such as `plugins/datadog-rum.client.ts` and initialize the Datadog RUM SDK with `nuxtRumPlugin`: | ||
|
|
||
| ```ts | ||
| import { datadogRum } from '@datadog/browser-rum' | ||
| import { nuxtRumPlugin } from '@datadog/browser-rum-nuxt' | ||
| import { defineNuxtPlugin, useNuxtApp, useRouter } from 'nuxt/app' | ||
|
|
||
| export default defineNuxtPlugin({ | ||
| name: 'datadog-rum', | ||
| enforce: 'pre', | ||
| setup() { | ||
| datadogRum.init({ | ||
| applicationId: '<APP_ID>', | ||
| clientToken: '<CLIENT_TOKEN>', | ||
| site: 'datadoghq.com', | ||
| plugins: [ | ||
| nuxtRumPlugin({ | ||
| router: useRouter(), | ||
| nuxtApp: useNuxtApp(), | ||
| }), | ||
| ], | ||
| }) | ||
| }, | ||
| }) | ||
| ``` | ||
|
|
||
| Using `enforce: 'pre'` lets the plugin capture startup errors reported through Nuxt's `app:error` hook before later plugins run. | ||
|
|
||
| Passing `nuxtApp` is optional, but recommended. When provided, the integration automatically reports: | ||
|
|
||
| - Vue component errors handled by `vueApp.config.errorHandler` | ||
| - Nuxt startup errors reported through `app:error` | ||
|
|
||
| ## Manual error reporting | ||
|
|
||
| If you catch a Nuxt or Vue error and want to report it to Datadog RUM, use `addNuxtError`: | ||
|
|
||
| ```vue | ||
| <script setup lang="ts"> | ||
| import { onErrorCaptured } from 'vue' | ||
| import { addNuxtError } from '@datadog/browser-rum-nuxt' | ||
|
|
||
| onErrorCaptured((error, instance, info) => { | ||
| addNuxtError(error, instance, info) | ||
| }) | ||
|
BeltranBulbarellaDD marked this conversation as resolved.
BeltranBulbarellaDD marked this conversation as resolved.
|
||
| </script> | ||
| ``` | ||
|
|
||
| ## Route tracking | ||
|
|
||
| The `nuxtRumPlugin` automatically tracks route changes as RUM views and normalizes dynamic segments to Nuxt-style file route names: | ||
|
|
||
| | Actual URL | View name | | ||
| | --------------- | ------------------- | | ||
| | `/about` | `/about` | | ||
| | `/user/123` | `/user/[id]` | | ||
| | `/blog/test` | `/blog/[[slug]]` | | ||
| | `/guides/a/b/c` | `/guides/[...slug]` | | ||
|
|
||
| Query string changes do not create a new view, but hash changes do. | ||
|
|
||
| ## Go further with Datadog Nuxt integration | ||
|
|
||
| ### Traces | ||
|
|
||
| Connect your RUM and trace data to get a complete view of your application's performance. See [Connect RUM and Traces][3]. | ||
|
|
||
| ### Logs | ||
|
|
||
| To forward your Nuxt application's logs to Datadog, see [JavaScript Logs Collection][4]. | ||
|
|
||
| ### Metrics | ||
|
|
||
| To generate custom metrics from your RUM application, see [Generate Metrics][5]. | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| Need help? Contact [Datadog Support][6]. | ||
|
|
||
| [1]: https://docs.datadoghq.com/real_user_monitoring/application_monitoring/browser/setup/client/ | ||
| [2]: https://www.npmjs.com/package/@datadog/browser-rum-nuxt | ||
| [3]: https://docs.datadoghq.com/tracing/other_telemetry/rum/ | ||
| [4]: https://docs.datadoghq.com/logs/log_collection/javascript/ | ||
| [5]: https://docs.datadoghq.com/real_user_monitoring/platform/generate_metrics/ | ||
| [6]: https://docs.datadoghq.com/help/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| { | ||
| "manifest_version": "2.0.0", | ||
| "app_uuid": "0bbcbba0-1ebc-423d-905f-4320f615fe15", | ||
| "app_id": "rum-nuxt-plugin", | ||
| "owner": "rum-browser", | ||
| "display_on_public_website": true, | ||
| "tile": { | ||
| "overview": "README.md#Overview", | ||
| "configuration": "README.md#Setup", | ||
| "support": "README.md#Troubleshooting", | ||
| "changelog": "CHANGELOG.md", | ||
| "description": "Monitor Nuxt applications with automatic route tracking and error reporting.", | ||
| "title": "Nuxt", | ||
| "media": [], | ||
| "classifier_tags": [ | ||
| "Category::Metrics", | ||
| "Category::Network", | ||
| "Category::Tracing", | ||
| "Supported OS::Android", | ||
| "Supported OS::Linux", | ||
| "Supported OS::Windows", | ||
| "Supported OS::iOS", | ||
| "Supported OS::macOS", | ||
| "Offering::Integration" | ||
| ] | ||
| }, | ||
| "author": { | ||
| "support_email": "help@datadoghq.com", | ||
| "name": "Datadog", | ||
| "homepage": "https://www.datadoghq.com", | ||
| "sales_email": "info@datadoghq.com" | ||
| }, | ||
| "assets": {} | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.