retrace_frontend/client
JavaScript delivery runtime. Capture and application updates remain separate. The host owns start/stop; saved batches drain across runtime restarts.
The client asks the collector to open a session, then uploads saved batches oldest first. A failed pass keeps its batch and waits before the next one, from 1.5 seconds doubling to 60. A refusal that a retry cannot change makes the client discard that session’s saved batches. An idle client holds no timer. In a browser, a page that becomes hidden or navigates away hands its unacknowledged batches to the transport’s keepalive send.
Types
pub type Config {
Config(
endpoint: String,
queue_name: String,
max_items: Int,
max_bytes: Int,
)
}
Constructors
-
Config( endpoint: String, queue_name: String, max_items: Int, max_bytes: Int, )
pub type Status {
Status(queued: Int, acknowledged: Int, detail: String)
}
Constructors
-
Status(queued: Int, acknowledged: Int, detail: String)
A factory that opens caller-owned persistence. Use retrace_frontend/client/adapter to construct one from Gleam operations, or provide an existing FFI adapter.
pub type Storage
Values
pub fn browser_storage() -> Storage
pub fn enqueue(
client: Client,
upload: wire.Upload,
saved: fn(Result(Nil, String)) -> Nil,
) -> Nil
Called after projection. The callback confirms local persistence, not upload. Validation failure does not touch local storage or the network.
pub fn http_transport(endpoint: String) -> Transport
pub fn open(
client: Client,
metadata: wire.Metadata,
opened: fn(Result(wire.Grant, String)) -> Nil,
) -> Nil
Ask the collector to open a session for metadata. opened receives the
server-issued session and its write token once the collector answers; until
then the request is retried with the client’s upload retries. The collector
must keep the metadata it was given.