Skip to content

Filtering events

View Markdown

You can ignore events programmatically using the beforeEvent callback. This callback is called before an event is sent to Honeybadger. If the callback returns false, the event will not be sent.

For example, you can ignore events based on the event type:

$honeybadger->beforeEvent(function (&$event) {
if ($event['event_type'] === 'user_activity' && $event['action'] === 'registration') {
return false;
}
});

Or, you may modify the event data before it is sent:

$honeybadger->beforeEvent(function (&$event) {
$event['user_id'] = 456;
});

Note: You can register multiple beforeEvent callbacks. If any of them return false, the event will not be sent.

If you’d rather reduce event volume across the board instead of ignoring specific events, see Sampling events.