OfflineProtocol from @offline-protocol/mesh-sdk. These signatures match v0.27.0. Read the integration guide for prerequisites and complete usage.
Methods on this page
enableTelemetrydisableTelemetryflushTelemetrytelemetryStatsendTelemetrySessionsetTelemetryEnabledtelemetryInstallId
enableTelemetry
Enables telemetry: the SDK collects, batches and uploads accepted events to the Offline Protocol ingest itself, on a background thread inside the native library. Nothing crosses the bridge per event and nothing reaches JavaScript; the only inputs are theapiKey and
appId the developer portal issued.
The native module fills in the platform (os, osMajor) and owns the
application lifecycle: entering the background closes the telemetry
session (a summary, then a flush inside an OS background task on iOS),
and returning to the foreground opens the next one. There is no
lifecycle call for the app to make.
Batches are durable across a restart once initializeMls has run
(the queue lives on the protocol-state store); before that they are
held in memory. Calling this again replaces the running pipe after its
final flush.
Rejects with code TelemetryConfigInvalid naming the refused field
when the configuration is unusable (an empty key, a non-ASCII app id,
a zero batch size).
What leaves the device, when, and how to switch it off are documented
in docs/telemetry.md; docs/privacy.md has the store disclosures.
disableTelemetry
Disables telemetry after one final flush of up to three seconds. The emit path goes back to its telemetry-off cost. Idempotent.flushTelemetry
Asks the uploader to send what is queued now. Returns immediately; the upload happens on the native background thread.telemetryStats
The telemetry pipe’s counters, ornull while telemetry is not
enabled. acceptedEvents is what the ingest reported accepting, which
is what an invoice is reconciled against; dropped counts events lost
to the ring buffer, the durable queue’s caps, the six-day expiry, a
permanent rejection, or everything queued or collected after the ingest
reported the application’s telemetry toggle off; lastError is the most
recent send failure, and clears once a batch is accepted, so it reports
the current state rather than the high-water mark of a recovered outage.
endTelemetrySession
Closes the current telemetry session explicitly: a summary, a flush of up to three seconds, then a fresh session id. The lifecycle-driven boundary still applies; calling both is safe because each summary reports only what the previous one did not. A no-op while collection is off; useflushTelemetry to push a queued backlog without collecting.
setTelemetryEnabled
Stops or resumes new collection without tearing the pipe down. Off, every emit costs one atomic load and nothing is buffered, and no session summary is emitted. The lifecycle transitions are still tracked, so the first foreground after collection resumes rotates the session as usual. Records queued before the switch continue to drain: this is a collection control, not an immediate network stop or a deletion. It is the runtime opt-out for a user setting.telemetryInstallId
Returns a stable, opaque per-install telemetry identifier (32 hex characters), derived from the SDK-managed persistent scrub secret. The secret itself never crosses the bridge and cannot be recovered from the id. Resolvesnull until the persistent secret is available, which is
after initializeMls has wired secure storage. Stamped on telemetry
batches only when TelemetryConfig.includeDeviceId is set; see
docs/privacy.md for the disclosure that setting carries.

