@accordkit/tracer - v0.2.1
    Preparing search index...

    Class BrowserSink

    BrowserSink Buffered (or immediate) delivery of JSONL batches to an HTTP endpoint from the browser.

    • Uses navigator.sendBeacon for small payloads (≤ beaconMaxBytes), else falls back to fetch(keepalive).
    • Guarded flushes: no overlap; close() drains deterministically.
    • Optional durable storage via IndexedDB (survives reloads/crashes). When enabled:
      • flush() moves RAM buffers -> IDB, then dequeues from IDB in batchSize chunks.
      • chunks are deleted from IDB only after successful delivery.
      • failures leave data in IDB for next flush (no data loss).

    Implements

    Index

    Constructors

    Methods

    Constructors

    Methods

    • Persist a single event for a session.

      Parameters

      • sessionId: string

        Unique identifier for grouping related events. Used for partitioning and log file naming.

      • e: TracerEvent

        The trace event to persist. See TracerEvent for structure.

      Returns void | Promise<void>

      Void or Promise for async implementations.

      Implementations should:

      • Handle errors gracefully without throwing
      • Consider batching for performance if needed
      • Maintain order of events within a session
      • Be thread-safe if used in concurrent environments
    • Public flush: serialized, drains RAM buffers (-> IDB if enabled) then IDB in batchSize chunks with sendBeacon/fetch.

      Returns Promise<void>