diff --git a/packages/rrweb/src/record/index.ts b/packages/rrweb/src/record/index.ts index b572d578aa..ca7cec2702 100644 --- a/packages/rrweb/src/record/index.ts +++ b/packages/rrweb/src/record/index.ts @@ -347,6 +347,7 @@ function record( unblockSelector, sampling: sampling['canvas'], dataURLOptions, + errorHandler, }, ); diff --git a/packages/rrweb/src/record/observers/canvas/canvas-manager.ts b/packages/rrweb/src/record/observers/canvas/canvas-manager.ts index 1dacf6d0f0..d5f45d8044 100644 --- a/packages/rrweb/src/record/observers/canvas/canvas-manager.ts +++ b/packages/rrweb/src/record/observers/canvas/canvas-manager.ts @@ -20,7 +20,8 @@ import initCanvas2DMutationObserver from './2d'; import initCanvasContextObserver from './canvas'; import initCanvasWebGLMutationObserver from './webgl'; import { getImageBitmapDataUrlWorkerURL } from '@sentry-internal/rrweb-worker'; -import { callbackWrapper } from '../../error-handler'; +import { callbackWrapper, registerErrorHandler } from '../../error-handler'; +import type { ErrorHandler } from '../../../types'; export type RafStamps = { latestId: number; invokeId: number | null }; @@ -47,8 +48,9 @@ export interface CanvasManagerConstructorOptions { blockSelector: string | null; unblockSelector: string | null; mirror: Mirror; - sampling?: 'all' | number; dataURLOptions: DataURLOptions; + errorHandler?: ErrorHandler; + sampling?: 'all' | number; } export class CanvasManagerNoop implements CanvasManagerInterface { @@ -113,11 +115,16 @@ export class CanvasManager implements CanvasManagerInterface { unblockSelector, recordCanvas, dataURLOptions, + errorHandler, } = options; this.mutationCb = options.mutationCb; this.mirror = options.mirror; this.options = options; + if (errorHandler) { + registerErrorHandler(errorHandler); + } + if (options.enableManualSnapshot) { return; }