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-nextjs.md

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

Next.js integration

Read rum-core.md first. Use @datadog/browser-rum-nextjs, not the plain React plugin.

Prerequisites and packages

Require Next.js 15.3 or later and React 18 or later. Confirm the configured Node runtime satisfies the detected Next.js package's engine requirement. If any prerequisite fails, stop without editing and report the detected and required versions. Do not upgrade Next.js and do not fall back to a client component or CDN setup.

Install together at the same exact version:

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

Initialize once

Create instrumentation-client.ts or .js at the Next.js source root required by the project's layout. Put the canonical datadogRum.init() from rum-core.md at module scope with plugins: [nextjsPlugin()].

For an App Router application:

import { datadogRum } from '@datadog/browser-rum'
import { nextjsPlugin, onRouterTransitionStart } from '@datadog/browser-rum-nextjs'

export { onRouterTransitionStart }

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

For a Pages Router-only application, omit onRouterTransitionStart:

import { datadogRum } from '@datadog/browser-rum'
import { nextjsPlugin } from '@datadog/browser-rum-nextjs'

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

Use NEXT_PUBLIC_ variables for values that must be read by this client module when following an existing environment-variable convention.

Wire the router

For App Router, render DatadogAppRouter exactly once in the root app/layout body without converting the layout to a client component:

import { DatadogAppRouter } from '@datadog/browser-rum-nextjs'

<body>
  <DatadogAppRouter />
  {children}
</body>

For Pages Router, render DatadogPagesRouter exactly once in the existing custom pages/_app alongside the page component:

import { DatadogPagesRouter } from '@datadog/browser-rum-nextjs'

<>
  <DatadogPagesRouter />
  <Component {...pageProps} />
</>

If both route trees are genuinely used, export onRouterTransitionStart and wire each router component in its own existing root. Keep a single init in instrumentation-client.

Error integration

Do not create an error page, error boundary, reset button, or fallback UI solely for RUM.

  • When an App Router error.tsx or global-error.tsx already exists, call addNextjsError(error) from an effect keyed by error, preserving the existing UI and reset behavior. Do not add another call if already present.
  • When Pages Router already has a custom error boundary, use the package's addNextjsError or ErrorBoundary in that existing surface without creating a second reporting path.
  • Preserve the digest attached to App Router server-component errors; pass the original error object.

Do not add @datadog/browser-rum-react, CDN Script tags, server tracing, Vercel metadata, or source-map upload.

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