Get the init configuration
RumInitConfiguration | undefined
Init the RUM browser SDK.
See RUM Browser Monitoring Setup for further information.
Configuration options of the SDK
Set the tracking consent of the current user.
Data will be sent only if it is set to "granted". This value won't be stored by the library
across page loads: you will need to call this method or set the appropriate trackingConsent
field in the init() method at each page load.
If this method is called before the init() method, the provided value will take precedence over the one provided as initialization parameter.
See User tracking consent for further information.
The user tracking consent
Add a custom action, stored in @action
See Send RUM Custom Actions for further information.
Name of the action
Optionalcontext: objectContext of the action
Add a custom error, stored in @error.
See Send RUM Custom Actions for further information.
Error. Favor sending a Javascript Error to have a stack trace attached to the error event.
Optionalcontext: objectContext of the error
Add a feature flag evaluation,
stored in @feature_flags.<feature_flag_key>
We recommend enabling the intake request compression when using feature flags compressIntakeRequests: true.
See Feature Flag Tracking for further information.
The key of the feature flag.
The value of the feature flag.
Add a custom timing relative to the start of the current view,
stored in @view.custom_timings.<timing_name>
Note: passing a relative time is discouraged since it is actually used as-is but displayed relative to the view start. We currently don't provide a way to retrieve the view start time, so it can be challenging to provide a timing relative to the view start. see https://github.com/DataDog/browser-sdk/issues/2552
Name of the custom timing
Optionaltime: numberEpoch timestamp of the custom timing (if not set, will use current time)
[Experimental] Manually set the current view's loading time.
Call this method when the view has finished loading. The loading time is computed as the elapsed time since the view started. Each call replaces any previously set value (last-call-wins).
Start tracking a custom action.
Call stopAction with the same name (and optional actionKey) to send a RUM action event
with the elapsed duration. Errors and resources triggered between start and stop are associated
with the action.
Name of the action
Optionaloptions: ActionOptionsOptions of the action (@default type: 'custom')
Start tracking a resource manually.
Use this for network activity that the SDK cannot automatically instrument. Call stopResource
with the same URL (and optional resourceKey) to send a RUM resource event with the elapsed duration.
URL of the resource
Optionaloptions: ResourceOptionsOptions of the resource (@default type: 'other')
Stop tracking a custom action started with startAction.
Sends a RUM action event with the elapsed duration since the matching start call. Context from start and stop calls is merged into the event.
Name of the action
Optionaloptions: ActionOptionsOptions of the action
Stop tracking a resource started with startResource.
Sends a RUM resource event with the elapsed duration since the matching start call. Context from start and stop calls is merged into the event.
URL of the resource
Optionaloptions: ResourceStopOptionsOptions of the resource
Start a view manually.
Enable to manual start a view, use trackViewsManually: true init parameter and call startView() to create RUM views and be aligned with how you’ve defined them in your SPA application routing.
See Override default RUM view names for further information.
Context -
OptionalnameOrOptions: string | ViewOptionsThe view name, or a ViewOptions object to configure the view
Get the Session Replay Link.
See Connect Session Replay To Your Third-Party Tools for further information.
Start Session Replay recording.
Enable to conditionally start the recording, use the startSessionReplayRecordingManually:true init parameter and call startSessionReplayRecording()
See Browser Session Replay for further information.
Stop Session Replay recording.
See Browser Session Replay for further information.
Clear all account information
Clear all account information
Get account information
Remove an account property
Key of the property to remove
Set account information to all events, stored in @account
Set or update the account property, stored in @account.<key>
Key of the property
Value of the property
Get the global Context
See Global context for further information.
Remove a global context property
See Global context for further information.
Set the global context information to all events, stored in @context
See Global context for further information.
Set or update a global context property, stored in @context.<key>
See Global context for further information.
Key of the property
Value of the property
Clear the global context
See Global context for further information.
Clear all user information
See User session for further information.
Get user information
See User session for further information.
Remove a user property
Key of the property to remove
User session for further information.
Set or update the user property, stored in @usr.<key>
See User session for further information.
Key of the property
Value of the property
Set user information to all events, stored in @usr
See User session for further information.
User information
Set View Context.
Enable to manually set the context of the current view.
Set View Context Property.
Enable to manually set a property of the context of the current view.
key of the property
value of the property
Set View Name.
Enable to manually change the name of the current view. See Override default RUM view names for further information.
Name of the view
Get View Context.
Stop the session. A new session will start at the next user interaction with the page.
Add a custom duration vital
Name of the custom vital
Options for the custom vital (startTime, duration, context, description)
Start a custom duration vital.
If you plan to have multiple durations for the same vital, use the vitalKey option to
differentiate them. Provide the same key when calling stopDurationVital.
Name of the custom vital
Optionaloptions: DurationVitalOptionsOptions for the custom vital (vitalKey, context, description)
// Simple usage
datadogRum.startDurationVital('my-vital')
datadogRum.stopDurationVital('my-vital')
// Multiple simultaneous vitals with the same name
const key = crypto.randomUUID()
datadogRum.startDurationVital('my-vital', { vitalKey: key })
datadogRum.stopDurationVital('my-vital', { vitalKey: key })
Stop a custom duration vital
Name of the custom vital
Optionaloptions: DurationVitalOptionsOptions for the custom vital (vitalKey, context, description)
Mark a feature operation as failed.
Name of the operation
Reason for the failure
Optionaloptions: OperationOptionsOptions for the operation (operationKey, context, description)
Use failOperation instead.
Start a feature operation.
Name of the operation
Optionaloptions: OperationOptionsOptions for the operation (operationKey, context, description)
Use startOperation instead.
Mark a feature operation as successful.
Name of the operation
Optionaloptions: OperationOptionsOptions for the operation (operationKey, context, description)
Use succeedOperation instead.
Mark an operation as failed.
Sends a RUM vital event marking the end of the operation started with startOperation.
Name of the operation
Reason for the failure
Optionaloptions: OperationOptionsOptions for the operation (operationKey, context, description)
Start an operation.
Call succeedOperation or failOperation with the same name (and optional
operationKey) to send a RUM vital event marking the end of the operation.
Name of the operation
Optionaloptions: OperationOptionsOptions for the operation (operationKey, context, description)
Mark an operation as successful.
Sends a RUM vital event marking the end of the operation started with startOperation.
Name of the operation
Optionaloptions: OperationOptionsOptions for the operation (operationKey, context, description)
List of default headers used by the trackResourceHeaders option. See configuration example for extending them.
For CDN async setup: Early RUM API calls must be wrapped in the window.DD_RUM.onReady() callback. This ensures the code only gets executed once the SDK is properly loaded.
See CDN async setup for further information.
Version of the Logs browser SDK
Public API for the RUM browser SDK.
See RUM Browser Monitoring Setup for further information.