Errors deduplicated into fingerprinted groups, developer logs in a pluggable
store, a superadmin dashboard on top — all persisted in your own database.
@spfn/monitor wires in through defineServerConfig() and one
package router, and notifies Slack by group state, not by event count.
A production error shouldn't vanish into a log stream. This package
persists it: error groups, individual events, and developer logs land as rows in the
spfn_monitor Postgres schema of the database you already run — queryable
through six superadmin API routes, rendered by ready-made React components. Integration
is three points on defineServerConfig() — an onError middleware,
a lifecycle, and monitorRouter mounted with .packages([...]), so
its /_monitor/admin/* routes are served but stay out of your app's client types.
Every tracked error is fingerprinted — SHA-256 over name, message,
and path, cut to 16 hex chars. Same triple, same group. Slack then follows the group's
state, not the event count: a new fingerprint creates a group and posts once; while the
group is active or ignored, further occurrences only increment
the count and record an event; mark it resolved, and the next occurrence
reopens the group and posts again. The concrete property: the channel carries one message
per new or reopened problem, while every single occurrence is still on record in the DB.
And if Slack or the event write fails, the failure is caught and logged — it never breaks
the response.
createMonitorErrorHandler — an onError drop-in that tracks every error at or above minStatusCode.
SHA-256(name:message:path), first 16 hex chars — same triple, same group.
active, resolved, ignored — resolve a group and a recurrence reopens it.
writeLog and queryLogs — five levels, debug through fatal, filterable.
setLogStore swaps the DB store for any LogStore backend, process-wide.
Six /_monitor/admin/* routes — every one gated by the superadmin role.
monitorApi — createApi over the monitor router, stats to status updates.
MonitorDashboard plus four building blocks — Tailwind, dark-mode aware.