HTTP exporter and route reference
Configure HTTP event batches, delivery, filtering, and server validation.
@docx-editor.dev/telemetry is available in version 2.29.0 and later.For setup steps, see Send to a log service.
Configure HTTP delivery
httpExporter({ url: '/api/telemetry' }) posts JSON arrays of events. telemetry.flush() sends with fetch. A hidden page sends with navigator.sendBeacon.
| Option | Default | Description |
|---|---|---|
url | Required | Route on your own origin. |
batchSize | 20 | Events per request, 1 to 50. Keep it within the route's maxEvents. |
flushIntervalMs | 10000 | Longest wait before a partial batch sends. |
headers | None | Extra headers. Closing pages then use keepalive fetch instead of beacons. |
onError | None | Reports failed requests and dropped events. |
Configure the receiving route
telemetryRoute(options) from @docx-editor.dev/telemetry/ingest returns a Fetch-style POST handler.
| Option | Default | Description |
|---|---|---|
forward(events) | Required | Sends events that pass. |
allowedOrigins | Any | Origins allowed to post. |
maxBodyBytes | 64 KiB | Largest body, in bytes. |
maxEvents | 50 | Longer arrays are refused. The browser still caps batches at 50. |
attributeKeys | None | Browser resource and attributes keys to keep. Values must be numbers, booleans, or identifier strings. Others are dropped. |
onError | None | Called when forward fails or the service refuses. |
It ignores non-POST methods, refuses bad origins and oversized requests, then validates each event:
- Drops unknown kinds or codes, mismatched codes, missing fields, and out-of-range values.
- Drops timing summaries unless counts are whole, bands sum to
count, and median ≤ p95 ≤ max. - Drops performance summaries with no timing summary.
- Removes unknown fields, and numeric fields and timing summaries that the event kind does not support.
Filter and count events
| Helper | Description |
|---|---|
filter | Client option. Selects exported events; metrics count all. Filter by kind so summaries pass. |
browserPrivacySignals({ optOutKey? }) | consent function: false on Global Privacy Control, Do Not Track, optOutKey set to off, or no browser. |
isFailure(event) | false for deduplication summaries. |
failureCount(event) | Failures an event adds, including summaries. |
toLogRecord(event) | Adds dt, message, occurrences, and failures; removes hint and docs. |
validateTelemetryEvents(body, options?) | Route validation for a parsed body. |
Combine consent sources with consent: () => privacy() && consentManager.analytics.
Limits
- HTTP delivery failures call
onError. They never throw into your application. - Closing-page delivery shares a best-effort budget of about 64 KiB.
- Withdrawn consent discards queued events.
- The handler returns
204even when forwarding fails. UseonError. - Apply rate limits through your platform.