Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@datadog/browser-logs
Advanced tools
@datadog/browser-logs is an npm package that allows you to collect and monitor logs from your web applications in real-time. It integrates with Datadog's logging service to provide comprehensive insights into your application's performance, errors, and user interactions.
Basic Logging
This feature allows you to initialize the Datadog logging client and send basic log messages. The `init` method configures the client with your Datadog client token and other settings, while the `logger.info` method sends an informational log message.
const { datadogLogs } = require('@datadog/browser-logs');
datadogLogs.init({
clientToken: 'YOUR_CLIENT_TOKEN',
site: 'datadoghq.com',
forwardErrorsToLogs: true,
sampleRate: 100,
});
datadogLogs.logger.info('This is an info log');
Error Logging
This feature allows you to log errors that occur in your application. By catching exceptions and using the `logger.error` method, you can send detailed error logs to Datadog.
try {
throw new Error('Something went wrong');
} catch (error) {
datadogLogs.logger.error('An error occurred', { error });
}
Custom Attributes
This feature allows you to add custom attributes to your log messages. By passing an object with additional data to the logging methods, you can enrich your logs with context-specific information.
datadogLogs.logger.info('User action', { userId: '12345', action: 'click' });
LogRocket is a front-end logging and session replay tool that helps you understand issues affecting your users. It provides similar logging capabilities as @datadog/browser-logs but also includes session replay, which allows you to see exactly what the user did leading up to an issue.
Loggly is a cloud-based log management service. The `loggly-jslogger` package allows you to send logs from your web applications to Loggly. It provides similar logging capabilities as @datadog/browser-logs but integrates with Loggly's log management and analysis platform.
Send logs to Datadog from web browser pages with the browser logs SDK.
See the dedicated datadog documentation for more details.
After adding @datadog/browser-logs
to your package.json
file, initialize it with:
import { datadogLogs } from '@datadog/browser-logs'
datadogLogs.init({
clientToken: '<DATADOG_CLIENT_TOKEN>',
site: '<DATADOG_SITE>',
forwardErrorsToLogs: true,
sessionSampleRate: 100,
})
After the Datadog browser logs SDK is initialized, send custom log entries directly to Datadog:
import { datadogLogs } from '@datadog/browser-logs'
datadogLogs.logger.info('Button clicked', { name: 'buttonName', id: 123 })
try {
...
throw new Error('Wrong behavior')
...
} catch (ex) {
datadogLogs.logger.error('Error occurred', { team: 'myTeam' }, ex)
}
v5.34.1
Public Changes:
Internal Changes:
FAQs
Unknown package
The npm package @datadog/browser-logs receives a total of 347,985 weekly downloads. As such, @datadog/browser-logs popularity was classified as popular.
We found that @datadog/browser-logs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.