Integrations / Platforms / Supabase

โšก

Supabase

Log events from Supabase Edge Functions or trigger LogIt from Supabase database webhooks when rows are inserted.


Option 1: Edge Function

bash
supabase functions new log-event
ts
// supabase/functions/log-event/index.ts
import { serve } from "https://deno.land/std@0.208.0/http/server.ts";

serve(async (req) => {
  const { email, plan } = await req.json() as { email: string; plan: string };

  await fetch("https://api.logit.now/api/ingest", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      Authorization: `Bearer ${Deno.env.get("LOGIT_API_KEY")}`,
    },
    body: JSON.stringify({
      channel: "signups",
      event: "New user signed up",
      description: `${email} joined on ${plan}`,
      icon: "๐Ÿ‘ค",
      notify: true,
      tags: { plan },
      metadata: { email },
    }),
  });

  return new Response(JSON.stringify({ ok: true }), {
    headers: { "Content-Type": "application/json" },
  });
});
bash
supabase secrets set LOGIT_API_KEY=lk_live_xxxxxxxxxxxxxxxx
supabase functions deploy log-event

Option 2: Database Webhook (no code)

Supabase can fire an HTTP request when a row is inserted in a table.

  1. Go to Database โ†’ Webhooks โ†’ Create a new hook
  2. Set the table to users and event to INSERT
  3. Set the HTTP URL to https://api.logit.now/api/ingest
  4. Add header: Authorization: Bearer lk_live_xxxxxxxxxxxxxxxx
  5. Set the body to:
json
{
  "channel": "signups",
  "event": "New user row inserted",
  "icon": "๐Ÿ‘ค",
  "notify": true
}

Tip: The database webhook body is static JSON. For dynamic content (email, plan), use an Edge Function instead.

Ready to connect Supabase?

7-day free trial. No credit card required.

Start free