A warehouse is usually where the history you want to analyse already lives: orders, subscriptions, support tickets, everything a backend wrote down before anyone thought about analytics. This page covers getting it in, and getting events back out.
Status
Nothing about the import route is provisional: it is the same route the scheduled sync will use.
Importing history
POST https://t.intelligent.page/v1/import Authorization: Bearer ipa_sec_…
- Server key only. A Project token is
401. - Up to 2 000 events and 10 MB per request.
- Original timestamps are kept, on one condition below.
/v1/import keeps every event's ts exactly as sent; the service marks imported ids internally so they are never clamped. Use your own stable id per row (an order id, a row key) so a re-run after a failure is idempotent. Only /v1/ingest clamps timestamps to the last 24 hours.
A query that emits events
Shape the event in SQL and the loader becomes a loop. BigQuery:
SELECT
CONCAT('order-', CAST(o.id AS STRING)) AS id,
FORMAT_TIMESTAMP('%Y-%m-%dT%H:%M:%E3SZ', o.paid_at) AS ts,
'Order Paid' AS event,
CAST(o.customer_id AS STRING) AS did,
'server' AS source,
TO_JSON_STRING(STRUCT(
o.total AS revenue,
o.currency AS currency,
o.item_count AS items
)) AS props
FROM `shop.orders` o
WHERE o.paid_at > @cursor
ORDER BY o.paid_at
LIMIT 50000
The same shape works in Snowflake (OBJECT_CONSTRUCT instead of STRUCT) and in Postgres (jsonb_build_object). Three rules make the difference between a clean import and a mess:
idfrom the row's primary key. Idempotent, and re-runnable after a failure.didfrom the same id namespace your live tracking uses. A warehouse customer id and a browser user id that differ produce two people per customer, and nothing later will reconcile them. See Identity and merge.- Order by the cursor column and keep the last value. Resuming is then a matter of re-running with a new
@cursor.
A loader
const HOST = 'https://t.intelligent.page';
const KEY = process.env.ANALYTICS_SERVER_KEY;
async function importEvents(rows) { // rows: the query result, in order
for (let i = 0; i < rows.length; i += 2000) {
const events = rows.slice(i, i + 2000).map((r) => ({
id: r.id, ts: r.ts, event: r.event, did: r.did,
source: 'server', props: JSON.parse(r.props),
}));
const res = await fetch(`${HOST}/v1/import`, {
method: 'POST',
headers: { 'content-type': 'application/json', authorization: `Bearer ${KEY}` },
body: JSON.stringify({ events }),
});
const body = await res.json();
if (res.status === 429) {
// quota or rate limit: body.accepted landed, the rest did not
console.warn('paused at row', i + body.accepted, body.error);
return { stoppedAt: i + body.accepted, reason: body.error };
}
if (!res.ok) throw new Error(`import failed: ${res.status}`);
if (body.rejected) console.warn(`${body.rejected} rejected in chunk at ${i}`);
}
return { stoppedAt: null };
}
A 429 stops the run and tells you where. On rate_limited, wait a minute and resume from stoppedAt. On quota_exceeded, resume next month or ask for a higher limit: see Usage and billing.
rejected above zero means events that failed validation. The usual causes are a missing did, an event name with a character outside the allowed set, or a property that is an array. Limits and validation has the full list.
Incremental loads
Keep a cursor per source query, usually the maximum paid_at you loaded. Because the ids are deterministic, overlapping the window is safe: re-importing the same rows writes nothing.
An hourly job with a fifteen-minute overlap is the arrangement that survives late-arriving rows without duplicating anything.
Before you import three years
- Check the quota first. Imported events count against the Project's monthly quota, in the month you run the import, not the month they happened in. Three years of orders can consume a plan in an afternoon.
- Import one month first. Read it in a report, confirm the timestamps, the people and the properties are what you expected, and only then run the rest. Fixing a property name after ten million events means a Data Drop and another import.
- Decide what an event is before you start. One
Order Paidper order is usually right; one event per line item multiplies your volume by the basket size and rarely answers a question the properties could not. - Run it out of hours. An import competes with live traffic for the same per-key rate limit.
Getting data out
Today, read with a Server key through the API: the event catalog, reports, people and sessions are all available. See the API reference. CSV export from a report is in the product.
Bulk export is arriving: a nightly Parquet file per Project to a bucket, and GET /v1/export?day= for an on-demand pull. Until then, a scheduled report read is the supported path, and a Server key reads only its own Project.