---
title: Filtering events
description: Ignore or modify events before they're sent from your JavaScript application to Honeybadger Insights.
url: https://docs.honeybadger.io/lib/javascript/insights/filtering-events/
---

You can ignore or modify events programmatically using `Honeybadger.beforeEvent`. Handlers run before an event is sent to Honeybadger. If a handler returns `false` (or a promise that resolves to `false`), the event will not be sent.

Handlers may be synchronous or asynchronous. They receive the fully assembled event payload (including merged event context) and may mutate it in place.

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

```javascript
Honeybadger.beforeEvent((event) => {
  if (event.event_type === "request.handled" && event.path === "/health") {
    return false;
  }
});
```

Or modify the event data before it is sent:

```javascript
Honeybadger.beforeEvent((event) => {
  event.user_id = 456;
});
```

Async handlers are supported:

```javascript
Honeybadger.beforeEvent(async (event) => {
  event.region = await lookupRegion();
});
```

**Note**: You can register multiple `beforeEvent` handlers. They run in registration order. If any of them return `false`, the event will not be sent. A handler that throws is logged and skipped; remaining handlers still run.

## Sampling events

If you’d rather reduce event volume across the board instead of ignoring specific events, see [Sampling events](https://docs.honeybadger.io/lib/javascript/insights/sampling-events/).

---

## Try Honeybadger for FREE

Intelligent logging, error tracking, and Just Enough APM™ in one dev-friendly platform. Find and fix problems before users notice.

[Start free trial](https://app.honeybadger.io/users/sign_up)

[See plans and pricing](https://www.honeybadger.io/plans/)
