SDK
Batching
Events queue in memory and ship as one GalyaEventBatch per request—fewer round trips, survives short navigation if keepalive is used on unload.
Flushes when: queue hits batchSize, flushIntervalMs elapses, tab hidden, page unload, flush(), or destroy().
new GalyaSDK({
endpoint: "https://your-worker.workers.dev/v1/events",
apiKey: "galya_…",
userId: "u1",
onBatch: ({ batch, result, error }) => {
console.log(batch.events.length, result?.status);
},
});Request shape:
POST /v1/events
Authorization: Bearer <apiKey>
Content-Type: application/json
{ "events": [...], "batchId": "…", "sentAt": 1730000000000 }Use debug: true or onBatch to see failures without building your own logger.