// NODE.JS, NO SDK

Send a custom metric from Node.js

A ten-line helper with the built-in fetch: a counter and a gauge over plain HTTPS. EzStat creates the stat on the first call, draws the chart, and exports CSV or JSON on request. No agent, no collector, no package.

Free: 10 stats, 300,000 datapoints a month, no card, open to the first 250 accounts. Paid plans are $19, $49 or $99 a month, and every paid plan tracks 10,000 stats. Prices are flat and monthly, in USD, + tax where applicable. /pricing is the source of truth. Alerts on paid plans, by webhook or Slack, checked periodically — not instant.

Before you start

Create an account and copy your API key (shown once) into EZSTAT_API_KEY. The key works at once, with one stat and 500 datapoints a day until you confirm your email address; confirm within 7 days to keep sending. The examples below write more than one stat, so confirm before you run them all. Use Node 18 or later for global fetch.

Record a counter or a gauge

const API = "https://api.ezstat.dev/api/v1/stats";

async function track(stat, kind, body) {
  const res = await fetch(`${API}/${encodeURIComponent(stat)}/${kind}`, {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.EZSTAT_API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify(body),
    signal: AbortSignal.timeout(5000),
  });
  if (!res.ok) throw new Error(`EzStat rejected the point: HTTP ${res.status}`);
}

await track("signups", "count", { count: 1 });
await track("checkout_ms", "value", { value: 142 });

A counter is a running total; a gauge is a measurement at a moment in time. A stat is one or the other, never both, so stay with /count or /value for each stat.

Never fail a request over a metric

// track() is the helper above.
// Do not let a metrics hiccup fail a request: log it and move on.
track("signups", "count", { count: 1 }).catch((err) =>
  console.error("ezstat:", err.message)
);

No await on the request path, a five-second timeout, and one log line if it fails. The user's request is never waiting on your telemetry.

What a failure means

res.ok === false is a real rejection — 401 bad key, 403 plan limit on stats or datapoints, 429 rate limited (or the starting limit before you confirm your email), 400 malformed input — and the point was not stored. A thrown fetch or a timeout means the outcome is unknown. Retry only with the same explicit timestamp and ikey:

// Retry-safe: the same timestamp + ikey on every attempt for one logical event.
await track("orders", "count", {
  count: 1,
  timestamp: "2026-12-03T09:15:00Z",
  ikey: "order-9831",
});

De-duplication keys on stat + timestamp + ikey; an ikey without a timestamp does not protect you. Rules: /docs#replay-semantics.

From a browser?

Keep it server-side. Cross-origin posting is documented for the StatHat-compatible endpoints rather than the v1 routes used here, and a key that ships to a browser is public: anyone can read it and write to your stats. If you must, use a key you can rotate.

Price and limits

Free: 10 stats, 300,000 datapoints a month, no card, open to the first 250 accounts. Paid plans are $19, $49 or $99 a month and every paid plan tracks 10,000 stats; the history you can see and export is 30 days on Free and Indie, 1 year on Pro, 3 years on Scale. A stat is one named metric. See the full table.

Other languages

The same two calls in Python, Go and curl. If an agent runs the job, it can record the same numbers through MCP: /ai-agent-metrics. Weighing this against a full observability suite? /datadog-alternative compares the two honestly.

Questions

How do I send a custom metric from Node.js?

Use fetch to POST JSON: fetch("https://api.ezstat.dev/api/v1/stats/signups/count", { method: "POST", headers: { Authorization: "Bearer " + process.env.EZSTAT_API_KEY, "Content-Type": "application/json" }, body: JSON.stringify({ count: 1 }) }). Use /count for a counter and /value with { value: 142 } for a gauge. A response with res.ok and {"status":"ok"} means the point was stored. Keep the key in an environment variable.

How do I stop a metrics call from failing my Node.js request?

Do not await it on the request path. Call the helper without await, attach a .catch that logs the error, and give the fetch a timeout with AbortSignal.timeout(5000). A failed metric then costs one log line, not a failed request. A thrown error or a timeout means the outcome is unknown, so retry only with a fixed timestamp and idempotency key.

Does the EzStat API need an SDK in Node.js?

No. It is plain HTTPS with a Bearer token and JSON, so the built-in fetch in Node 18 or later is enough. There is no agent, collector or package to install. The stat is created by its first write and appears on a chart.

Can I send metrics from browser JavaScript?

The examples here are server-side. Cross-origin posting is documented for the StatHat-compatible endpoints, not for the v1 routes, and any key you ship to a browser is public — treat it as compromised and rotate it if it is abused. Prefer sending from your server.

What does a failed write look like?

On the v1 routes it is a real HTTP error: 401 for a bad key, 403 for a plan limit on stats or datapoints, 429 for rate limiting (or for the starting limit before you confirm your email), 400 for malformed input. Check res.ok.