upgrade-browser-sdk-v5
This skill automates migration of Datadog Browser SDK from v4 to v5 by updating CDN and npm dependencies, replacing deprecated configuration parameters and…
Identity proven by GitHub's verified organisation badge (DataDog, datadog-labs)
- Agents
- Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode, claude.ai and API
- License
- MIT (permissive)
- Pin
- 9cbd518pinned Oct 9, 2026
- Context cost
- about 3,600 tokenswhen the skill loads
- GitHub stars
- 177on datadog-labs/agent-skills
- Scripts
- None found
What it does
“Upgrade Datadog Browser SDK from v4 to v5. Use when encountering removed options like proxyUrl, sampleRate, replaySampleRate, premiumSampleRate, allowedTracingOrigins, or deprecated APIs like addRumGlobalContext, removeUser, or when a project references datadoghq-browser-agent.com CDN with /v4/ paths.”
Generated summary from the skill's own text
This skill automates migration of Datadog Browser SDK from v4 to v5 by updating CDN and npm dependencies, replacing deprecated configuration parameters and API methods, adjusting Session Replay defaults, and updating infrastructure settings like CSP domains. It provides a seven-step systematic process with search patterns to identify affected code throughout JavaScript, TypeScript, and template files.
When to use it
- Upgrading Datadog Browser SDK v4 projects to v5
- Fixing removed init options like proxyUrl, sampleRate, or replaySampleRate
- Replacing deprecated APIs such as addRumGlobalContext or removeUser
- Updating CDN script URLs from /v4/ to /v5/ paths
When not to
- Already running Datadog Browser SDK v5 or later
- Migrating from AP2 region without upgrading to v6 first
- Projects not using Datadog Browser SDK for monitoring
Install
These commands install from the publisher's repository and need no account.
skills CLI
npx skills add datadog-labs/agent-skills --skill upgrade-browser-sdk-v5Installs from the repository's default branch, which may have changed since the commit we checked.
GitHub CLI 2.90 or later
gh skill install datadog-labs/agent-skills upgrade-browser-sdk-v5@9cbd518922765c46d5d446f09cf03d060dd4b46fInstalls the commit we checked (9cbd518).
Copy by hand
Download the folder at 9cbd518 and put it in .claude/skills/upgrade-browser-sdk-v5 for Claude Code and in .agents/skills/upgrade-browser-sdk-v5 for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode.
Claude Code plugin
/plugin install datadog@claude-plugins-officialThe publisher's plugin in Claude's official marketplace. It may hold more than this skill, and we have not pinned it.
Copy for your agent
A prompt for any coding agent. It installs this skill from GitHub at the pinned commit, copies the files as they are, and runs nothing unless you ask.
Prompt
Install the agent skill "upgrade-browser-sdk-v5" by Datadog. Source, pinned to commit 9cbd518922765c46d5d446f09cf03d060dd4b46f: https://github.com/datadog-labs/agent-skills/tree/9cbd518922765c46d5d446f09cf03d060dd4b46f/dd-browser-sdk/upgrade-v5 1. Download that folder at exactly this commit. Do not use the default branch. 2. Copy every file unchanged, keeping the folder structure, into .claude/skills/upgrade-browser-sdk-v5/ for Claude Code and .agents/skills/upgrade-browser-sdk-v5/ for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode. Create the folders if they do not exist. 3. Do not edit the files, and do not run any script in the folder unless I ask you to. 4. When you are done, list the files you copied and where you put them. Listing and checks: https://www.agentnative.dev/skills/datadog/upgrade-browser-sdk-v5
SKILL.md at the pin
---
name: upgrade-browser-sdk-v5
description: >
Upgrade Datadog Browser SDK from v4 to v5. Use when encountering removed options like
proxyUrl, sampleRate, replaySampleRate, premiumSampleRate, allowedTracingOrigins, or
deprecated APIs like addRumGlobalContext, removeUser, or when a project references
datadoghq-browser-agent.com CDN with /v4/ paths.
metadata:
version: "1.0.0"
author: datadog-labs
repository: https://github.com/datadog-labs/agent-skills
tags: datadog,browser-sdk,rum,logs,migration,v5,upgrade
---
# Upgrade Datadog Browser SDK to v5
Systematic migration guide from v4 to v5. Follow steps 1-7 in order. Each step includes a search pattern to find affected code.
## Step 1: Update SDK version
**CDN setup** — update script `src` URLs:
| v4 pattern | v5 replacement |
| -------------------------------------------------------- | -------------------------------------------------------- |
| `datadoghq-browser-agent.com/us1/v4/datadog-rum.js` | `datadoghq-browser-agent.com/us1/v5/datadog-rum.js` |
| `datadoghq-browser-agent.com/us1/v4/datadog-logs.js` | `datadoghq-browser-agent.com/us1/v5/datadog-logs.js` |
| `datadoghq-browser-agent.com/us1/v4/datadog-rum-slim.js` | `datadoghq-browser-agent.com/us1/v5/datadog-rum-slim.js` |
Replace `us1` with your site: `eu1`, `us3`, `us5`, `ap1`. For US1-FED, the pattern is flat with no site prefix: `datadog-rum-v5.js`, `datadog-logs-v5.js`, `datadog-rum-slim-v5.js`. Note: AP2 is not available for v5 — upgrade to v6 first if you need AP2.
Search: `grep -r "datadoghq-browser-agent.com.*v4" --include="*.html" --include="*.js" --include="*.ts" --include="*.tsx" --include="*.jsx"`
**npm setup** — update `package.json` dependencies:
```
"@datadog/browser-rum": "^5.0.0"
"@datadog/browser-logs": "^5.0.0"
"@datadog/browser-rum-slim": "^5.0.0"
```
Then run your package manager (`npm install`, `yarn install`, etc.) and rebuild.
Also upgrade framework integrations to v5 if used: `@datadog/browser-rum-react`.
Search: `grep -r "@datadog/browser-" --include="package.json" .`
## Step 2: Replace deprecated init parameters
These v4 parameter names no longer exist in v5. Replace them:
| Deprecated parameter (v4) | Replacement (v5) |
| ------------------------- | ------------------------- |
| `proxyUrl` | `proxy` |
| `sampleRate` | `sessionSampleRate` |
| `allowedTracingOrigins` | `allowedTracingUrls` |
| `tracingSampleRate` | `traceSampleRate` |
| `trackInteractions` | `trackUserInteractions` |
| `premiumSampleRate` | `sessionReplaySampleRate` |
| `replaySampleRate` | `sessionReplaySampleRate` |
Search: `grep -rn 'proxyUrl\|sampleRate\|allowedTracingOrigins\|tracingSampleRate\|trackInteractions\|premiumSampleRate\|replaySampleRate' --include="*.js" --include="*.ts" --include="*.tsx" --include="*.jsx" --include="*.html" --include="*.vue" --include="*.svelte"`
**Note**: `sampleRate` matches broadly. Look specifically for init config objects — `sessionSampleRate` is the v5 name for the session sampling rate.
## Step 3: Replace deprecated public APIs
These v4 API method names no longer exist in v5:
### RUM APIs
| Deprecated API (v4) | Replacement (v5) |
| ------------------------------- | ------------------------------------ |
| `DD_RUM.removeUser` | `DD_RUM.clearUser` |
| `DD_RUM.addRumGlobalContext` | `DD_RUM.setGlobalContextProperty` |
| `DD_RUM.removeRumGlobalContext` | `DD_RUM.removeGlobalContextProperty` |
| `DD_RUM.getRumGlobalContext` | `DD_RUM.getGlobalContext` |
| `DD_RUM.setRumGlobalContext` | `DD_RUM.setGlobalContext` |
### Logs APIs
| Deprecated API (v4) | Replacement (v5) |
| ----------------------------------- | ------------------------------------- |
| `DD_LOGS.addLoggerGlobalContext` | `DD_LOGS.setGlobalContextProperty` |
| `DD_LOGS.removeLoggerGlobalContext` | `DD_LOGS.removeGlobalContextProperty` |
| `DD_LOGS.getLoggerGlobalContext` | `DD_LOGS.getGlobalContext` |
| `DD_LOGS.setLoggerGlobalContext` | `DD_LOGS.setGlobalContext` |
| `logger.addContext` | `logger.setContextProperty` |
| `logger.removeContext` | `logger.removeContextProperty` |
Search: `grep -rn 'removeUser\|addRumGlobalContext\|removeRumGlobalContext\|getRumGlobalContext\|setRumGlobalContext\|addLoggerGlobalContext\|removeLoggerGlobalContext\|getLoggerGlobalContext\|setLoggerGlobalContext\|\.addContext\|\.removeContext' --include="*.js" --include="*.ts" --include="*.tsx" --include="*.jsx" --include="*.html" --include="*.vue" --include="*.svelte"`
## Step 4: Update Session Replay configuration
v5 changes several Session Replay defaults and behaviors:
### 4a. `defaultPrivacyLevel` changed to `"mask"`
In v4, the default was `mask-user-input`. In v5, **all content is masked by default**.
To preserve v4 behavior (only mask user input):
```js
DD_RUM.init({
defaultPrivacyLevel: 'mask-user-input',
})
```
### 4b. Recording starts automatically
Sessions sampled for Session Replay are now automatically recorded. You no longer need to call `startSessionReplayRecording()`.
To preserve v4 behavior (manual recording start):
```js
DD_RUM.init({
startSessionReplayRecordingManually: true,
})
```
### 4c. Default `sessionReplaySampleRate` is now `0`
In v4, the default replay sample rate was 100. In v5, it's `0` — no replays unless you set it explicitly.
**Action**: Ensure `sessionReplaySampleRate` is explicitly set in your init config:
```js
DD_RUM.init({
sessionReplaySampleRate: 100, // or your desired rate
})
```
### 4d. `trackResources` and `trackLongTasks` must be explicit
When using `sessionReplaySampleRate` (instead of the removed `replaySampleRate` or `premiumSampleRate`), resources and long tasks are no longer collected by default. Enable them explicitly — **unless** the v4 config already set them to `false` intentionally:
```js
DD_RUM.init({
sessionReplaySampleRate: 100,
trackResources: true, // omit if v4 explicitly had trackResources: false
trackLongTasks: true, // omit if v4 explicitly had trackLongTasks: false
})
```
Search: `grep -rn 'sessionReplaySampleRate\|startSessionReplayRecording\|defaultPrivacyLevel\|trackResources\|trackLongTasks' --include="*.js" --include="*.ts" --include="*.tsx" --include="*.jsx" --include="*.html" --include="*.vue" --include="*.svelte"`
Also search for all RUM init calls to catch projects that omit these options and rely on v4 defaults: `grep -rn 'DD_RUM\.init\|datadogRum\.init' --include="*.js" --include="*.ts" --include="*.tsx" --include="*.jsx" --include="*.html" --include="*.vue" --include="*.svelte"`. For each init call, verify that `sessionReplaySampleRate`, `defaultPrivacyLevel`, and `trackResources`/`trackLongTasks` are explicitly set.
## Step 5: Update changed APIs and behaviors
### 5a. `beforeSend` must return a boolean
`beforeSend` callback functions should return `true` to keep the event or `false` to discard it. If no value is returned, the event is kept. This resolves TypeScript compilation errors.
```js
beforeSend: (event, context) => {
// return true to keep, false to discard
return true
}
```
### 5b. `beforeSend` action context: `context.event` → `context.events`
With frustration signals, an action event can be associated with multiple DOM events. `context.event` is replaced by `context.events` (array).
```js
// v4
beforeSend: (event, context) => {
if (event.type === 'action') {
const domEvent = context.event
}
}
// v5
beforeSend: (event, context) => {
if (event.type === 'action') {
const domEvents = context.events // array
}
}
```
### 5c. `beforeSend` performance entry is now a `PerformanceEntry` object
The `performanceEntry` in `beforeSend` context is now the raw `PerformanceEntry` object, not a JSON representation. The `PerformanceEntryRepresentation` type has been removed.
### 5d. `startTime` removed from XHR `beforeSend` context
The `context.startTime` property has been removed from XHR resource `beforeSend` context. Use the `performanceEntry` instead.
### 5e. `view.in_foreground_periods` removed from `beforeSend`
This attribute is now computed by the backend. Remove any `beforeSend` code that accesses `view.in_foreground_periods`.
### 5f. Frustration signals collected automatically
Set `trackUserInteractions: true` to collect all user interactions, including frustration signals. The `trackFrustrations` parameter is no longer needed.
### 5g. Resource method names are uppercase
Resource `method` field is now always uppercase (e.g., `GET`, `POST`). Update any dashboards or monitors filtering on `resource.method`.
### 5h. `session.plan` field removed
The `session.plan` field (`lite`/`premium`) is removed in v5 and not emitted on any event type. Replace any dashboard or monitor filter on `session.plan` with the new replay fields:
- `@session.sampled_for_replay:true` — session was sampled for Session Replay
- `@session.has_replay:true` — session has an actual replay recording
Search: `grep -rn 'beforeSend\|trackFrustrations\|PerformanceEntryRepresentation\|in_foreground_periods\|context\.event\b\|startTime' --include="*.js" --include="*.ts" --include="*.tsx" --include="*.jsx" --include="*.html" --include="*.vue" --include="*.svelte"`
## Step 6: Handle trusted events
v5 only listens to user-generated (trusted) events. Script-generated events are ignored by default.
If you rely on programmatic events (e.g., `dispatchEvent`), add the `__ddIsTrusted` attribute:
```js
// JavaScript
const click = new Event('click')
click.__ddIsTrusted = true
document.dispatchEvent(click)
```
```ts
// TypeScript
const click = new Event('click') as Event & { __ddIsTrusted?: boolean }
click.__ddIsTrusted = true
document.dispatchEvent(click)
```
Or allow all untrusted events globally:
```js
DD_RUM.init({
allowUntrustedEvents: true,
})
```
Search: `grep -rn 'dispatchEvent\|new Event\|new MouseEvent\|new KeyboardEvent\|\.click()' --include="*.js" --include="*.ts" --include="*.tsx" --include="*.jsx" --include="*.html" --include="*.vue" --include="*.svelte"`
## Step 7: Update infrastructure
### CSP `connect-src` domains changed
v5 sends data to new intake domains. Update your Content Security Policy:
| Datadog site | New `connect-src` domain |
| ------------ | ------------------------------------------ |
| US1 | `https://browser-intake-datadoghq.com` |
| US3 | `https://browser-intake-us3-datadoghq.com` |
| US5 | `https://browser-intake-us5-datadoghq.com` |
| EU1 | `https://browser-intake-datadoghq.eu` |
| US1-FED | `https://browser-intake-ddog-gov.com` |
| US2-FED | `https://browser-intake-us2-ddog-gov.com` |
| AP1 | `https://browser-intake-ap1-datadoghq.com` |
### CORS headers for distributed tracing
v5 adds `tracecontext` as a default propagator. If you use `allowedTracingUrls`, your server must accept the `traceparent` header. Add it to your existing `Access-Control-Allow-Headers` — do not replace the full list:
```
# Add traceparent alongside your existing headers
Access-Control-Allow-Headers: <existing-headers>, traceparent
```
### Logs: `error.origin` removed
Update dashboards/monitors using `error.origin` to use `origin` instead.
### Logs: console error prefix removed
The `"console error:"` prefix is removed from log messages. Update queries using this prefix to use `@origin:console` instead.
### Logs: main logger decoupled
Runtime errors, network logs, report logs, and console logs no longer inherit the main logger's context, level, or handler. Use global context and dedicated init parameters instead.
Search for main logger configuration that may have been relying on this inheritance: `grep -rn 'DD_LOGS\.logger\.setLevel\|DD_LOGS\.logger\.setHandler\|DD_LOGS\.logger\.setContext\|DD_LOGS\.logger\.setContextProperty' --include="*.js" --include="*.ts" --include="*.tsx" --include="*.jsx" --include="*.html" --include="*.vue" --include="*.svelte"`. For each match, verify the setting is intentional for the main logger only — it will no longer affect runtime errors, network logs, or console logs.
## Common Mistakes
| Mistake | What goes wrong | Fix |
| -------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| Setting `sessionReplaySampleRate > 0` without enabling `trackResources` and `trackLongTasks` | Resources and long tasks are silently not collected — they no longer default to `true` when using `sessionReplaySampleRate` | Always add `trackResources: true, trackLongTasks: true` alongside any non-zero `sessionReplaySampleRate` |
| Using `context.event` instead of `context.events` in `beforeSend` for action events | Action context property renamed — `context.event` is `undefined`, DOM event details are lost | Update to `context.events` (array); iterate if you need all associated DOM events |
| Not updating CSP `connect-src` to the new v5 intake domains | SDK silently fails to send data — old intake domains are no longer valid | Update `connect-src` to the v5 intake domain for your site (see Step 7) |
## Verification checklist
After upgrading, confirm:
- [ ] SDK loads without console errors
- [ ] No references to removed init parameters (`proxyUrl`, `sampleRate`, `replaySampleRate`, etc.)
- [ ] No references to removed APIs (`addRumGlobalContext`, `removeUser`, etc.)
- [ ] `beforeSend` callbacks return boolean values
- [ ] `beforeSend` action handlers use `context.events` (not `context.event`)
- [ ] `trackResources` and `trackLongTasks` explicitly set if using `sessionReplaySampleRate`
- [ ] Session Replay recording works (if `sessionReplaySampleRate` > 0)
- [ ] Distributed tracing working (no CORS errors from `traceparent` header)
- [ ] CSP `connect-src` updated to new intake domains
- [ ] Dashboards/monitors updated for uppercase `resource.method`
- [ ] No queries using `error.origin` (use `origin` instead)
From datadog-labs/agent-skills at 9cbd518, shown as plain text under its license: MIT (permissive). The license text is in LICENSE.
View SKILL.md on GitHub at 9cbd518Files
- SKILL.md15 KB · ae031571304f
1 file, 15 KB in total. Each file has a sha256 in the pin's manifest; the first 12 characters are shown.
Skill folder on GitHub at 9cbd518More from Datadog
dd-code-generation
This skill enables agents to interact with Datadog through the pup CLI tool for immediate queries and operations, or generate code for integrating Datadog…
Claude Code, Codex, Cursor +3 · about 4.3K tokens · pinned 6 days ago
dd-file-issue
This skill helps file GitHub issues to the DataDog/pup repository for bugs, feature requests, and documentation problems related to the pup CLI, agents, and…
Claude Code, Codex, Cursor +3 · about 2.2K tokens · pinned 6 days ago
dd-idp
Queries Datadog's Unified Entity Graph to find and connect software services, teams, infrastructure, dependencies, and operational context through read-only…
Claude Code, Codex, Cursor +4 · about 1.8K tokens · pinned 6 days ago
dd-logs
This skill enables agents to search, process, and archive Datadog logs using the pup command-line tool.
Claude Code, Codex, Cursor +4 · about 1.2K tokens · pinned 6 days ago
agent-observability-auto-experiment
Runs a local hill-climb optimization loop to improve code or prompts against real Datadog LLM-Obs evaluation data.
Contains scripts
Claude Code · about 28.4K tokens · pinned 6 days ago
agent-observability-build-eval-from-annotations
Fits an LLM evaluator to human-labeled data by iteratively scoring a judge against the labels, reading its errors, making targeted improvements, and…
Contains scripts
Claude Code, Codex, Cursor +3 · about 12.1K tokens · pinned 6 days ago
Related in Observability
agent-observability-online-experiment
This skill guides users through setting up online A/B tests for LLM applications using Datadog's Agent Observability and feature flags.
by DatadogOfficial publisher
Claude Code, Codex, Cursor +4 · about 5.9K tokens · pinned 6 days ago
agent-observability-replay-trace
Replay a single production trace against local code changes to test fixes iteratively.
by DatadogOfficial publisher
Contains scripts
Claude Code · about 3.4K tokens · pinned 6 days ago
agent-observability-session-classify
Classifies whether a user's intent was satisfied in a Datadog Agent Observability trace or session by analyzing conversation content, tool outcomes, and…
by DatadogOfficial publisher
Claude Code, Codex, Cursor +4 · about 15.7K tokens · pinned 6 days ago
agent-skills
This skill package provides Datadog observability tools for AI agents, including monitoring, logging, tracing, APM, and cloud integrations through the pup CLI.
by DatadogOfficial publisher
Claude Code, Codex, Cursor +4 · about 910 tokens · pinned 6 days ago
dd-account-setup
Ensures a user has a valid Datadog API key and application key on the correct region before running any Datadog instrumentation.
by DatadogOfficial publisher
Claude Code, Codex, Cursor +4 · about 4.3K tokens · pinned 6 days ago
dd-apm
This skill enables agents to set up Datadog APM for distributed tracing and performance analysis.
by DatadogOfficial publisher
Claude Code · about 1.8K tokens · pinned 6 days ago