diff --git a/packages/rrweb/src/record/index.ts b/packages/rrweb/src/record/index.ts index 10b2aa594c..0945f585d7 100644 --- a/packages/rrweb/src/record/index.ts +++ b/packages/rrweb/src/record/index.ts @@ -358,6 +358,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 276b1e9c00..c6e29a2e47 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; }