@openobserve/browser-logs
v0.2.11
Published
Send logs to openobserve from web browser pages with the browser logs SDK.
Downloads
9,576
Readme
Browser Log Collection
Send logs to openobserve from web browser pages with the browser logs SDK.
See the dedicated openobserve documentation for more details.
Usage
After adding @openobserve/browser-logs
to your package.json
file, initialize it with:
import { openobserveLogs } from '@openobserve/browser-logs'
openobserveLogs.init({
clientToken: '<OPENOBSERVE_CLIENT_TOKEN>',
site: '<OPENOBSERVE_SITE>',
forwardErrorsToLogs: true,
sessionSampleRate: 100,
})
After the openobserve browser logs SDK is initialized, send custom log entries directly to openobserve:
import { openobserveLogs } from '@openobserve/browser-logs'
openobserveLogs.logger.info('Button clicked', { name: 'buttonName', id: 123 })
try {
...
throw new Error('Wrong behavior')
...
} catch (ex) {
openobserveLogs.logger.error('Error occurred', { team: 'myTeam' }, ex)
}