Skip to content

API Reference ​

Types ​

ts
interface CapturedError {
  error: unknown
  message: string
  stack?: string
  componentName?: string
  lifecycleHook?: string
  source: 'render' | 'async' | 'event' | 'unhandledrejection' | 'manual'
  timestamp: number
}

interface ErrorReporter {
  report(error: CapturedError, context?: Record<string, unknown>): void | Promise<void>
  destroy?(): void
}

destroy?() is optional teardown for an adapter that holds a persistent listener/timer of its own — nothing in the package calls it automatically, so call it yourself when tearing down whatever owns the reporter. Only createHttpReporter implements it (removing its pagehide listener and force-flushing any pending batch); every other adapter has nothing persistent to release and omits it.

source notes:

  • 'render' — a synchronous failure during a component's render or (sync) setup().
  • 'async' — an async setup() that rejects after an await. Vue reports both cases with the identical "setup function" info string, so this package additionally checks whether the component's own setup is an AsyncFunction to tell them apart.
  • 'event' — a Vue-compiled v-on handler (native DOM event or component emit) that throws. Note: Vue does route these through onErrorCaptured — what it genuinely can't see is covered in Error handling behavior.
  • 'unhandledrejection' / and non-Vue 'event's — only produced by useGlobalErrorCapture().
  • 'manual' — the default for captureError() when no source is given.