Skip to main content
Use @squasher-ai/node for Express, Fastify, Hono, Bun, workers, and plain scripts.

Install

Initialize early

Call init() before you import code that might throw.
src/index.ts
For long-running services, install process-level handlers and close the client during shutdown:
The SDK batches buffered events and automatically splits multi-event request bodies at 1 MB. The configured event-count and flush-interval thresholds still determine when a flush starts; the byte limit only keeps a single outbound request bounded.

Wrap request handlers

Use withHttpRequest when you want request metadata attached automatically if the handler throws:

Capture framework errors

Manual capture

Actionable error context

Squasher AI triage works best when errors include a short explanation and a next step. For Node services, send that context as structured attributes on telemetry events: Keep these values safe to store with remote project telemetry. Put private implementation notes in your own development workflow rather than public-facing docs or customer-visible messages. For reusable application errors, create the context once and let captureError merge it into the event:
internal is hidden from the error’s normal JSON representation, but it is still sent to Squasher as event extra. Only include values that are safe for retained project telemetry.

Local debug artifacts

Enable localEventSink when you want a coding agent or local debug script to inspect the exact events the SDK prepared after beforeSend.
The sink writes redacted NDJSON files named YYYY-MM-DD.jsonl. Treat them as temporary debugging output for agents and humans. They complement Squasher’s remote observability, but they are not the production source of truth and should not be used for alerting, retention, or incident history.

Agent handoff