Documentation
Supabase guide
When an order row is inserted, post the payment to AnalyticFast with the visitor id you stored on that row. Point a Database Webhook at an Edge Function, not at AnalyticFast. Supabase sends its own envelope (type, table, schema, record, old_record). That envelope is not an AnalyticFast payment body.
Store the website visitor id on the order before insert (a visitor_id column, or your own metadata jsonb). Store the charged amount as integer minor units if you can. Column names below are yours; Supabase does not define an orders table.
Create the function and put the token in Edge Function secrets (ANALYTICFAST_TOKEN, ANALYTICFAST_BASE_URL, ANALYTICFAST_SITE_ID). Do not put the token in the webhook URL. Copy packages/node/src/index.ts to supabase/functions/_shared/analyticfast.ts (it is not published and has no dependencies).
// supabase/functions/analyticfast-order/index.ts
import { createClient } from '../_shared/analyticfast.ts';
Deno.serve(async (req) => {
const payload = await req.json();
if (payload?.type !== 'INSERT' || !payload.record) return Response.json({ ignored: true });
const row = payload.record as { id?: string; visitor_id?: string | null; amount_minor?: number; currency?: string | null };
if (!row.id || !Number.isInteger(row.amount_minor) || !row.currency) return Response.json({ ignored: true });
const analytics = createClient({
token: Deno.env.get('ANALYTICFAST_TOKEN') ?? '',
baseUrl: Deno.env.get('ANALYTICFAST_BASE_URL') ?? '',
siteId: Deno.env.get('ANALYTICFAST_SITE_ID') || undefined,
});
const result = await analytics.payment({
transactionId: String(row.id),
amountMinor: row.amount_minor,
currency: row.currency,
visitorId: row.visitor_id || undefined,
});
return Response.json(result);
});
In the Supabase Dashboard, create a Database Webhook on INSERT for your orders table, choose Supabase Edge Functions, and select this function. If the row stores a major-unit price instead, convert it with the same minor-unit exponent you charged (USD and EUR use 2, so 29.99 becomes 2999; yen uses 0) before amountMinor. Do not send a decimal amount. The order id is the idempotency key: webhook retries stay one payment. A missing visitor id still records the payment, unattributed.
Official references, checked 2026-10-26: Database Webhooks, Edge Functions, secrets.
Questions, answered.
How do I use supabase with AnalyticFast?
Follow the Supabase instructions on this page using your own website’s Site ID and configuration. Verify a real event before relying on the reports.
Where can I get setup help?
Contact support@analyticfast.com with the website domain and a redacted description. Do not send API tokens, signing secrets or personal customer data.