Skip to main content
OfflineQueue keeps events while your code cannot reach TechnicallyFit (a gym floor system that syncs at night, a service behind an unreliable link) and sends them in order when you call flush. Streams reach the API as summaries rather than raw sample lists: reduce streaming device samples into summary observations before queuing them, or stream the workout over Real-time when connected so its folded summaries arrive as ordinary readings when the session ends.
  • Checked when queued. An invalid event fails when you add it, and nothing is queued.
  • Keys fixed when queued. Each event gets its idempotency key (or keeps its source.record_id) when it is added, and the queue saves it through your storage. A flush after a crash sends the same keys, so the API answers duplicate instead of storing anything twice.
  • One flush at a time. A second flush waits for the first and then sends only what is left, so each event is sent once.
  • In order. Events are sent oldest first through POST /v1/events:bulk, in requests within the API’s limits, and the API decides each teammate’s events in that order.
  • Removed when answered. accepted and duplicate events leave the queue. A rejected event leaves it too and is reported in the result, because sending the same copy again gets the same answer. A request that fails as a whole leaves its events, and every later one, in the queue.
The bulk endpoint takes an organization key, so the queue runs where your key is: your servers or a sync service, never an app on a person’s device.

Storage

Give the queue a storage with load and save. It saves the whole queue after every change. MemoryStorage keeps it in memory, for tests.
A flush retries a rate limit or a temporary failure the way every SDK call does. When it still fails, it throws (or raises) and keeps the events: call flush again later.