firetower
v0.5.0
Published
Reports the errors and failed calls a Firetower fix needs, and nothing else.
Maintainers
Readme
firetower
Reports the two things a fix can be written from: an error that was thrown, and a call to somebody else's service that failed.
import { init } from "firetower";
init({
key: "pk_live_...", // from the Firetower dashboard, not a secret
release: process.env.GIT_SHA,
environment: "production",
});That is the whole setup. It hooks uncaught errors, unhandled rejections, and
fetch, and sends a batch every ten seconds.
Or one script tag
For a page rather than a server:
<script src="https://api.firetower.sh/t.js?key=pk_live_..." async></script>Same tracker, same wire format. data-environment, data-release,
data-runtime and data-hosts="api.stripe.com,api.twilio.com" on the tag map to the options
above, and the tracker is on window.firetower for capture(err). The tag
sees the calls the browser makes. Calls your server makes need the package.
Where it runs
One package, everywhere: a server, a page, a worker, an edge function, a mobile app. Each copy works out where it is and says so with every batch, so the dashboard can show server failures and browser failures apart. An app that runs in two places loads the SDK in both, and each copy reports its own.
| Detected as | When |
|---|---|
| server | Node, Bun or Deno |
| web | a browser page |
| worker | a service worker or web worker |
| edge | Cloudflare Workers, Vercel Edge |
| mobile | React Native |
Set it yourself when you know better, or to use your own name:
init({ key: "pk_live_...", runtime: "ios" });<script src="https://api.firetower.sh/t.js?key=pk_live_..." data-runtime="web" async></script>runtime is where the code runs. environment is still which deployment it
is (production, staging). One app is in production on a server and in a
browser at the same time.
What it sends
Per problem, not per occurrence: one bad line throwing forty thousand times is one report with a count of forty thousand.
- the error name, message and parsed stack frames
- which frame is your code and which is a dependency
- for a failed call: the host, the path with ids removed, the method, the status, and how long it took
- for a failed call to a provider you use (OpenAI, Azure OpenAI, Anthropic,
Google, Bedrock, and any host Firetower found in your repo): the
provider's error type, code and parameter name, its message cut to 300
characters, the model you asked for, and the names of the parameters you
sent. The message is the provider's own text and can quote part of what
you sent;
beforeSendcan deletee.providerore.provider.messageif that matters to you. - for calls to those same hosts: how many succeeded and failed per hour, as counters, so the dashboard can show an error rate
What it does not send
No request bodies beyond the model string and the parameter names, no
parameter values, no headers, no full URLs, no user identifiers, no session
trail, no per-call records of successful calls. Path segments that look
like ids are replaced before the event leaves your process, so
/v1/charges/ch_3Nk... becomes /v1/charges/:id on your machine rather
than on ours.
If you want to strip something else, beforeSend gets the last look and
returning null drops the event.
init({
key: "pk_live_...",
beforeSend: (e) => (e.message.includes("internal") ? null : e),
});What it will not do to your application
- Never throws into your code. Every entry point is wrapped and a failure inside the SDK is swallowed.
- Never retries a failed send. A collector that is down must not become your outage.
- Never holds your process open: the flush timer is unref'd.
close()restores thefetchit replaced, and only if nothing else wrapped it afterwards.
Options
| | |
|---|---|
| key | project ingest key, required |
| release | git sha, so a fix lands on the right commit |
| environment | defaults to production |
| hosts | only report failures from these hosts; empty means all. Provider hosts are always inspected. |
| hostsUrl | where to learn your repo's hosts; "" skips the lookup |
| flushMs | send interval, default 10000 |
| maxBatch | distinct problems per flush, default 50 |
| beforeSend | last look before an event leaves the process |
| endpoint | override the collector |
Upgrading from 0.1.0
Failures on provider hosts now fingerprint on the model and the error code, not just the call site. If you had an open problem on OpenAI, Anthropic, Google, Azure OpenAI, or Bedrock from before the upgrade, it stops receiving new occurrences and a new one appears beside it. The old row is not lost; it just ages out of the window on its own.
