Togo
Togo
Apply for the beta

Changelog@togohq/sdk-node

@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

On this site since

Breaking

  • flushIntervalSeconds (10 to 60, default 10) replaces flushIntervalMs. A flushIntervalMs passed to init() 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

  • batchSize accepts 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 a 429.

Migration

Replace flushIntervalMs with flushIntervalSeconds, and wrap serverless handlers in withFlush().

Before
const analytics = init({ writeKey, flushIntervalMs: 10_000 });
After
const analytics = init({ writeKey, flushIntervalSeconds: 10 });
export const handler = analytics.withFlush(async (event) => {
  analytics.track('order_paid', {}, { userId: event.userId });
});

The old form stops working in 1.3.0.