Offline Event Queue & Data Sync Manager avatar

Offline Event Queue & Data Sync Manager

Pricing

from $4.40 / 1,000 results

Go to Apify Store
Offline Event Queue & Data Sync Manager

Offline Event Queue & Data Sync Manager

Ensure zero data loss for user sessions by caching events locally when offline. This tool manages a persistent JSON-based queue that records events and allows for seamless bulk synchronization once connectivity is restored.

Pricing

from $4.40 / 1,000 results

Rating

0.0

(0)

Developer

Lore Nest

Lore Nest

Maintained by Community

Actor stats

0

Bookmarked

2

Total users

1

Monthly active users

10 days ago

Last modified

Categories

Share

Ensure zero data loss for user sessions by caching events locally when offline. This tool manages a persistent JSON-based queue that records events and allows for seamless bulk synchronization once connectivity is restored.

This Actor implements an offline-first event recording system that buffers user session events to a persistent local JSON file, ensuring no data is lost when the network is unavailable. Once connectivity is restored, the accumulated events can be retrieved and processed in a single batch via the sync action. By writing every recorded event to disk immediately and exposing a simple status endpoint, the tool gives you full visibility and durability guarantees for your session pipeline.

Use Cases

  • Offline form submissions: Capture user-submitted form data or survey responses during network outages and flush them to your backend in bulk once the connection returns, using the record and sync actions in sequence.
  • Session telemetry buffering: Queue clickstream, navigation, or interaction events in a local JSON file so analytics pipelines receive every event even if the client loses connectivity mid-session.
  • Resilient mobile data collection: Use the persistent queue as a crash-safe buffer on devices that roam between networks, calling sync only when a reliable connection is detected to minimize failed network requests.
  • Audit trail maintenance: Persist every recorded event to offline_queue.json on disk, providing a recoverable, file-based history that survives application restarts and can be inspected via the status action.
  • Batch processing hand-off: Drain the entire queue at once through the sync action, which returns the full list of buffered events and clears the on-disk queue in a single atomic step, making it straightforward to feed into a downstream processor.

How It Works

The Actor instantiates a singleton OfflineSessionManager that loads any existing queue from offline_queue.json at startup, defaulting to an empty list if the file is missing or contains invalid JSON. The run function dispatches incoming payloads to one of four actions: init reports the current queue size, record appends an event and immediately rewrites the file to disk via _persist, sync returns a copy of every queued event and atomically clears the file, and clear empties the queue without returning its contents. All disk operations are wrapped in exception handling so a corrupt or unwritable file degrades gracefully to an in-memory queue rather than crashing the Actor.

Usage on Apify

Run it directly from the Apify Console ("Start"/"Try for free"), or call it via the API:

POST https://api.apify.com/v2/acts/offline-session-sync/run-sync-get-dataset-items?token=<YOUR_APIFY_TOKEN>
Content-Type: application/json
{}

Pricing

Pay-per-event, billed automatically by Apify -- no separate account or payment step:

  • Actor start: $0.00005 per GB of memory (minimum one event per run)
  • Result: $0.005 per item returned -- this is the primary, usage-based charge

Also independently available at $0.0100 USDC (Base) per call via the x402 payment protocol (POST /tools/offline-session-sync) for callers outside the Apify platform.

Example output

Real output captured from this tool's own build-time smoke test (input above):

{
"error": "unknown action: None"
}