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.

OptionDefaultDescription
urlRequiredRoute on your own origin.
batchSize20Events per request, 1 to 50. Keep it within the route's maxEvents.
flushIntervalMs10000Longest wait before a partial batch sends.
headersNoneExtra headers. Closing pages then use keepalive fetch instead of beacons.
onErrorNoneReports failed requests and dropped events.

Configure the receiving route

telemetryRoute(options) from @docx-editor.dev/telemetry/ingest returns a Fetch-style POST handler.

OptionDefaultDescription
forward(events)RequiredSends events that pass.
allowedOriginsAnyOrigins allowed to post.
maxBodyBytes64 KiBLargest body, in bytes.
maxEvents50Longer arrays are refused. The browser still caps batches at 50.
attributeKeysNoneBrowser resource and attributes keys to keep. Values must be numbers, booleans, or identifier strings. Others are dropped.
onErrorNoneCalled 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

HelperDescription
filterClient 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 204 even when forwarding fails. Use onError.
  • Apply rate limits through your platform.

See also