Logs and errors
Sending Custom Logs
import { CoralogixRum, CoralogixLogSeverity } from '@coralogix/browser';
// send custom logs with different severity levels
CoralogixRum.log(CoralogixLogSeverity.Info, 'this is a custom log');
// send custom logs with extra data
CoralogixRum.log(CoralogixLogSeverity.Error, 'this is an error custom log with extra data', { data: 'tbd' });
// send custom logs with extra data, call the error severity log directly
CoralogixRum.error('this is a custom log with error severity', { data: 'tbd' });
// send custom logs with extra data and labels
CoralogixRum.warning(
'this is a custom log message with warning severity',
{
data: 'tbd',
},
{
my_label_key: 'my label value',
}
);
// data is optional unless labels are provided, in which case data is required (can be null
CoralogixRum.log(CoralogixLogSeverity.Info, 'this is a custom log message with info severity', null, {
my_label_key: 'my label value',
});
Instrumentation's
Turn on/off specific instrumentation, default to all trues. Each instrumentation is responsible for which data the SDK will track and collect for you.
CoralogixRum.init({
// ...
instrumentations: {
xhr: true,
fetch: true,
web_vitals: false,
interactions: false,
custom: true,
errors: true,
long_tasks: true,
resources: false,
},
});
Web Vitals: TBT metric
By default, the TBT (Total Blocking Time) metric is disabled. To enable it, explicitly configure it as shown below:
{
"instrumentations": {
"web_vitals": {
"enabled": true,
"metrics": {
"tbt": true
}
}
}
}
Manually Capture Errors
You can pass an Error object to capture it as an event.
Additionally, you can include custom data and labels with the event.
try {
// Some code that might throw an error
} catch (error) {
CoralogixRum.captureError(error);
CoralogixRum.captureError(error, { custom_data: { id: '123' } }); // add custom data
CoralogixRum.captureError(error, { custom_data: { id: '123' } }, { label1: 'value1' }); // add custom data and labels
}
Last updated on