Skip to content

⚗️ Angular- Add error handling integration#4358

Open
rgaignault wants to merge 6 commits intoromanG/angular-integrationfrom
romanG/angular-error-on-router
Open

⚗️ Angular- Add error handling integration#4358
rgaignault wants to merge 6 commits intoromanG/angular-integrationfrom
romanG/angular-error-on-router

Conversation

@rgaignault
Copy link
Contributor

@rgaignault rgaignault commented Mar 19, 2026

Motivation

Add error handling to @datadog/browser-rum-angular, complementing the router integration from #4315.

When an Angular error occurs, without this integration it shows up as an anonymous unhandled error via window.onerror. With this integration, errors are properly categorized as handled errors with framework: "angular" context and a handling_stack.

Changes

New exports:

  • provideDatadogErrorHandler() — Angular provider that replaces the default ErrorHandler, reports errors to RUM then delegates to super.handleError()
  • addAngularError(error) — standalone function for users with custom error handlers

Implementation:

  • Uses the addError plugin API (same pattern as React's addReactError)
  • Captures handling_stack via createHandlingStack('angular error')

Tests:

  • Unit tests for addAngularError, provideDatadogErrorHandler, and dd_context merging
  • E2E tests for error reporting and dd_context support

RFC: https://datadoghq.atlassian.net/wiki/spaces/RUMP/pages/6387532503

@rgaignault rgaignault requested a review from a team as a code owner March 19, 2026 12:33
@cit-pr-commenter-54b7da
Copy link

cit-pr-commenter-54b7da bot commented Mar 19, 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.0042 0.0039 -7.14%
RUM - add action 0.0141 0.0132 -6.38%
RUM - add error 0.0145 0.0127 -12.41%
RUM - add timing 0.0028 0.0027 -3.57%
RUM - start view 0.0139 0.0127 -8.63%
RUM - start/stop session replay recording 0.0007 0.0007 0.00%
Logs - log message 0.0158 0.015 -5.06%
🧠 Memory Performance
Action Name Base Memory Consumption Local Memory Consumption 𝚫
RUM - add global context 26.62 KiB 26.86 KiB +247 B
RUM - add action 52.88 KiB 52.03 KiB -870 B
RUM - add timing 26.39 KiB 26.98 KiB +605 B
RUM - add error 54.78 KiB 54.55 KiB -237 B
RUM - start/stop session replay recording 25.71 KiB 25.63 KiB -79 B
RUM - start view 464.89 KiB 463.18 KiB -1.71 KiB
Logs - log message 44.83 KiB 44.18 KiB -662 B

🔗 RealWorld

@datadog-prod-us1-5
Copy link

datadog-prod-us1-5 bot commented Mar 19, 2026

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 77.30% (+0.03%)

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

@rgaignault rgaignault force-pushed the romanG/angular-error-on-router branch from 5d02daf to cc41070 Compare March 19, 2026 13:02
@rgaignault rgaignault marked this pull request as draft March 19, 2026 13:06
@rgaignault rgaignault force-pushed the romanG/angular-error-on-router branch from cc41070 to 7284bc7 Compare March 19, 2026 13:10
@rgaignault rgaignault marked this pull request as ready for review March 19, 2026 13:11
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: 7284bc7112

ℹ️ 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".

@rgaignault rgaignault force-pushed the romanG/angular-error-on-router branch from 7284bc7 to a77040b Compare March 19, 2026 13:29
@rgaignault rgaignault changed the title ✨ Angular- Add error handling integration ⚗️ Angular- Add error handling integration Mar 19, 2026
@rgaignault rgaignault force-pushed the romanG/angular-error-on-router branch from a77040b to 7cd6e04 Compare March 19, 2026 13:47
Copy link
Collaborator

Choose a reason for hiding this comment

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

❓ question: ‏Why do you need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@angular/core uses globalThis directly (without a guard), and that throw a reference error on chrome 63

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh interesting :)
Out of curiosity, do you have the reference in @angular/core where it’s used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you have any other idea to handle this ?

@rgaignault rgaignault force-pushed the romanG/angular-error-on-router branch from a369d88 to 37da729 Compare March 19, 2026 15:21
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

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.

3 participants