overleaf/services/web/frontend/js/features/source-editor/extensions/exception-logger.ts
Alf Eaton e025088065 Merge pull request #13241 from overleaf/ae-extensions-documentation
Add documentation for CodeMirror extensions

GitOrigin-RevId: e5f07084173f201919272f9d46dcdaef4b817874
2023-07-17 10:28:53 +00:00

15 lines
510 B
TypeScript

import { Extension } from '@codemirror/state'
import { EditorView } from '@codemirror/view'
import { captureException } from '../../../infrastructure/error-reporter'
/**
* A custom extension which configures the EditorView.exceptionSink facet
* so that exceptions are sent to Sentry with a `cm6-exception` tag.
*/
export const exceptionLogger = (): Extension => {
return EditorView.exceptionSink.of(exception => {
captureException(exception, {
tags: { handler: 'cm6-exception' },
})
})
}