ark_watch_client (Dart)

The ARK-RAPID Watch client for Dart 3.5+ and Flutter on Android, iOS, macOS, Windows and Linux (it uses dart:io, so not the web), with no dependencies. log() puts the event in a bounded in-memory ring and returns: it never blocks on the network and never throws. A worker isolate batches events, masks them, compresses them and sends them to POST /v1/events. While the server is unreachable they go to a disk spool and are replayed in order when it is back. When the ring is full, the drop policy applies and every drop is counted and reported to the server.

dart pub add ark_watch_client        # or: flutter pub add ark_watch_client
import 'dart:io';
import 'package:ark_watch_client/ark_watch_client.dart';

final audit = AuditClient(
  endpoint: Uri.parse('https://audit.example.com'),
  apiKey: Platform.environment['ARK_WATCH_API_KEY'], // a secret key from Admin -> Applications; never in source
  application: 'orders-api', environment: 'prod', appVersion: '2.3.1',
  spoolDirectory: '/var/lib/orders-api/audit-spool',       // optional, recommended: survives restarts and outages
);

audit.log(AuditLevel.notice, 'invoice.approve',
    message: 'Invoice approved', participantId: 'u-42', resourceType: 'invoice', resourceId: 'inv-1001',
    correlationId: requestId, attributes: {'amount': 125.5, 'currency': 'EUR'});

await audit.close(); // at shutdown: flushes what is buffered and stops the worker isolate
  • Fields filled in for you: event id (a ULID), time, host, IP, application, version, environment, and the participant (this program as a service when you give none).
  • Privacy: secret-looking attribute keys (password, token, api_key, ...) are masked to ***, card numbers and bearer tokens in text are replaced, and the event lists what was masked (redactions). The server applies its own policy as well.
  • Options: ringCapacity (8192), batchSize (500), flushInterval (200 ms), spoolMaxBytes (256 MB), dropPolicy (dropOldest, dropNewest, sampleDebug), requestTimeout (10 s), breakerFailureThreshold, breakerBaseDelay, breakerMaxDelay, pii.
  • Health: audit.stats returns logged, sent, spooled, replayed, dropped (by reason), rejected, internal errors and the breaker's state.
  • Flutter: give spoolDirectory a folder in the app's support directory (for example from path_provider). Mobile apps are often killed without warning. Events already spooled survive that, while events still in the ring (at most flushInterval worth) are lost.
  • Shutdown: the client holds a timer and an isolate. Until close() is called, a command-line program does not exit.

It behaves like the .NET and Python SDKs. The shared conformance suite (tests/Ark.Watch.Conformance.Tests) runs the same scenarios against all three, through dart run bin/conformance.dart. Unit and latency tests: dart test.

For AI coding agents

AGENTS.md and llms.txt are in the package (~/.pub-cache/hosted/pub.dev/ark_watch_client-<version>/). AGENTS.md has the exact API, rules, recipes and fixes of this package; llms.txt covers the whole product: when to choose it, sizing, every client and the HTTP contract. They are plain Markdown for any agent: Codex, Cline and Cline-based tools, Claude Code, Copilot, Cursor and others.

The same guidance is an Agent Skill at skills/ark-watch-client-dart/SKILL.md: copy that folder to .agents/skills/ (Codex, Cline, others), .cline/skills/ or .claude/skills/.

Author

ARK-RAPID Watch is created and maintained by Immanuel R (Immanuel Raj), AI developer, solution architect and cloud architect in Chennai, India: immanuel.co · About · Blog · GitHub · NuGet · npm · PyPI · Docker Hub · Stack Overflow

Libraries

ark_watch_client
ARK-RAPID Watch client for Dart and Flutter (dart:io): log never blocks and never throws; a worker isolate ships the events in the background, through a disk spool when the server is unreachable.