Chapter 03
Issue grouping
PostHog groups exceptions into issues by their code. Sometimes exceptions that look different in code have the same cause.
When a stay's host record is missing, Trip details and the stay page both throw a HostNotFoundError, from readTripHost and StayPageView. PostHog puts these exceptions in two issues Fig. 1.
HostNotFoundError
Host "colette" not found for booking booking_3
readTripHost in src/trips/trip-details.ts
Active · Unassigned
HostNotFoundError
Host "colette" not found for stay stay-03
StayPageView in src/stays/StayPageView.tsx
Active · Unassigned
How PostHog groups
PostHog decides how to group exceptions into issues by going through these rules, in order:
- A custom fingerprint set in source code. If that's not set:
- A grouping rule in PostHog. If that's not set:
- A default fingerprint PostHog generates.
Default generated fingerprints
PostHog generates the fingerprint from the exception type and Twig's frames in the stack trace, or from the message if there's no stack trace.
Both exceptions are a HostNotFoundError, but one throws in readTripHost and the other in StayPageView Fig. 2. Different frames make different fingerprints, so PostHog puts them in two issues.
HostNotFoundError
Host "colette" not found for booking booking_3
HostNotFoundError
Host "colette" not found for stay stay-03
When a source map is absent, PostHog groups by the first in-app frame in the minified code instead. Each deploy can minify that frame differently, so the same bug can land in a new issue after every deploy.
Custom grouping
The engineers want every HostNotFoundError in one issue, wherever Twig throws it. They add a grouping rule in Error Tracking settings that matches the exception type Fig. 3.
Matching exceptions will be grouped as a single issue.
1,442 exceptions across 2 issues would have been grouped into one issue in the last 7 days
The rule only applies to new exceptions, so the engineers also select the two existing issues in the issue list and click Merge.
Custom fingerprinting
The grouping rule puts every HostNotFoundError in one issue. The engineers want one issue per missing host instead, because each host record needs its own fix.
With grouping rules, every host needs its own rule. Twig's code already knows which host is missing, so it's easier to put the host in the fingerprint there Fig. 4.
posthog.captureException(error, { surface: context.surface, stay_id: context.stayId, $exception_fingerprint: `host-not-found:${error.hostId}`,})A custom fingerprint wins over the grouping rule. Each missing host now gets its own issue, whether Trip details or the stay page finds it. Like grouping rules, custom fingerprints only apply to new exceptions.
Misgrouped issues
As Twig grows and the team changes, the engineers keep adjusting how they group issues.
When issues are misgrouped, Twig's engineers debug like this:
We turned this into a skill for you to debug your misgrouped issues Fig. 5.





