Upgrade the Browser SDK to V3

Upgrade the Browser SDK to V3

Overview

Browser SDK v3 introduces Session Replay. With this major version update, several breaking changes were made to RUM and logs Browser SDKs.

Changes

RUM errors

The RUM Browser SDK no longer issues RUM errors for failed XHR and Fetch calls. These failed network requests are still collected as RUM resources, which contain the status code attribute.

To continue seeing the failed network requests as RUM errors, Datadog recommends intercepting the resource with the beforeSend API, checking the status_code property, and manually sending an error with the addError API.

beforeSend: (event) => {
    if (event.type === 'resource' && event.resource.status_code >= 500) {
        datadogRum.addError(`${event.resource.method} ${event.resource.url} ${event.resource.status_code}`); // "GET https://www.example.com/ 504"
    }
}

RUM error source attribute

The RUM Browser SDK no longer lets you specify the source of an error collected with the addError API. All errors collected with this API have their source attribute set to custom. The addError API accepts a context object as its second parameter, which should be used to pass extra context about the error.

Removals

RUM API

Old APINew API
addUserActionaddAction

Initialization options

Old optionsNew options
publicApiKeyclientToken
datacentersite
resourceSampleRateNONE

TypeScript types

Old typesNew types
RumUserConfigurationRumInitConfiguration
RumRecorderUserConfigurationRumRecorderInitConfiguration
LogsUserConfigurationLogsInitConfiguration

Further Reading