
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
@datadog/browser-rum
Advanced tools
The @datadog/browser-rum package is a Real User Monitoring (RUM) solution provided by Datadog. It allows developers to collect and analyze performance and user behavior data from their web applications in real-time. This data can be used to identify and troubleshoot issues, improve user experience, and monitor application performance.
Real User Monitoring
Initializes the RUM SDK to start collecting data from the user's browser, including session replay recording.
import { datadogRum } from '@datadog/browser-rum';
datadogRum.init({
applicationId: 'YOUR_APPLICATION_ID',
clientToken: 'YOUR_CLIENT_TOKEN',
site: 'datadoghq.com',
service:'your-service-name',
// Specify a version number to identify the deployed version of your application in Datadog
version: '1.0.0',
sampleRate: 100,
trackInteractions: true,
});
datadogRum.startSessionReplayRecording();
Custom User Actions
Records custom user actions, such as button clicks, with additional context.
datadogRum.addAction('button_click', { buttonId: 'my-button' });
Logging Errors
Logs errors manually with additional context to help with debugging.
datadogRum.addError(new Error('Something went wrong'), {
context: {
productId: 123
}
});
User Tracking
Sets user information to track user-specific data and associate it with the collected RUM data.
datadogRum.setUser({
id: '1234',
name: 'John Doe',
email: 'john.doe@example.com',
// User-defined attributes
plan_type: 'premium',
});
Raygun4js is a JavaScript SDK for Raygun, providing error tracking and real user monitoring. It captures errors and performance data from the browser, offering a feature set that competes with @datadog/browser-rum, with a focus on error diagnosis and resolution.
Datadog Real User Monitoring (RUM) enables you to visualize and analyze the real-time performance and user journeys of your application's individual users.
To set up Datadog RUM browser monitoring:
clientToken
and an applicationId
for your application.Note: Your application shows up on the application list page as "pending" until Datadog starts receiving data.
Supported browsers: The RUM SDK supports all modern desktop and mobile browsers including IE11. See the browser support table.
npm (node package manager) : This method is recommended for modern web applications. The RUM SDK gets packaged with the rest of your front-end javascript code. It has no impact on page load performance. However, the SDK might miss errors, resources and user actions triggered before the SDK is initialized. Note: it is recommended to use a matching version with logs SDK if used.
CDN async : This method is recommended for web applications with performance targets. The RUM SDK is loaded from our CDN asynchronously: this method ensures the SDK download does not impact page load performance. However, the SDK might miss errors, resources and user actions triggered before the SDK is initialized.
CDN sync : This method is recommended for collecting all RUM events. The RUM SDK is loaded from our CDN synchronously: this method ensures the SDK is loaded first and collects all errors, resources and user actions. This method might impact page load performance.
Add @datadog/browser-rum
to your package.json
file, then initialize it with:
import { datadogRum } from '@datadog/browser-rum'
datadogRum.init({
applicationId: '<DATADOG_APPLICATION_ID>',
clientToken: '<DATADOG_CLIENT_TOKEN>',
site: '<DATADOG_SITE>',
// service: 'my-web-application',
// env: 'production',
// version: '1.0.0',
sampleRate: 100,
trackInteractions: true,
})
Note: The trackInteractions
parameter enables the automatic collection of user clicks in your application. Sensitive and private data contained on your pages may be included to identify the elements interacted with.
Add the generated code snippet to the head tag of every HTML page you want to monitor in your application.
<script>
(function(h,o,u,n,d) {
h=h[d]=h[d]||{q:[],onReady:function(c){h.q.push(c)}}
d=o.createElement(u);d.async=1;d.src=n
n=o.getElementsByTagName(u)[0];n.parentNode.insertBefore(d,n)
})(window,document,'script','https://www.datadoghq-browser-agent.com/datadog-rum.js','DD_RUM')
DD_RUM.onReady(function() {
DD_RUM.init({
clientToken: '<CLIENT_TOKEN>',
applicationId: '<APPLICATION_ID>',
site: '<DATADOG_SITE>',
// service: 'my-web-application',
// env: 'production',
// version: '1.0.0',
sampleRate: 100,
trackInteractions: true,
})
})
</script>
Notes:
trackInteractions
parameter enables the automatic collection of user clicks in your application. Sensitive and private data contained on your pages may be included to identify the elements interacted with.DD_RUM.onReady()
callback. This ensures the code only gets executed once the SDK is properly loaded.Add the generated code snippet to the head tag (in front of any other script tags) of every HTML page you want to monitor in your application. Including the script tag higher and synchronized ensures Datadog RUM can collect all performance data and errors.
<script src="https://www.datadoghq-browser-agent.com/datadog-rum.js" type="text/javascript"></script>
<script>
window.DD_RUM &&
window.DD_RUM.init({
clientToken: '<CLIENT_TOKEN>',
applicationId: '<APPLICATION_ID>',
site: '<DATADOG_SITE>',
// service: 'my-web-application',
// env: 'production',
// version: '1.0.0',
sampleRate: 100,
trackInteractions: true,
})
</script>
Notes:
trackInteractions
parameter enables the automatic collection of user clicks in your application. Sensitive and private data contained on your pages may be included to identify the elements interacted with.window.DD_RUM
check is used to prevent issues if a loading failure occurs with the RUM SDK.Types are compatible with TypeScript >= 3.0. For earlier versions, import JS sources and use global variables to avoid any compilation issues:
import '@datadog/browser-rum/bundle/datadog-rum'
window.DD_RUM.init({
applicationId: 'XXX',
clientToken: 'XXX',
site: 'datadoghq.com',
sampleRate: 100,
})
The following parameters are available:
applicationId
: Required
Type: String
The RUM application ID.
clientToken
: Required
Type: String
A Datadog client token.
site
: Required
Type: String
Default: datadoghq.com
The Datadog site of your organization. US: datadoghq.com
, EU: datadoghq.eu
service
: Optional
Type: String
The service name for your application.
env
: Optional
Type: String
The applicationās environment, for example: prod, pre-prod, staging, etc.
version
: Optional
Type: String
The applicationās version, for example: 1.2.3, 6c44da20, 2020.02.13, etc.
trackInteractions
: Optional
Type: Boolean
Default: false
Enables automatic collection of users actions.
sampleRate
: Optional
Type: Number
Default: 100
The percentage of sessions to track: 100
for all, 0
for none. Only tracked sessions send rum events.
silentMultipleInit
: Optional
Type: Boolean
Default: false
Initialization fails silently if Datadog's RUM is already initialized on the page.
proxyHost
: Optional
Type: String
Optional proxy host (ex: www.proxy.com), see the full proxy setup guide for more information.
allowedTracingOrigins
: Optional
Type: List
A list of request origins used to inject tracing headers.
Options that must have matching configuration when also using logs
SDK:
trackSessionAcrossSubdomains
: Optional
Type: Boolean
Default: false
Preserve the session across subdomains for the same site.
useSecureSessionCookie
: Optional
Type: Boolean
Default: false
Use a secure session cookie. This disables RUM events sent on insecure (non-HTTPS) connections.
useCrossSiteSessionCookie
: Optional
Type: Boolean
Default:false
Use a secure cross-site session cookie. This allows the RUM SDK to run when the site is loaded from another one (iframe). Implies useSecureSessionCookie
.
Init must be called to start the tracking:
init(configuration: {
applicationId: string,
clientToken: string,
site?: string,
sampleRate?: number,
silentMultipleInit?: boolean,
trackInteractions?: boolean,
service?: string,
env?: string,
version?: string,
allowedTracingOrigins?: Array<String|Regexp>,
trackSessionAcrossSubdomains?: boolean,
useSecureSessionCookie?: boolean,
useCrossSiteSessionCookie?: boolean,
})
v2.11.1
FAQs
Unknown package
The npm package @datadog/browser-rum receives a total of 1,511,159 weekly downloads. As such, @datadog/browser-rum popularity was classified as popular.
We found that @datadog/browser-rum demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Ā It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezerās API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.