Skip to content

⚗️ Add Angular Router integration#4315

Open
rgaignault wants to merge 6 commits intomainfrom
romanG/angular-integration
Open

⚗️ Add Angular Router integration#4315
rgaignault wants to merge 6 commits intomainfrom
romanG/angular-integration

Conversation

@rgaignault
Copy link
Contributor

@rgaignault rgaignault commented Mar 11, 2026

Motivation

The RUM Browser SDK supports React but has no Angular equivalent. Angular is widely used and customers need RUM views aligned with their Angular route definitions — using route patterns like /article/:articleId instead of resolved URLs like /article/2.

This PR adds @datadog/browser-rum-angular, starting with Angular Router integration as described in the Angular integration RFC.

Changes

New package: @datadog/browser-rum-angular

  • angularPlugin({ router: true }) — RUM plugin that enables manual view tracking when router integration is active
  • provideDatadogRouter() — Angular provider that listens to GuardsCheckEnd events, computes the view name from the route snapshot tree, and starts a new RUM view
  • computeRouteViewName() — Walks the primary outlet chain to build a stable view name from route patterns (e.g. /users/:id/posts/:postId), skipping layout wrappers and named outlets

Uses GuardsCheckEnd rather than NavigationEnd so that resolver data fetches are attributed to the correct view.

Test app & E2E

  • Angular 15 test app with static, parameterized, and lazy-loaded routes
  • AOT compilation via @ngtools/webpack + Angular linker (no unsafe-eval needed)
  • E2E scenarios validating view names for navigation and nested routes

Test instructions

yarn test:unit --spec packages/rum-angular
yarn test:e2e -g "angular plugin"

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

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

cit-pr-commenter-54b7da bot commented Mar 11, 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.006 0.0042 -30.00%
RUM - add action 0.0186 0.0141 -24.19%
RUM - add error 0.0195 0.0145 -25.64%
RUM - add timing 0.0036 0.0028 -22.22%
RUM - start view 0.029 0.0139 -52.07%
RUM - start/stop session replay recording 0.0018 0.0007 -61.11%
Logs - log message 0.0199 0.0158 -20.60%
🧠 Memory Performance
Action Name Base Memory Consumption Local Memory Consumption 𝚫
RUM - add global context 26.56 KiB 26.62 KiB +69 B
RUM - add action 51.61 KiB 52.88 KiB +1.27 KiB
RUM - add timing 27.91 KiB 26.39 KiB -1.52 KiB
RUM - add error 55.17 KiB 54.78 KiB -397 B
RUM - start/stop session replay recording 26.15 KiB 25.71 KiB -453 B
RUM - start view 466.22 KiB 464.89 KiB -1.33 KiB
Logs - log message 45.51 KiB 44.83 KiB -692 B

🔗 RealWorld

@datadog-datadog-prod-us1-2
Copy link

datadog-datadog-prod-us1-2 bot commented Mar 11, 2026

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 71.74%
Overall Coverage: 77.27% (-0.03%)

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

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: 1d86086b1e

ℹ️ 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-integration branch 2 times, most recently from 84e221e to 8846690 Compare March 11, 2026 19:42
@rgaignault rgaignault marked this pull request as draft March 11, 2026 20:43
@rgaignault rgaignault force-pushed the romanG/angular-integration branch 2 times, most recently from 61f19c4 to 09b6061 Compare March 12, 2026 13:33
@rgaignault rgaignault changed the title Add @datadog/browser-rum-angular package with Angular Router integration ✨ Add @datadog/browser-rum-angular package with Angular Router integration Mar 12, 2026
@rgaignault rgaignault force-pushed the romanG/angular-integration branch from 78eecf0 to 4fd7473 Compare March 12, 2026 13:42
@amortemousque amortemousque changed the title ✨ Add @datadog/browser-rum-angular package with Angular Router integration ⚗️ Add Angular Router integration Mar 17, 2026
@amortemousque amortemousque force-pushed the romanG/angular-integration branch 2 times, most recently from 5e2e8d3 to 323e229 Compare March 18, 2026 13:44
@rgaignault rgaignault marked this pull request as ready for review March 18, 2026 14:10
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: 323e2297f6

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

@amortemousque amortemousque force-pushed the romanG/angular-integration branch 2 times, most recently from aafc358 to f2f532f Compare March 18, 2026 14:46
@amortemousque amortemousque force-pushed the romanG/angular-integration branch from f2f532f to 0887365 Compare March 18, 2026 14:54
@amortemousque amortemousque force-pushed the romanG/angular-integration branch from 25b8a69 to d9e1544 Compare March 18, 2026 22:00
},
onRumStart({ addError }) {
globalAddError = addError
for (const subscriber of onRumStartSubscribers) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as you said to me haha we can move the if outside.

// Bootstrap - dynamically create root element (E2E framework serves bare HTML)
const rootElement = document.createElement('app-root')
document.body.appendChild(rootElement)
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this an unsafe-call? Does it mean customers have to add this too?

await flushEvents()
const viewEvents = intakeRegistry.rumViewEvents
expect(viewEvents.length).toBeGreaterThan(0)
const lastView = viewEvents[viewEvents.length - 1]
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use view. referrer? instead of [viewEvents. length - 1]

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