@togohq/sdk-node 1.3.0
Version 1.3.0 adds withFlush() for serverless handlers and takes the flush interval in seconds
- Node.js SDK
Breaking
flushIntervalSeconds(10 to 60, default 10) replacesflushIntervalMs. AflushIntervalMspassed toinit()is ignored, with a warning naming the replacement.
New
withFlush(handler)wraps a serverless handler so the queue is sent after it returns or throws, with its result passed through unchanged.
Improved
batchSizeaccepts 100 to 500. A value outside that range is moved into it, with a warning.flush()retries a network failure or a server error within a 2-second budget before it resolves, and never retries a429.
Migration
Replace flushIntervalMs with flushIntervalSeconds, and wrap serverless handlers in withFlush().
const analytics = init({ writeKey, flushIntervalMs: 10_000 });const analytics = init({ writeKey, flushIntervalSeconds: 10 });
export const handler = analytics.withFlush(async (event) => {
analytics.track('order_paid', {}, { userId: event.userId });
});