# Observability without plaintext (https://docs.open-e2ee.dev/operate/observability.md)

- Status: stable
- Applies to: 15.0.0
- Platforms: Expo · Browser · Node
- Prereqs: A working client from Start → Quickstart
- Reading time: 12 min

You cannot read the messages. The system requires this property, so you cannot log and inspect payloads. You can still use error codes, counters, session health, key ages, and envelope timing. This page defines useful diagnostics and the data that can break the system's security property.

## The central warning [#the-central-warning]

> **Failure mode — The obvious fix is the vulnerability**
>
> Element shipped a bug in which "the private part of the backup key pair [was] logged to application debug logs… 156 unique Matrix IDs have been affected by this bug, resulting in their key material being leaked to the rageshake servers."
>
> Read the mechanism, not the headline. Nobody decided to log a private key. A diagnostic log serialized an object that contained one. The material then traveled to a bug-reporting server. This system collects and centralizes logs, which is dangerous when a log contains key material.
>
> Use two structural defenses. First, never let logger serialization select fields from an object. Construct each log payload from an explicit field allowlist. Second, include crash reporters and log aggregation in your threat model. These systems hold a copy of each emitted field.

**Figure:** A device holds plaintext and key material. Counters and codes cross the redaction boundary. Solid forms stay inside the device. Outlined codes, counters, and health values cross the redaction boundary into telemetry. These values carry metadata.

## What the SDK gives you [#what-the-sdk-gives-you]

**`client.logger`** is the injection point. The `Logger` shape is `debug`, `info`, `warn`, `error`, and `breadcrumb`, all optional. Supply your own at composition time, or import the primitives from `/logger`. The default logger is environment-aware: in development it wires all five to the console. In production it emits only `warn` and `error`. Under `NODE_ENV=test` it emits nothing.

```ts
const client = await createSignalProtocolClient({
  identity: { userId },
  adapters: { storage, relay },
  logger: {
    warn: (message, data) => telemetry.warn(message, redact(data)),
    error: (message, error, data) => telemetry.error(message, toCode(error), redact(data)),
  },
});
```

`redact` is yours and it is the most security-relevant function in your telemetry layer. Write it as an allowlist of field names, never a denylist.

**`client.getStats()`** returns `hasIdentityKey`, `oneTimePreKeysCount`, and `sessionCount`. Three numbers, cheap, and a good heartbeat gauge.

**`getSessionHealth(userId)`** returns a `SessionHealthResult`: `status`, `sessionExists`, a `message` for UI display, `issues[]`, `checkedAt`, a `keyStatus` block (`hasIdentityKey`, `hasSignedPreKey`, `hasKyberPreKey`, `signedPreKeyAgeDays`, `kyberPreKeyAgeDays`, `needsRotation`) and, when a session exists, `sessionStatus` with `createdAt`, `lastUsedAt`, `ageDays`, `messagesSent`, `messagesReceived`, `isExpiredForSending`, and `isExpiredForReceiving`. This is the richest per-peer diagnostic available without touching content.

**`checkPreKeyStatus()`** returns `oneTimePreKeysRemaining` and `needsReplenishment`. Graph the first, alert on the second persisting.

**`getSesameStats()`** returns `totalUsers`, `totalDevices`, `totalActiveSessions`, `totalInactiveSessions`, `expiredSessions`, and `staleRecords`. Rising `staleRecords` or `expiredSessions` means `cleanupExpiredSesameSessions()` is not running often enough.

**`getGroupSenderKeyStats(groupId, senderId, senderDeviceId)`** returns `generation`, `chainIndex`, and `skippedKeysCount`. `generation` is your evidence that a membership-change rotation actually happened.

**`client.syncStatus`** is `'synced' | 'failed' | 'none'`. A population sitting on `'failed'` is a prekey-publication outage in progress.

**React hooks** live at `/hooks` and are separate from `registerHook()`. `useSessionHealth({ signal, userId })` returns `{ health, isLoading, error, refresh }`. Use it for a per-conversation encryption-status indicator. `useKeyRotation({ signal, onRotationComplete })` calls `rotatePreKeys()` at most once per `rateLimitMs` and hands you the `PreKeyRotationResult`, so a rotation error count is one callback away. `useSignalProtocolRelayConnectionState({ signal })` returns this device's `SignalProtocolRelayConnectionState` for a local connection indicator. The SDK reports no device presence.

**`client.relayConnectionState`** is `stopped`, `connecting`, `connected`, or `reconnecting`. Count `reconnecting` transitions by `reason` from `subscribeRelayConnectionState(listener)`. The reason is a fixed site name such as `handshake`, `authentication`, or `silent`, never an error message, so it is safe to emit. A `silent` transition means that the OpenE2EE Signal Protocol Relay did not answer a ping before the next ping was due. A `stopped` state with the reason `upgrade-required` means that the Relay no longer serves the protocol version of the SDK. That subscription does not reconnect, so alert on it and ship a newer SDK. See [protocol versions](https://docs.open-e2ee.dev/signal-relay/protocol-versions.md).

The reasons `authority-refused`, `device-revoked`, and `device-unknown` also stop the subscription, and it does not reconnect. See [error handling](https://docs.open-e2ee.dev/operate/error-handling.md#when-the-relay-refuses-this-device).

## Safe to emit, and never [#safe-to-emit-and-never]

**Safe.** Emit error codes from `EncryptionErrorCode`. Emit counters for decrypt results and session lifecycle events. Emit `oneTimePreKeysRemaining` and `needsReplenishment`.

Session health fields include `status`, `ageDays`, signed and Kyber prekey age, `needsRotation`, and `isExpiredForSending`. You can emit envelope counts, sizes, delivery latency, and subscription uptime. Adapter identity, SDK version, `client.syncStatus`, and sender-key `generation` are also safe.

**Never.** Do not emit message plaintext in any form. This includes the "first 20 characters for debugging" pattern, truncated text, and known-salt hashes. Do not emit private key material or derived data. This includes identity keys, prekeys, sessions, message keys, chain keys, root keys, and the storage-wrapping key.

Do not emit safety numbers or the `numeric`, `emojis`, and `scannable` outputs from `generateCompositeSafetyNumber(...)`. A log with both peers' comparison data can impersonate the ceremony. Do not emit attachment plaintext, attachment keys, or presigned object-store URLs. These URLs are bearer credentials and "must not be logged or exposed beyond the authorized operation."

**Handle with care.** `EncryptionError.context` contents depend on the operation. Export allowlisted fields instead of the full object. `.untrustedAddress` on an `UntrustedIdentityError` identifies a peer. Most privacy obligations treat it as personally identifiable information even though it is not key material. Raw ciphertext is unreadable, but long-term log retention still creates a deliberate data copy.

## The two-sided problem [#the-two-sided-problem]

Matrix's undecryptable-message meta-issue catalogs over 70 distinct causes, and its operational conclusion is the one that should shape your support process: "we need logs from the receiver of the message and those from the sender. We generally can't debug issues without logs from both sides."

That has direct consequences.

Your correlation identifier must be content-independent and available on both sides. Derive it from the envelope. Store it in the sender's outbound record and receiver's inbound record. A support agent can then request the matching record.

Your support workflow needs a way to request diagnostics from a second user. Some reports from user A require data from user B. Without a consented collection mechanism for user B, these tickets remain unresolved. Design the consent flow before you need it.

Your diagnostic bundle needs a redaction pass that runs at collection time, on the device, before the bundle leaves. Redacting at the ingestion server means the unredacted copy already traveled: which is precisely how the Element leak reached the rageshake servers.

Accept a residue. Support cannot explain some undecryptable messages with evidence that you can legitimately collect. Give support an honest script for that case instead of an escalation path that ends in silence.

**Opacity ledger**

| Telemetry field | Stays on device | Sent to relay | In object store | Safe in a log sink |
|---|---|---|---|---|
| `EncryptionError.code` | yes | no | no | yes |
| `EncryptionError.context` | yes | no | no | allowlisted fields only |
| `getStats().sessionCount` | yes | no | no | yes |
| `getStats().oneTimePreKeysCount` | yes | no | no | yes |
| `checkPreKeyStatus().needsReplenishment` | yes | no | no | yes |
| `getSessionHealth().status` | yes | no | no | yes |
| `getSessionHealth().keyStatus.signedPreKeyAgeDays` | yes | no | no | yes |
| `getSesameStats().staleRecords` | yes | no | no | yes |
| `getGroupSenderKeyStats().generation` | yes | no | no | yes |
| `client.syncStatus` | yes | no | no | yes |
| `client.userId` / `client.deviceId` | yes | yes | no | PII — treat as such |
| `message.content` | yes | no | no | **never** |
| `identityKeyPair` private half | yes | no | no | **never** |
| Session record (`version: 4`) | yes | no | no | **never** |
| `generateCompositeSafetyNumber()` output | yes | no | no | **never** |
| Presigned object-store URL | transient | no | n/a | **never** |

> **Tradeoff — Diagnostic depth vs. the size of the copy you are creating**
>
> Each telemetry field can help resolve bugs and make the log store a more valuable target. The protocol does not protect your log store. It holds supplied data under vendor access controls for the configured retention period. Use short retention for rich fields and longer retention for counters. Select these periods explicitly instead of inheriting vendor defaults.

> **Not covered — Server-side metrics on the relay**
>
> Your deployment defines what the relay records, including envelope volume, delivery latency, device presence, and access logs. The SDK does not control this design. [Limits and metadata](https://docs.open-e2ee.dev/learn/limits-and-metadata.md) covers its metadata exposure.

## Next [#next]

- [Error handling and retries](https://docs.open-e2ee.dev/operate/error-handling.md)
- [Key rotation](https://docs.open-e2ee.dev/operate/key-rotation.md)
- [Limits and metadata](https://docs.open-e2ee.dev/learn/limits-and-metadata.md)
- [Testing encrypted flows](https://docs.open-e2ee.dev/operate/testing.md)
