Skip to Content
Spec

Analytics

Ingest request and reply, and the stored event.

Usage

import { analyticsIngestRequestSchema } from "@dapplelight/signet-spec/analytics"

const body = { events: [{ name: "page_view", anonymousId: "a-1", props: { plan: "pro" } }] }
const parsed = analyticsIngestRequestSchema.safeParse(body)
if (!parsed.success) console.log(parsed.error.issues)

Up to 50 events, names up to 64 characters, up to 20 props, ids match ^[A-Za-z0-9_.:-]{1,64}$. A bad body gets 400 with code INVALID_PAYLOAD.

API

ExportWhat it does
analyticsIngestRequestSchemaZod schema for the body of the ingest POST
analyticsIngestResponseSchemaThe 202 reply, { success: true, written }
analyticsIngestErrorSchemaThe 400 reply: the error envelope with code INVALID_PAYLOAD
trackedEventSchemaOne event: name, optional ts, ids and props
AnalyticsIngestRequestz.infer of the request schema
AnalyticsIngestResponsez.infer of the 202 schema
AnalyticsIngestErrorz.infer of the 400 schema
TrackedEventz.infer of the event schema
MAX_EVENTS50, events per request
MAX_PROPS20, props per event
MAX_NAME_LENGTH64, characters in an event name