@datadog/browser-logs
TypeScript icon, indicating that this package has built-in type declarations

6.5.1 • Public • Published

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

Dependencies (1)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i @datadog/browser-logs

    Weekly Downloads

    1,156,523

    Version

    6.5.1

    License

    Apache-2.0

    Unpacked Size

    348 kB

    Total Files

    186

    Last publish

    Collaborators

    • datadog