Events
Server SDK
Server-side events tracking methods.
import Buildspace from "@buildspacestudio/sdk";
const bs = new Buildspace(process.env.BUILDSPACE_SECRET_KEY!);
await bs.events.track("order:created", { amount: 49.99 });
await bs.events.track("order:created", { amount: 49.99 }, "user_123");
await bs.events.batchTrack([
{ event: "email:sent", properties: { template: "welcome" } },
{ event: "user:action", actor_id: "user_123", timestamp: "2025-06-01T12:00:00Z" },
]);Methods:
track(event, properties?, actorId?)— track a single event immediately. Returns{ event_id }.batchTrack(events)— track multiple events in one request. Returns{ count, event_ids }.
Each event in batchTrack accepts:
event(required) — event name.properties(optional) — arbitrary key-value data.actor_id(optional) — associate the event with a user or actor.timestamp(optional) — ISO 8601 string; defaults to the current time if omitted.