Documentation
    Preparing search index...

    Module @datadog/browser-logs

    Datadog Browser Logs SDK for collecting and forwarding browser logs to Datadog. Provides comprehensive logging capabilities with automatic error tracking and custom log collection.

    Browser Log Collection

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

    API

    LogsGlobal

    Configuration

    LogsInitConfiguration

    Other

    Logger
    Account
    ConsoleLogsEventDomainContext
    Context
    InitConfiguration
    InternalContext
    LoggerConfiguration
    LoggerLogsEventDomainContext
    LogsEvent
    LogsMessage
    NetworkLogsEventDomainContext
    PublicApi
    User
    ConsoleApiName
    ConsoleApiName
    ContextValue
    ErrorSource
    ErrorSource
    HandlerType
    LogsEventDomainContext
    MatchOption
    ProxyFn
    RawReportType
    RawReportType
    SessionPersistence
    Site
    StatusType
    TraceContextInjection
    TraceContextInjection
    TrackingConsent
    TrackingConsent
    datadogLogs
    HandlerType
    StatusType