Write events to Supabase Analytics Buckets
Supabase Analytics Buckets store Iceberg tables and require an ingestion pipeline. Send JSON events from your server or Edge Functions, or export OTLP from your services. Send2Bucket appends the records to your Analytics Bucket.
Analytics Buckets are in private alpha at Supabase; request access through the form linked from Supabase's Create an analytics bucket page first.
1. Create the bucket, a namespace and keys
- In the Supabase dashboard, open Storage, create a bucket and choose Analytics Bucket. Note its name.
- Under the Storage settings, create S3 access keys.
- From the bucket's connection details, copy the catalog token. Supabase's instructions use the service role key, so keep it on the server.
- Create a namespace for Send2Bucket's table. With PyIceberg:
from pyiceberg.catalog import load_catalog
catalog = load_catalog(
"supabase",
type="rest",
uri="https://<project_ref>.supabase.co/storage/v1/iceberg",
warehouse="<analytics_bucket>",
token="<catalog_token>",
)
catalog.create_namespace("s2b")
print(catalog.list_namespaces())
2. Add the destination
In the Send2Bucket dashboard, create an ingestion stream and add a Supabase Analytics Buckets destination with the project ref, the bucket name as warehouse, the project's region, the namespace s2b, a table name such as events, the catalog token and the S3 keys. Select Verify: Send2Bucket creates the table with four columns, signal_type, delivery_batch_id, ingested_at and payload. Supabase Analytics Buckets lists every field.
3. Send events from your app
Call this from server code: an Edge Function, an API route or a background job. The Send2Bucket key must not reach the browser, just like your service role key.
// Server-side only: the API key must never reach a browser.
export async function track(apiKey, event, properties = {}) {
const res = await fetch('https://api.send2bucket.com/v1/events', {
method: 'POST',
headers: {authorization: `Bearer ${apiKey}`, 'content-type': 'application/json'},
body: JSON.stringify({event, ...properties, sent_at: new Date().toISOString()}),
});
if (!res.ok) throw new Error(`Send2Bucket ${res.status}: ${await res.text()}`);
return res.json();
}
{ bytes: 114, accepted: 1 }
In an Edge Function, store the key with supabase secrets set S2B_API_KEY=s2b_ingest_... and pass Deno.env.get('S2B_API_KEY'). A 200 means the event is stored durably; a 429 means the request would take the organization past its plan's allowance, and the body says when it resets.
Services that emit OpenTelemetry can export to the same stream; see the S3 guide for the variables. Logs, spans and metrics then sit in the same table as your events, told apart by signal_type.
4. Query from Postgres
In the Supabase dashboard, open the Analytics Bucket, select Query with Postgres on the s2b namespace and name a schema such as s2b_lake. Supabase installs the Iceberg wrapper and creates a foreign table for events. Then, from the SQL editor:
SELECT signal_type, count(*) AS records
FROM s2b_lake.events
GROUP BY signal_type;
With Wrappers 0.6.3, some WHERE filters on the foreign table returned no rows when rows matched. To join events with your own tables, load new batches into a regular table on a schedule, as Iceberg tables and Analytics Buckets with the Iceberg wrapper shows, and query that.
Or query with DuckDB
DuckDB reads the bucket directly through its catalog, from your laptop, a notebook or a job:
INSTALL httpfs; LOAD httpfs; INSTALL iceberg; LOAD iceberg;
CREATE SECRET s2b_storage (
TYPE s3, KEY_ID '<access_key_id>', SECRET '<secret_access_key>', REGION '<region>',
ENDPOINT '<project_ref>.supabase.co/storage/v1/s3', URL_STYLE 'path');
CREATE SECRET s2b_catalog (TYPE iceberg, TOKEN '<catalog_token>');
ATTACH '<analytics_bucket>' AS lakehouse (
TYPE iceberg, ENDPOINT 'https://<project_ref>.supabase.co/storage/v1/iceberg', SECRET s2b_catalog);
SELECT payload::JSON->>'$.data.event' AS event,
count(*) AS events,
count(DISTINCT payload::JSON->>'$.data.user_id') AS users
FROM lakehouse.s2b.events
WHERE signal_type = 'event'
GROUP BY ALL
ORDER BY events DESC;
Python with PyIceberg, Apache Spark, Trino and ClickHouse read the same table.
Limits and costs
- A request can be up to 8 MiB decompressed; a single event has no separate limit.
- Send2Bucket bills the stored JSON of each record it accepts (Plans and billing). Supabase bills the bucket's storage under your project.
- Each delivery batch is one Iceberg snapshot, about 1,440 a day on a busy stream. Check Supabase's Analytics Buckets limits for your project.
- A client retry after a lost response is stored again; include your own event ID if you need to deduplicate.