Cutting error tracking costs

Last updated:

|Edit this page|

We aim to be significantly cheaper than our competitors. In addition to our pay-as-you-go pricing, below are tips to reduce your error tracking costs:

Configure exception autocapture

By default, we capture all unhandled errors and rejections. This can capture more than you need. To reduce which exceptions that are captured, you can configure which types of exceptions are autocaptured in the JS SDK config like this:

JSON
{
"capture_exceptions": {
"capture_unhandled_errors": true,
"capture_unhandled_rejections": true,
"capture_console_errors": false
}
}

Alternatively, you can disable exception autocapture completely in your project settings.

Filtering exceptions clientside

Suppression rules

Autocaptured exceptions can be ignored client-side by configuring suppression rules. Because the stack of an exception may still be minified client-side, you can only filter based on the exception type and message attributes.

Issue suppression rules

Burst protection

The JavaScript web SDK uses burst protection to limit the number of autocaptured exceptions that can be captured in a period. This prevents an excessive amount of exceptions being captured from any one client, typically because they're being thrown in an infinite loop.

By default, we capture 10 exceptions (bucket size) of the same type within a 10 second period before the rate limiter kicks in, after which, we capture 1 exception (refill rate) every 10 seconds.

Often not needed, but you can change the bucket size and refill rate as part of your configuration:

JavaScript
import posthog from 'posthog-js'
posthog.init('<ph_project_api_key>', {
api_host: 'https://us.i.posthog.com',
error_tracking: {
__exceptionRateLimiterRefillRate: 1
__exceptionRateLimiterBucketSize: 10
}
})

Using the before_send hook

You can use the before_send callback in the web and Node.js SDKs to exclude any exception events you do not wish to capture. Do this by providing a before_send function when initializing PostHog and have it return a falsey value for any events you want to drop.

JavaScript
posthog.init('<ph_project_api_key>', {
before_send: (event) => {
if (event.event === "$exception") {
const exceptionList = event.properties["$exception_list"] || []
const exception = exceptionList.length > 0 ? exceptionList[0] : null;
if (exception && exception["$exception_type"] === "UnwantedError") {
return false
}
}
return event
}
})

Issue suppression

If the unwanted exceptions are being grouped under the same issue, you can suppress them so that subsequent exception events are not ingested. Issues can be suppressed from the list or issue page by changing their status to Suppressed.

Issue suppression status

Quota limiting

Like all PostHog products, you can set a billing limit for error tracking. When a project exceeds this limit, PostHog will no longer capture exception events until your billing period resets.

Questions? Ask Max AI.

It's easier than reading through 718 pages of documentation

Community questions

Was this page useful?

Next article

Tutorials and guides

Got a question which isn't answered below? Head to the community forum to let us know! Framework guides How to set up Python (and Flask) error tracking How to set up Next.js error monitoring How to set up React error tracking

Read next article