Set up an editor
Create the telemetry client, register its module in React or Vue, and choose what to record.
@docx-editor.dev/telemetry is available in version 2.29.0 and later.Register telemetry
Create the client once, outside your components:
// telemetry.ts
import { createTelemetry } from '@docx-editor.dev/telemetry';
import { sentryExporter } from '@docx-editor.dev/telemetry/sentry';
import * as Sentry from '@sentry/react';
export const telemetry = createTelemetry({
exporters: [sentryExporter(Sentry)],
include: { documentOpen: true, trackedChanges: true, editing: true },
consent: () => consentManager.analytics === true, // your consent manager
resource: { 'service.name': 'contracts-app' },
});Register telemetry.module so it receives diagnostics from the first document the editor opens:
import { DocxEditor } from '@docx-editor.dev/react';
import { reviewModule } from '@docx-editor.dev/pro';
import { telemetry } from './telemetry';
const MODULES = [reviewModule(), telemetry.module];
export function Editor({ bytes }: { bytes: Uint8Array }) {
return <DocxEditor document={bytes} modules={MODULES} />;
}<script setup lang="ts">
import { DocxEditor } from '@docx-editor.dev/vue';
import { reviewModule } from '@docx-editor.dev/pro';
import { telemetry } from './telemetry';
defineProps<{ bytes: Uint8Array }>();
const MODULES = [reviewModule(), telemetry.module];
</script>
<template>
<DocxEditor :document="bytes" :modules="MODULES" />
</template>Register the module or call telemetry.record(event) yourself. Doing both records each event twice.
Choose recorded areas
If you omit include, all areas are on. If you set it, list every area you want, including ones with default options.
| Area | Records |
|---|---|
documentOpen | Opens with size and page buckets and duration. Refused opens with the reason. |
documentSave | Each save() call: saved with size bucket and duration, or failed with the reason. |
sessions | Editor start and end, active editing time, and edits by origin. See Sessions. |
editing | Refused edits and commands while changes are not tracked. |
trackedChanges | Refused tracked edits, tracking errors, and changes skipped during accept, reject, or reassign. |
fonts | Fonts that failed to load and were substituted. |
history | Undo steps that did not group as the gesture intended. |
customNodes | Custom node payloads that could not be read. |
collaborationClient | Status changes, failure codes, connect time, and participant count. |
performance | Key press or click to next frame, plus layout and paint times. See Performance. |
Configure collection
| Option | Default | Behavior |
|---|---|---|
consent | Collection allowed | boolean or () => boolean. When false, new events are dropped, not buffered. Checked per event and per timed key press, layout, and paint. Keep it fast. Never runs during server rendering. Applies to every exporter, including the console. |
include.<area>.sampleRate | 1 | 0 to 1. Samples events only; metrics count every event. For performance and sessions, the rate selects editors. performance at 0 stops measurement and its metrics. |
documentShape | 'basic' | 'detailed' adds part, paragraph, review item, and embedded font buckets. See Privacy. |
dedupeWindowMs | 10000 | Identical refusals send once per window. 0 sends every event. A summary then reports repeated, the count of extra events only. Participant counts and repeated statuses also send once per window. |
To allow all exporters in local builds, use consent: () => import.meta.env.DEV || consentManager.analytics === true.
Inspect development events
Add consoleExporter() to print each event with its hint and documentation link:
import { createTelemetry, consoleExporter } from '@docx-editor.dev/telemetry';
export const telemetry = createTelemetry({ exporters: [consoleExporter()] });For every code and hint, see Diagnostics.
Limits
consentcontrols only this package. Your OpenTelemetry SDK can still export metrics it recorded earlier. Apply the same decision to your Sentry and OpenTelemetry SDKs.- A deduplication summary is not a new failure.
- Which areas become Sentry issues is set by the exporter. See Send to Sentry.