Record away from the host and sync on reconnect

Record offline evidence, upload bounded WebP capture chunks with an upload-only key, and view them directly in the browser.

Native offline capture records app evidence on the device while the Ansight host is disconnected, then transfers retained sessions when the app reconnects. Swift and Kotlin own recording, storage, recovery, ZIP creation, and delivery. .NET/MAUI, React Native, Expo development builds, Flutter, and Capacitor use those same native engines on supported Apple and Android targets.

Requirements: use compatible SDK and CLI builds that include native offline recording and the host receiver. SDK 1.8.0 provides the managed .NET recorder; it does not contain this native workflow.

Enable recording

Offline capture is opt-in. Add it to the options used by your existing runtime initialization. Enable Connectivity Capture alongside it to retain connection observations during a disconnected run.

.NET and MAUI

using Ansight;
using Ansight.Connectivity;
using Ansight.Native;

var options = Options.CreateBuilder()
    .WithConnectivityCapture()
    .WithOfflineCapture(new NativeOfflineCaptureOptions
    {
        MaximumSessions = 10,
        TransferMode = OfflineCaptureTransferMode.Automatic
    })
    .Build();

Runtime.InitializeAndActivate(options);

Add these options to the existing UseAnsight or initialization path when the app already configures Ansight. Do not create a parallel managed OfflineCaptureController in an app using native recording.

Swift

import AnsightCore

let options = try AnsightOptionsBuilder()
    .withConnectivityCapture()
    .withOfflineCapture(OfflineCaptureOptions(
        enabled: true,
        transferMode: .automatic,
        maximumSessions: 10
    ))
    .build()

Kotlin

import ai.ansight.runtime.AnsightOptionsBuilder
import ai.ansight.runtime.OfflineCaptureOptions
import ai.ansight.runtime.OfflineCaptureTransferMode

val options = AnsightOptionsBuilder()
    .withConnectivityCapture()
    .withOfflineCapture(OfflineCaptureOptions(
        enabled = true,
        transferMode = OfflineCaptureTransferMode.Automatic,
        maximumSessions = 10
    ))
    .build()

Calling the native builder’s withOfflineCapture() with no arguments enables recording. If you construct a Swift or Kotlin OfflineCaptureOptions object yourself, set enabled: true / enabled = true; the raw option object’s default is disabled.

React Native, Expo, and Capacitor

Use createOptionsBuilder from @ansight/react-native or @ansight/capacitor:

const options = createOptionsBuilder()
  .withConnectivityCapture()
  .withOfflineCapture({ maximumSessions: 10, transferMode: 'automatic' })
  .build();

Flutter

final options = AnsightOptionsBuilder()
    .withConnectivityCapture()
    .withOfflineCapture(const AnsightOfflineCaptureOptions(
      maximumSessions: 10,
      transferMode: 'automatic',
    ))
    .build();

Pass these options through the platform’s normal runtime initialization and activation. Framework HTTP wrappers keep recording while native status reports isOfflineCaptureRecording, subject to their existing network-capture opt-in.

Retention and lifecycle

SettingDefaultBehavior
maximumSessions10Includes the active recording; accepts any positive count.
maximumSessionBytes128 MiBRotates the recording when another record would exceed the payload budget.
maximumRetainedBytes512 MiBEvicts the oldest unleased sessions to bound retained payload bytes.
maximumQueuedBytes8 MiBBounds pending records and attachments.
transferModeautomaticTransfers retained sessions on an authenticated host reconnect. Use manual to require a request.
recordingEnabledtrueInitial app-controlled recording gate.
rootDirectoryApp-private storageCan be overridden to adopt an existing capture directory.

An active, eligible runtime can record before its first pairing. Connecting to the host seals the offline session; disconnecting starts another. Deactivation or revoking the recording gate seals recording and stops automatic transfers. Screenshots pause while the app is backgrounded.

Retention can evict untransferred sessions. In-flight transfer leases protect sessions until transfer completes or the lease is released. Byte budgets count payload files, excluding manifests, filesystem overhead, and the temporary transfer ZIP. Policy changes take effect at the next initialization; the recording gate can change while running.

For an app-controlled access policy in .NET, configure RecordingEnabled = false, initialize the runtime, then call await Runtime.SetOfflineCaptureEnabledAsync(userHasAnsightAccess) before activation. This gate is independent of configuring the feature.

Transfer and review

In automatic mode, reconnect the app to the matching host. The SDK sends each sealed archive over the authenticated app connection. The host verifies its size, checksum, archive paths, and app identity, imports the evidence, and persists it before acknowledging delivery.

The SDK deletes the local session only after a durable receipt with the matching source session ID and checksum. Interrupted transfers, older hosts, and invalid receipts retain the source for retry. Retrying an acknowledged import returns the same host session, including after a host restart.

For manual transfer, Swift and Kotlin expose transferOfflineCaptures(), and .NET exposes await Runtime.TransferOfflineCapturesAsync(). Agents can discover and invoke the offline_capture.transfer app tool when configured; that tool requires a write grant. A successful request means transfer started. Confirm completion by finding the imported session on the host.

ansight session list --json
ansight serve --open --session <imported-session-id>
ansight session connectivity <imported-session-id> summary --json

Imported IDs use offline-<source-session-id>. Review them alongside live captures in the player. See Connectivity Review for connection changes, quality samples, and annotation windows. Local-host transfer requires no cloud account or capture API key.

Evidence and compatibility

Recordings retain metadata, custom properties, metrics, events, client logs, touches, sanitized network requests, and configured screenshots and visual trees. Enabled connectivity observations travel through the application-event stream. Network bodies follow the configured capture and redaction policy.

The native stores can adopt prior managed sessions/<id> directories, including compact JSONL and existing manifest fields. They do not read encrypted ZIPs as a migration source or continue the managed cloud-upload workflow. Native capture currently has no offline annotated-feedback bundle sink and does not attach crash-report files to its ZIPs; crash reports retain their independent native outbox handoff.

Use Managed .NET Offline Capture for the existing controller, portable .NET recording, ZIP/AES export API, or separate cloud-upload integration. Keep one recorder responsible for an app’s offline session.

Upload sliced captures directly to the cloud

Availability: sliced cloud uploads require SDK 1.10.0 or later and a cloud deployment that supports the v2 sliced-upload protocol. Existing whole-session ZIP captures retain their import/export workflow; they are not converted automatically.

Set chunkDurationSeconds to enable the v2 recorder. One recording has a stable capture ID; each sealed chunk has an immutable sequence, start/end time and SHA-256 receipt. The SDK seals at the duration, byte or record limit. The final chunk is sealed when recording stops. Screenshots use WebP; JSON and images travel together in a bounded ZIP. Apple builds a pinned, namespaced libwebp source dependency through SwiftPM or CocoaPods. Android uses the platform WebP encoder.

Use 10-second chunks, a 4 MiB chunk byte budget and a retained queue sized for the expected offline period:

var options = AnsightOptions()
options.offlineCapture = OfflineCaptureOptions(
    enabled: true, transferMode: .manual, maximumSessions: 512,
    maximumSessionBytes: 4 * 1024 * 1024,
    chunkDurationSeconds: 10
)
try AnsightRuntime.shared.initializeAndActivate(options: options)
let uploader = try AnsightRuntime.shared.makeOfflineCaptureUploader(
    configuration: OfflineCaptureUploadConfiguration(endpoint: uploadEndpoint, apiKey: uploadKey)
)
let result = try await uploader.uploadPending()
val options = AnsightOptionsBuilder()
    .withOfflineCapture(OfflineCaptureOptions(
        enabled = true, transferMode = OfflineCaptureTransferMode.Manual,
        maximumSessions = 512, maximumSessionBytes = 4L * 1024 * 1024,
        chunkDurationSeconds = 10
    )).build()
// Apply options through the app's existing Ansight initialization.
val uploader = AnsightRuntime.makeOfflineCaptureUploader(
    OfflineCaptureUploadConfiguration(uploadEndpoint, uploadKey), application.cacheDir)
val uploadPass = uploader.uploadPending() // Future; wait off the UI thread.

For .NET/MAUI, use WithOfflineCapture(NativeOfflineCaptureOptions.ForCloudUploads()) on the options builder, then await Runtime.UploadOfflineCapturesAsync(uploadEndpoint, uploadKey). This uses the shared native recorder; do not add a second managed recorder.

React Native and Capacitor accept the same options through withOfflineCapture({ chunkDurationSeconds: 10, maximumSessionBytes: 4 * 1024 * 1024, maximumSessions: 512, transferMode: 'manual' }). Call their exported uploadOfflineCaptures(endpoint, apiKey) function. Flutter accepts these fields on AnsightOfflineCaptureOptions and exposes Ansight.instance.uploadOfflineCaptures(endpoint: uri, apiKey: key).

The endpoint is https://<project>.supabase.co/functions/v1/capture-upload-v2. Supply an app-scoped capture key (an_cap_…) or a runner key (an_run_…) with sessions:write. Testers need no portal account. Keep keys in caller-owned secure configuration; they are not part of serializable capture options. Only localhost test endpoints permit HTTP.

Run another upload pass after connectivity returns, periodically while recording, and while pendingChunks is nonzero. The result reports sessionIds, acknowledgedChunks and pendingChunks. Keep one uploader per recorder. On Android, close it when no longer needed. The SDK does not promise continued execution after the operating system suspends the app; the durable local queue resumes during a later upload pass.

The uploader sends sealed chunks while recording continues, retries interrupted transfers, and removes a local chunk only after the server confirms its exact hash as ready. Host reconnect transfer skips cloud chunks. When unacknowledged chunks fill the retained budget, recording pauses instead of evicting them. Observe the recorder’s error/drop counters, restore connectivity, and upload to free space. A recording is bounded to 4,096 chunks and 512 MiB of raw cloud uploads; stop and start recording for a new capture when reaching those limits.

Browser behavior

Uploads appear in the organisation’s Sessions list. The portal loads evidence around the selected time and seeks across chunk boundaries; it does not fetch the original ZIP. It displays available screenshots, logs, metrics, touches and visual trees while later chunks are arriving. A partial capture remains marked incomplete until every sequence through the final chunk is ready. Failed chunks and recorder-reported gaps are shown explicitly. Network payloads follow the existing cloud exclusion policy.

Server processing and recovery

Upload keys authorize capture uploads; they cannot read raw chunk storage or call service worker operations. Organisation membership governs replay access.

The upload endpoint validates app scope and immutable sequence reservations, issues a signed upload URL, and queues committed chunks. A bounded background invocation validates the archive, normalizes evidence and publishes an immutable replay chunk. Database leases fence stale workers. A minute cron retries abandoned jobs, with five processing attempts maximum, and reclaims acknowledged raw chunks and objects from deleted sessions.

Each ZIP is capped at 8 MiB, expanded content at 16 MiB, 256 entries and 128 screenshots, with additional record and organisation storage reservation limits. The SDK also rotates after 128 attachments. Browser and AI evidence windows are bounded to 64 chunks and 32 MiB of JSON; choose a narrower time range if a capture exceeds that window budget.

Investigate chunk uploads

Super admins can open Super Admin → Capture uploads, enter the session UUID from its replay URL, and optionally filter by chunk sequence. The view shows current receipts alongside an append-only event history: reservation, confirmed upload, processing attempts and stage durations, retry or failure, replay publication, and raw ZIP cleanup. Correlation IDs connect events from one upload request or worker attempt. Earlier failures remain visible after a successful retry. Refresh to load new events; older events and chunk receipts are paginated in groups of 100.

History is stored in offline_capture_chunk_events separately from the mutable offline_capture_chunks receipt. Events include sequence, attempt, timestamp, hash, byte counts, safe error codes, and stage-specific details. They exclude upload credentials, signed URLs, and captured payloads. Unknown provider and parser messages are replaced with a safe diagnostic to avoid copying captured content into history. Upload keys and ordinary portal accounts cannot read these diagnostics; super admins can read them but cannot rewrite events. Deleting a session deletes its history too. Existing captures receive a clearly labeled migration snapshot, without invented upload timestamps.

A confirmed-upload event means the server checked the stored object and accepted its commit. A network failure before that commit may leave only a reservation. Server history also cannot confirm deletion on the device: the SDK independently removes a local chunk after receiving a ready receipt with the matching SHA-256.

Successful raw ZIPs become eligible for cleanup immediately after normalization and durable evidence storage. To retain them briefly for diagnosis, set the Edge Function secret ANSIGHT_OFFLINE_RAW_SUCCESS_RETENTION_HOURS to a whole number from 0 to 168; the default is 0. The worker applies this value when completing a chunk. Failed ZIPs are retained for seven days after terminal failure. Pending and retrying uploads remain available for processing. The maintenance cron removes eligible objects in bounded batches, so expiry is a cleanup deadline rather than an exact deletion time. A cleanup failure is recorded and retried after an hour; an interrupted deletion is reconciled from Storage metadata.

While a raw ZIP is retained, a super admin can select Prepare ZIP download to obtain a download link valid for 60 seconds. History remains after raw ZIP cleanup, alongside the normalized replay evidence. This history feature requires only the server and portal update; existing v2 SDK uploaders remain compatible.