step() and the SDK automatically fires running, success, and error events to Failpath — no manual try/catch bookkeeping required. You keep full control over your business logic; the SDK handles the telemetry.
Installation
Quick start
The following example covers the full lifecycle: creating a client, starting a run, and instrumenting two steps inside a checkout handler.step() call queues a running event before your function executes, then queues success or error when it completes. Telemetry sends in the background by default, so instrumentation does not add network latency to your request path. Call failpath.flush() before a short-lived process exits, or at the end of a serverless request when your runtime does not provide a waitUntil hook.
If the wrapped function throws, the SDK records the error and rethrows the original exception so your application error handling remains intact.
Feature highlights
TypeScript-first
Full type declarations are included in the package, and
.failpath/sdk.ts gives you typed flow slugs and step keys.Background telemetry
Telemetry sends run in the background by default. Use
flush() or a runtime waitUntil hook when you need deterministic delivery.Automatic error capture
When a wrapped step throws, the SDK records the error event and rethrows the original error — no extra try/catch required.
Skip support
Use
run.skip() to mark a step as intentionally skipped, keeping your flow trace complete even when a branch is not taken.Rich metadata
Attach arbitrary metadata at the client, run, or step level. Client-level
defaultMetadata is merged into every event automatically.Custom fetch
Supply your own
fetch implementation for runtimes that lack a native one, such as older Node.js versions or edge environments.Test helper
Import
createMockFailpathClient() from @failpath/sdk/testing to capture events in automated tests without network calls.Explore the SDK
Client
Configure the typed or base client with your project key, metadata defaults, and error handling options.
Typed Keys
Generate
.failpath/sdk.ts and use autocomplete for flow slugs and step keys.Runs & Steps
Learn how to start a run, instrument steps, skip branches, and record events manually.
Testing
Use the mock client to assert emitted events in unit and integration tests.
Options
Full reference for every configuration option across the client, run, step, and
recordStep APIs.