Skip to content

Shadow: ⚗️ Add Nuxt error tracking (v5)#94

Open
allspain wants to merge 9 commits into
shadow/4477/v5-basefrom
shadow/4477/v5
Open

Shadow: ⚗️ Add Nuxt error tracking (v5)#94
allspain wants to merge 9 commits into
shadow/4477/v5-basefrom
shadow/4477/v5

Conversation

@allspain
Copy link
Copy Markdown
Owner

Shadow Review — PR #4477 v5

Source: DataDog/browser-sdk#4477
Commit: b13420280c15615b1f0f5cd317725b7fec5cb743
Timestamp: 2026-04-20T07:45:14Z


Original PR Description

Motivation

This PR adds first-class Nuxt error tracking, covering both Vue rendering/lifecycle errors (via vueApp.config.errorHandler) and Nuxt startup errors thrown in plugins or app hooks (via the app:error hook).

Changes

New public APIs (exported from @datadog/browser-rum-nuxt)

  • addNuxtError(error, instance, info) — a low-level function compatible with both vueApp.config.errorHandler and Nuxt's app:error hook. Intended for users who want manual control. It:

    • Captures a handling stack at call time
    • Builds a component stack string from the Vue component hierarchy and the info string
    • Merges a dd_context property from the error object (if present) into the event context
    • Tags all events with framework: 'nuxt'
    • Buffers errors thrown before RUM initialises and flushes them once datadogRum.init completes
  • setupNuxtErrorHandling(nuxtApp) — a convenience helper that sets up both handlers automatically. It:

    • Wraps the existing vueApp.config.errorHandler (preserving Nuxt's own error page handler)
    • Hooks into app:error for errors thrown during plugin/app startup
    • Uses WeakSet-based deduplication to prevent double-reporting when the same error bubbles through both errorHandler and app:error

Internal changes

  • nuxtRumPlugin now implements the onRumStart lifecycle hook to receive and distribute the addError function to buffered subscribers
  • createHandlingStack extended with a 'nuxt error' source label

Test instructions

  1. Unit tests:

    yarn test:unit --spec packages/rum-nuxt/src/domain/error/addNuxtError.spec.ts
  2. E2E tests:

    yarn test:e2e:init
    yarn test:e2e -g "nuxt error"
  3. Manual:

    • Start the Nuxt test app and navigate to /error-test. Click "Trigger Error" and verify a single RUM error event is collected with error.source: custom, context.framework: nuxt, and a handling_stack.
    • Navigate to /startup-error and verify a single RUM error event is collected for the startup error thrown in the plugin, again with context.framework: nuxt and a handling_stack.

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated documentation and/or relevant AGENTS.md file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants