Skip to content

✨ add vuePlugin and addVueError#4327

Merged
mormubis merged 1 commit intomainfrom
adlrb/vue-plugin
Mar 18, 2026
Merged

✨ add vuePlugin and addVueError#4327
mormubis merged 1 commit intomainfrom
adlrb/vue-plugin

Conversation

@mormubis
Copy link
Contributor

@mormubis mormubis commented Mar 13, 2026

Motivation

Second of five PRs (#4325 is the first one). First one with actual user-facing code. After this, Vue apps can report errors to Datadog with Vue-specific context.

Changes

vuePlugin() is the RUM plugin Vue apps register via datadogRum.init({ plugins: [vuePlugin()] }). It uses the same module-level subscriber pattern as reactPlugin: onVueInit and onVueStart hooks let features queue work until the plugin initializes, so call order doesn't matter. vuePlugin({ router: true }) additionally sets trackViewsManually: true to disable the SDK's automatic URL tracking, which PR 3 takes over with parameterized route names.

addVueError matches Vue's app.config.errorHandler signature exactly, so it can be assigned directly without a wrapper:

app.config.errorHandler = addVueError

Vue's info string (e.g. "mounted hook", "v-on handler") maps to component_stack. context.framework is set to "vue". Errors thrown before datadogRum.init() are queued and flushed when RUM starts.

The implementation uses addError from StartRumResult directly, the same pattern introduced in #4343 for addNextjsError, rather than constructing the event manually with addEvent.

Test instructions

yarn test:unit --spec packages/rum-vue/src/domain/vuePlugin.spec.ts
yarn test:unit --spec packages/rum-vue/src/domain/error/addVueError.spec.ts

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change
  • Added e2e/integration tests
  • Updated documentation

@cit-pr-commenter-54b7da
Copy link

cit-pr-commenter-54b7da bot commented Mar 13, 2026

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 175.02 KiB 175.02 KiB 0 B 0.00%
Rum Profiler 6.16 KiB 6.16 KiB 0 B 0.00%
Rum Recorder 27.46 KiB 27.46 KiB 0 B 0.00%
Logs 56.80 KiB 56.80 KiB 0 B 0.00%
Rum Slim 130.66 KiB 130.66 KiB 0 B 0.00%
Worker 23.63 KiB 23.63 KiB 0 B 0.00%
🚀 CPU Performance
Action Name Base CPU Time (ms) Local CPU Time (ms) 𝚫%
RUM - add global context 0.0041 0.0038 -7.32%
RUM - add action 0.0174 0.0155 -10.92%
RUM - add error 0.0194 0.0127 -34.54%
RUM - add timing 0.0034 0.0029 -14.71%
RUM - start view 0.0142 0.0133 -6.34%
RUM - start/stop session replay recording 0.001 0.0007 -30.00%
Logs - log message 0.0175 0.016 -8.57%
🧠 Memory Performance
Action Name Base Memory Consumption Local Memory Consumption 𝚫
RUM - add global context 26.55 KiB 27.44 KiB +908 B
RUM - add action 50.84 KiB 52.49 KiB +1.65 KiB
RUM - add timing 26.66 KiB 26.76 KiB +96 B
RUM - add error 56.11 KiB 55.80 KiB -317 B
RUM - start/stop session replay recording 25.81 KiB 25.08 KiB -748 B
RUM - start view 465.73 KiB 460.74 KiB -4.99 KiB
Logs - log message 44.50 KiB 44.78 KiB +290 B

🔗 RealWorld

@datadog-official
Copy link

datadog-official bot commented Mar 13, 2026

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 88.57%
Overall Coverage: 77.30% (+0.05%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 8c710e0 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

Base automatically changed from adlrb/vue-scaffold to main March 16, 2026 15:27
@mormubis mormubis force-pushed the adlrb/vue-plugin branch 4 times, most recently from 4e0030b to fdd1422 Compare March 17, 2026 10:42
@mormubis mormubis marked this pull request as ready for review March 17, 2026 11:26
@mormubis mormubis requested a review from a team as a code owner March 17, 2026 11:26
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fdd1422e2d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

componentStack: info || undefined,
startClocks,
context: {
...(error as Error & { dd_context?: Context }).dd_context,

Choose a reason for hiding this comment

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

P2 Badge Guard dd_context access for nullish thrown values

addVueError intentionally accepts error: unknown, but the context merge currently does ...(error as Error & { dd_context?: Context }).dd_context unconditionally. If Vue forwards a non-Error throw like null or undefined (which is valid JavaScript and permitted by app.config.errorHandler’s unknown type), this property access throws before addError is called, so the original Vue error is lost and the error handler itself can fail. Please extract dd_context only after checking the value is indexable/object-like.

Useful? React with 👍 / 👎.

Copy link
Contributor

@BeltranBulbarellaDD BeltranBulbarellaDD left a comment

Choose a reason for hiding this comment

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

LGTM

@mormubis mormubis merged commit 05e66f9 into main Mar 18, 2026
21 checks passed
@mormubis mormubis deleted the adlrb/vue-plugin branch March 18, 2026 16:03
@github-actions github-actions bot locked and limited conversation to collaborators Mar 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants