All skills
datadog-labs avatar

/dd-instrument-rum

@659ea9a official

Instrument browser-based web applications with Datadog Browser RUM. Detect the application framework, router, package manager, bundler, entrypoint, credentials, and existing RUM setup; add or safely complete classic Browser RUM instrumentation for React, Next.js App or Pages Router, Angular, Vue, Nuxt, Svelte, vanilla JavaScript, SPAs, and iframe-hosted apps; avoid duplicate initialization; and verify the application still builds. Use when asked to add, set up, instrument, repair, or verify Datadog RUM, Browser Monitoring, Session Replay, or framework-specific Browser RUM plugins.

Use this Skill: https://skilld.dev/gh/datadog-labs/agent-skills/dd-instrument-rum

This session only. Nothing lands on disk.

referencesrum-react.md

≈831 tokens on demand. Your agent reads this file only when SKILL.md points to it.

React integration

Read rum-core.md first. Use this integration only for plain React applications, not Next.js.

Prerequisites and packages

Require React 18 or 19. Stop before editing when the detected React major is unsupported.

Install together:

npm install --save @datadog/browser-rum @datadog/browser-rum-react

Keep both packages on the same exact version. Initialize at module scope in the browser entry before createRoot(...).render(...) or the legacy render call:

import { datadogRum } from '@datadog/browser-rum'
import { reactPlugin } from '@datadog/browser-rum-react'

datadogRum.init({
  // ...canonical fields from rum-core.md...
  plugins: [reactPlugin()],
})

Do not add router mode when the application does not use a supported router.

React Router

Support React Router v6, v7, and v8. Detect the installed major and the router APIs actually used. Initialize with:

plugins: [reactPlugin({ router: true })]

Replace only these imports when they are used: createBrowserRouter, createHashRouter, createMemoryRouter, useRoutes, and Routes. Keep unrelated router exports such as RouterProvider, Link, hooks, and route utilities on their original package.

Choose the matching Datadog entrypoint:

Router major Datadog entrypoint
v6 @datadog/browser-rum-react/react-router-v6
v7 @datadog/browser-rum-react/react-router-v7
v8 @datadog/browser-rum-react/react-router-v8

Do not use the version-agnostic react-router entrypoint for a known older major because it targets the latest supported router. Preserve whether the application imports its other APIs from react-router, react-router/dom, or react-router-dom.

TanStack Router

Require @tanstack/react-router >=1.64.0 and <2. Detect actual usage rather than enabling this path from dependency presence alone.

Use reactPlugin({ router: true }) and replace only the createRouter import:

- import { createRouter } from '@tanstack/react-router'
+ import { createRouter } from '@datadog/browser-rum-react/tanstack-router'

Keep RouterProvider, Link, route construction helpers, and all other TanStack exports imported from @tanstack/react-router.

If React Router and TanStack Router dependencies are both present, instrument only the router that constructs the active application router. Stop and ask rather than guessing when both are genuinely active entrypoints.

Error integration

Do not create a new error boundary or fallback UI solely for instrumentation.

  • If the application already has a class error boundary, import addReactError and call it from the existing componentDidCatch(error, errorInfo) while preserving the handler's current behavior.
  • If the application already uses React 19 createRoot error callbacks, call addReactError from those callbacks and preserve their logging/recovery logic.
  • If the application already uses Datadog's ErrorBoundary or calls addReactError, do not add a second report path.
  • Do not add onCaughtError when an existing boundary already reports the same caught error; that creates duplicates.

Core Browser RUM already captures uncaught browser errors. A project with no existing component-error surface remains valid with reactPlugin() and no invented UI.

Source: SKILL.md on GitHub

No alerts1mo3 checks · Risk SAFE
  • Gen Agent Trust Hub1mo

    The skill performs automated instrumentation of web applications using Datadog Browser RUM. It executes standard build and installation commands and ingests project source files, presenting a standard attack surface for indirect prompt injection common to developer tools.

  • Socket1mo

    No alerts

  • Snyk1mo

    Risk: LOW · No issues

Signed by skilld at 659ea9a. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated last month
Other metadata
metadata
{
  "version": "0.1.0",
  "author": "datadog-labs",
  "repository": "https://github.com/datadog-labs/agent-skills",
  "tags": "datadog,rum,browser-rum,instrumentation,session-replay,react,nextjs,angular,vue,nuxt,svelte",
  "alwaysApply": "false"
}

README badge

README badge for datadog-labs/agent-skills/dd-instrument-rum