You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

@datadog/browser-logs

Package Overview
Dependencies
Maintainers
0
Versions
249
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@datadog/browser-logs

Send logs to Datadog from web browser pages with the browser logs SDK.


Version published
Weekly downloads
741K
decreased by-17.72%
Maintainers
0
Install size
1.40 MB
Created
Weekly downloads
 

Package description

What is @datadog/browser-logs?

@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.

What are @datadog/browser-logs's main functionalities?

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' });

Other packages similar to @datadog/browser-logs

Changelog

Source

v5.22.0

  • ✨⚗️ [RUM-4469] introduce a plugin system (#2809)
  • ✨ [RUM-4014] DD_LOGS: add handling stack in beforeSend context (#2786)
  • ✨ [RUM-3902] Add privacy control for action names (#2707)
  • 🐛 Fix developer extension crashing when dev mode enabled (#2810)
  • 🔮 [HADXVI-53] Browser SDK extension search bar improvement (#2771)
  • ⚡️ [RUM-3570] Batch the records for 16ms minimum before processing them (#2807)
  • Use the same service/version type in init() and startView() (#2798)
  • ⚗️ [RUM-4780] Remote configuration (#2799)

Readme

Source

Browser Log Collection

Send logs to Datadog from web browser pages with the browser logs SDK.

See the dedicated datadog documentation for more details.

Usage

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)
}

FAQs

Package last updated on 01 Jul 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc