Enhance & manage browser RUM data with beforeSend
Enable event access and modification before sending data to Coralogix using beforeSend. This feature allows you to modify content or discard events as needed.
Overview
The beforeSend callback method can be configured to filter error events just before they are sent to the server. This method provides a final opportunity to decide whether to send or modify the data. The beforeSend function receives the event object as a parameter, allowing you to use custom logic to either alter the event’s data or discard it entirely by returning null.
Usage
Here is an example demonstrating how to use beforeSend:
CoralogixRum.init({
// ...
beforeSend: (event) => {
// Discard events from @company.com users.
if (event.session_context.user_email?.endsWith('@company.com')) {
return null;
}
// Redact sensitive information from the page URL.
event.page_context.page_url = event.page_context.page_url.replace(
'sensitive-info',
'redacted'
);
return event;
},
});
Notes:
To retain the event, you must
return event.To discard the event, return
null.
Theme
Light