@squasher-ai/node for Express, Fastify, Hono, Bun, workers, and plain scripts.
Install
Initialize early
Callinit() before you import code that might throw.
src/index.ts
Use a standalone client
init() sets the optional process-wide client used by the package-level helpers. Use
SquasherClient directly when you need explicit ownership, isolated tests, or more than one client
in the same process:
SquasherClient do not use the process-wide client. Package-level helpers such as
captureError() and close() continue to use the client created by init(). flush() and
close() wait for queued events and any active batch request that the batch-size threshold started.
Check local delivery health
ReadgetDeliveryStats() when a health endpoint, shutdown check, or local debug tool needs to know
whether the SDK can deliver events:
Wrap request handlers
UsewithHttpRequest to emit one correlated completion event for successful and failed requests:
Wrap AWS Lambda handlers
UsewithAwsLambda to capture handler failures and flush queued events before the invocation ends:
src/handler.ts
Capture framework errors
- Express
- Fastify
- Hono
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.
Supported release line:
@squasher-ai/node 0.4.x and the companion JavaScript SDKs at 0.3.x. Do not install earlier 0.x artifacts.
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
EnablelocalEventSink when you want a coding agent or local debug script to inspect the exact events the SDK prepared after beforeSend.
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
Related guides
- Use Pino transport or Winston transport for structured logs.
- Use source maps to improve stack trace quality.
- Use AI triage to turn rich error context into root-cause summaries.
- Use Design Queryable Logs for operation event fields and sampling.