The saasboost SDK.
Two lines of TypeScript to attribute every signup, trial, and paid conversion back to the seller who sent the visitor. 2KB minified, zero dependencies, never throws.
One line.
npm install saasboostCapture the click.
Drop this on every page. It reads the ?ref= query string, persists it for 60 days, and stamps every conversion call automatically.
import saasboost from 'saasboost'
// One-line init. Do this once at the root of your app.
saasboost.init('lk_live_xxxx')
// Fire when real money moves. `amount` is in DOLLARS, not cents.
saasboost.conversion({
amount: 49,
email: 'jane@stripe.com',
})Fire the conversion.
Call this from your billing webhook (Stripe or Paddle) when a trial becomes paid. Pass the seller's slug as refId — that's how the conversion finds its way to the right person.
import { SaaSBoostServer } from 'saasboost/server'
const sb = new SaaSBoostServer(process.env.SAASBOOST_KEY, {
throwOnError: true, // surface failures so your webhook retries
})
// Inside your billing webhook handler:
await sb.conversion({
refId: order.metadata.saasboost_ref, // the slug — NOT 'ref'
amount: order.amount_total / 100, // Stripe sends cents → divide
currency: order.currency,
email: order.customer_email,
})Three ways your events disappear.
The SDK never throws by design — so if you misconfigure it, calls silently 404. Get these right or nothing lands on the seller dashboard.
`apiBase` is the host root — no /api/v1.
The SDK appends the API path itself. Set apiBase to http://localhost:3333 in dev, not http://localhost:3333/api/v1. A wrong base posts to a 404 and the SDK swallows the error so your signup form never breaks.
`amount` is in dollars, not cents.
Pass 49 for a $49 conversion. Passing 4900 books a $4,900 conversion with a 100× commission. If your billing provider sends cents (such as Stripe), divide by 100 before passing it in.
Server SDK: the field is `refId`, not `ref`.
Both the SDK type and the backend validator expect refId. Sending ref is silently dropped and the conversion lands unattributed — invisible on the seller dashboard.
What we won't do.
Never throws
All failures are swallowed by default. Your signup form will never break because of us.
No PII collected
We only see referral IDs, amounts, and optional emails. No name, no IP, no fingerprint.
Offline-friendly
Click events use keepalive fetch so they survive page unload — no retry queue needed.
GDPR-friendly
No third-party cookies. Referral data lives in localStorage scoped to your domain.