tracabit
v1.0.0
Published
Tracabit — GA4-style privacy-first analytics SDK + Sentry-style crash reporting. Multi-provider geo race, passive fingerprint, standard event helpers. Zero runtime deps. Works in browsers and Node 18+.
Maintainers
Readme
+ tracabitWhy Tracabit exists Google Analytics 4 is 45–100KB, cookie-laden, and shows your data to Google. Plausible is privacy-first but you can't query it from code. Sentry is crash-only, and MCP-coupled agent analytics doesn't exist yet. Tracabit unifies all three: a 2.6KB tracker, GA4-event-compatible JSON API, Sentry-style crash capture, and a contract any AI agent can read — with no inference cost, no cookies, no third-party trackers.
Install
npm install tracabit
# or: pnpm add tracabit · yarn add tracabit · bun add tracabit60-second quick start
import { createClient } from "tracabit";
const tcb = createClient({
apiKey: "tcb_live_...",
projectId: "tcb_proj_...",
endpoint: "https://your-host/analytics",
});
// Fire a page view — runs in <1ms, never blocks the page
tcb.pageView();
// GA4-style product analytics
tcb.addToCart({ item_id: "SKU-1001", item_name: "Pro Plan", price: 99, quantity: 1 });
tcb.purchase("T-2026-0842", 149.97, "EUR", [
{ item_id: "SKU-1001", item_name: "Pro Plan", price: 149.97, quantity: 1 },
]);
// Capture a crash — links to the live session timeline
tcb.captureException(new Error("checkout failed"), { fatal: true });That's the entire API surface for createClient. No SDK bloat — just events you actually fire.
Browser script tag (1 line, no build step)
<script src="https://tracabit.com/tracabit.js" data-key="tcb_live_..."></script>
<script>
window.tracabit.track("page_view");
window.tracabit.purchase("T-1", 49.99, "USD");
</script>Auto-fires page_view on load. Auto-tracks elements with data-track="event_name". Includes the passive fingerprint, multi-provider geo resolution, and scroll-depth milestones.
Why developers switch to Tracabit
| | Tracabit | GA4 | Plausible | PostHog | Sentry | | :--- | :---: | :---: | :---: | :---: | :---: | | Tracker size (gzipped) | ~1 KB | ~22 KB | ~1 KB | ~12 KB | — | | Zero cookies (GDPR-native) | ✓ | ✗ | ✓ | ✓ | n/a | | GA4 standard event helpers | ✓ | ✓ | ✗ | partial | ✗ | | Crash reporting built-in | ✓ | ✗ | ✗ | ✓ | ✓ | | Inference-free core | ✓ | ✓ | ✓ | ✗ | n/a | | Self-host in your VPC | ✓ | ✗ | partial | partial | ✗ | | Queryable via AI agents (HTTP/JSON) | ✓ | partial | ✗ | via MCP | ✗ | | Runtime dependencies | 0 | vendor lock | 0 | 0 | heavy SDK |
7.6 KB compressed. Zero runtime dependencies. Works in Node 18+ and every modern browser. Tree-shakeable. Side-effect-free.
The full event surface
Every method on createClient() mirrors the GA4 reference:
tcb.pageView(url?, title?)
tcb.search(term)
tcb.viewItem(item) tcb.viewItemList(items)
tcb.addToCart(item) tcb.viewCart(items?) tcb.removeFromCart(item)
tcb.beginCheckout(value, currency?, items?)
tcb.addPaymentInfo(paymentType?, value?, currency?)
tcb.purchase(transactionId, value, currency?, items?)
tcb.refund(transactionId, value?, currency?)
tcb.generateLead(value, currency?)
tcb.formStart(formId) tcb.formSubmit(formId)
tcb.fileDownload(extension, name, linkUrl?)
tcb.share(method, contentId)
tcb.viewPromotion(id, name) tcb.selectPromotion(id, name)
tcb.viewSearchResults(term, count?)
tcb.track(eventName, params?) // generic — fire any GA4 event
tcb.captureException(err, extra) // Sentry-style crash captureCrash reports — Sentry-grade, with session context
Every crash is routed to the same event stream as your product analytics — so a purchase failure shows up next to the user's session_id, fingerprint, and ad source that brought them in. No second SDK, no separate bill.
import { captureException, getErrors } from "tracabit";
// Auto-capture (browser)
window.addEventListener("error", (e) =>
captureException("tcb_live_...", e.error || e.message, { projectId: "tcb_proj_..." })
);
// Read stored reports (server-side)
const errs = await getErrors("tcb_live_...", { fatalOnly: true, limit: 50 });Privacy-first, by architecture
┌─────────────────┐ POST /analytics ┌──────────────────┐
│ Browser SDK │ ── sendBeacon ──► │ Tracabit Crude Engine │
│ (1 KB, 0 deps) │ ⇆ no cookies ⇆ │ (your VPC) │
│ │ no third-party JS │ │
└─────────────────┘ └────────┬─────────┘
▲ passive djb2 fingerprint parity-resolved
▲ sessionStorage session Geo-IP (CDN header
▲ 5-provider Geo race (cached 30m) or 5-provider race)
▲ auto scroll milestones + [data-track]- No cookies. Anonymous
sessionStoragesession IDs. - No PII leaked. Fingerprint is a passive djb2 hash over UA / language / screen / timezone / TZ — no identifiers.
- No third-party JS. The geo race hits OneTrust / Cloudflare / ipapi.co only when an edge CDN header isn't available.
- Self-host by default. Deploy the engine inside your VPC — your data never leaves your infrastructure.
Rich context — automatic, per event
Every beacons carries these automatically — no configuration, no schema:
| Field | Source |
|---|---|
| sessionId | sessionStorage (tcb_session), backed by in-memory fallback |
| userId | localStorage (tcb_uid) via setUserId() |
| country, region, city | Server CF-IPCountry / X-Vercel-IP-Country if available — else 5-provider client race cached 30m |
| fingerprint | Passive djb2 hash, stable per-session |
| language, screen, platform | navigator (browser only) |
| pageTitle | document.title (browser only) |
| referrer | document.referrer (validated against project allowlist) |
Runtime requirements
- Node 18+ — for native
fetch,AbortController,crypto. - Modern browsers — ES2020 (Chrome 80+, Firefox 75+, Safari 14+, Edge 80+).
No external runtime dependencies. The npm package contains only the compiled/minified bundles and type declarations.
Transport
- Browsers:
navigator.sendBeacon→fetch({ keepalive: true })fallback. - Node: native
fetch. - Always fire-and-forget — never blocks the page or the request handler.
Backward-compatible report() API
import { report } from "tracabit";
await report("tcb_live_...", "page_view", {
projectId: "tcb_proj_...",
endpoint: "https://your-host/analytics",
event: "page_view",
eventParams: { page_title: "Landing" },
});Community & resources
- Documentation — tracabit.com/docs
- Self-host guide — one-command VPC deploy
- Issue tracker — github.com/tracabit/tracabit/issues
- Changelog — releases
- License — MIT — ship it, fork it, sell it.
Tracabit — analytics that respects your users and improve your margins.
If your team ships product analytics, crash reports, or AI-agent data pipelines — Tracabit was written for you. Star the repo, file issues, and reach out. We build in public.
