Buildspace
Events

Client SDK

Browser-side events tracking methods.

import { createClient } from "@buildspacestudio/sdk/client";

const bs = createClient(process.env.NEXT_PUBLIC_BUILDSPACE_PUBLISHABLE_KEY!);

bs.events.track("page:viewed", { path: window.location.pathname });
bs.events.track("button:clicked", { label: "Sign Up" }, "user_123");
await bs.events.flush();
await bs.events.shutdown();

Methods:

  • track(event, properties?, actorId?) — queue an event for batched delivery. actorId optionally associates the event with a specific user or actor.
  • flush() — send all queued events immediately.
  • shutdown() — stop the automatic flush timer and send remaining events.