npm.io
1.4.0 • Published 3d ago

@kubesense/kubesense-browser-logs

Licence
Apache-2.0
Version
1.4.0
Deps
1
Size
348 kB
Vulns
0
Weekly
0

Kubesense Browser Logs

Send logs to Kubesense from your browser pages. The Logs SDK forwards console errors and uncaught exceptions, and lets you send your own structured log entries with severity levels and custom context.

It can run standalone or alongside @kubesense/kubesense-browser-rum — when both are present, logs are automatically correlated with the active RUM session and view.

Installation

npm install @kubesense/kubesense-browser-logs
# or
yarn add @kubesense/kubesense-browser-logs

Usage

Initialize the SDK as early as possible in your application's lifecycle:

import { kubesenseLogs } from '@kubesense/kubesense-browser-logs'

kubesenseLogs.init({
  clientToken: '<KUBESENSE_CLIENT_TOKEN>',
  kubesenseRumEndpoint: '<KUBESENSE_RUM_ENDPOINT>',
  forwardErrorsToLogs: true,
  sessionSampleRate: 100,
})
Sending logs
import { kubesenseLogs } from '@kubesense/kubesense-browser-logs'

kubesenseLogs.logger.info('Button clicked', { name: 'buttonName', id: 123 })

try {
  throw new Error('Wrong behavior')
} catch (error) {
  kubesenseLogs.logger.error('Error occurred', { team: 'myTeam' }, error)
}

The logger exposes debug, info, warn, and error methods. Each accepts a message, an optional context object, and an optional Error.

Documentation

See the dedicated Kubesense documentation for configuration options, custom loggers, and log filtering.

License

Apache-2.0

Keywords