Skip to content

Sending custom events

View Markdown

You can send your own application events to Honeybadger Insights with Honeybadger’s PHP (v2.19+) and Laravel (v4.1+) packages. (For the events the Laravel package captures on its own, see Automatic instrumentation; to forward application logs, see Capturing logs.)

Start by configuring Honeybadger and enabling events:

$honeybadger = Honeybadger\Honeybadger::new([
'api_key' => 'my-api-key',
'events' => [
'enabled' => true
]
]);

Then you can send events using the $honeybadger->event method:

$honeybadger->event('user_activity', [
'action' => 'registration',
'user_id' => 123
])

The first argument is the type of the event (event_type) and the second argument is an object containing any additional data you want to include.

$honeybadger->event can also be called with a single argument as an object containing the data for the event:

$honeybadger->event([
'event_type' => 'user_activity',
'action' => 'registration',
'user_id' => 123
])

A timestamp field (ts) will be automatically added to the event data if it is not provided, regardless of the method used to send the event.

These events may be found using the following BadgerQL query:

fields @ts, @preview
| filter event_type::str == "user_activity"
| filter action::str == "registration"
| sort @ts

If some events are noisy or you’d like to reduce quota consumption: