Send to Sentry
Send editor failures to Sentry and exclude document content from Replay, breadcrumbs, and URLs.
@docx-editor.dev/telemetry is available in version 2.29.0 and later.Register the Sentry exporter
Pass your app's Sentry module to sentryExporter, then register telemetry.module in the editor:
import * as Sentry from '@sentry/react';
import { createTelemetry } from '@docx-editor.dev/telemetry';
import { sentryExporter } from '@docx-editor.dev/telemetry/sentry';
export const telemetry = createTelemetry({ exporters: [sentryExporter(Sentry)] });The exporter uses the Sentry module from any Sentry JavaScript SDK. For registration and consent, see Set up an editor.
Protect document content
Block the editor in Replay and drop editor breadcrumbs. Call dropEditorBreadcrumbs first, then apply your own filter to what it keeps:
import * as Sentry from '@sentry/react';
import { dropEditorBreadcrumbs, EDITOR_SELECTORS } from '@docx-editor.dev/telemetry/sentry';
Sentry.init({
dsn: import.meta.env.VITE_SENTRY_DSN,
dataCollection: {
userInfo: false,
cookies: false,
httpHeaders: false,
httpBodies: [],
urlQueryParams: false,
},
integrations: [Sentry.replayIntegration({ block: [...EDITOR_SELECTORS] })],
beforeBreadcrumb: (crumb, hint) => {
const kept = dropEditorBreadcrumbs(crumb, hint);
return kept?.category === 'console' ? null : kept;
},
beforeSend: (event) => {
// Remove identifiers from the URL before the event leaves the browser.
if (event.request?.url) event.request.url = event.request.url.split('?')[0];
return event;
},
});EDITOR_SELECTORSinblockreplaces the editor with a placeholder in Replay. You do not needmask.dropEditorBreadcrumbsdrops editor click and key breadcrumbs. Theiralt,title, andaria-labelvalues can hold document content.dataCollectionstops user, cookie, header, request body, and query parameter collection. Sentry SDKs before version 11 usesendDefaultPii: falseinstead.- The
consolefilter drops console breadcrumbs, in case your code logs document details.
Choose issue behavior
Failures become grouped issues. Other events become breadcrumbs, which appear beside your errors without using event quota.
| Event | Default |
|---|---|
document.open rejected because of the app or an unexplained engine error | Issue |
document.open rejected for a corrupt or oversized file | Breadcrumb |
document.save rejected with save.failed | Issue |
edit.rejected with edit.internal-invariant | Issue |
review.skipped with review.revision-unsupported or review.retained-structure | Warning issue |
font.failed with font.shaper-unavailable | Issue |
collab.status error that does not recover | Issue |
collab.status for an expired token or compacted room | Breadcrumb (the client rejoins) |
| Everything else | Breadcrumb |
| Option or helper | Behavior |
|---|---|
issue: (event) => boolean | Replaces the classification. Combine with isSentryIssue(event) to extend the default. |
breadcrumbs | Records breadcrumbs for other events. Defaults to true. |
| Fingerprint | Diagnostic code, engine reason, and change kind. |
| Tags | Failure detail tags such as docx_editor.cause and docx_editor.change_kind. |
Limits
- The page URL is on every event and on navigation and fetch breadcrumbs. Remove identifiers in
beforeSendandbeforeBreadcrumb. - Removing query strings does not remove identifiers in URL paths or other fields.
- On a server, request bodies can attach to issues. If an endpoint receives document bytes or agent instructions, remove
event.request.datainbeforeSend. - Uncaught errors carry JavaScript messages and stack traces that the package does not control. Check them for document content.