Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Register errorHandler inside of CanvasManager #161

Merged
merged 3 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/rrweb/src/record/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@
unblockSelector,
sampling: sampling['canvas'],
dataURLOptions,
errorHandler,
},
);

Expand Down Expand Up @@ -627,7 +628,7 @@
plugins
?.filter((p) => p.observer)
?.map((p) => ({
observer: p.observer!,

Check warning on line 631 in packages/rrweb/src/record/index.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/rrweb/src/record/index.ts#L631

[@typescript-eslint/no-non-null-assertion] Forbidden non-null assertion.
options: p.options,
callback: (payload: object) =>
wrappedEmit(
Expand All @@ -647,7 +648,7 @@

iframeManager.addLoadListener((iframeEl) => {
try {
handlers.push(observe(iframeEl.contentDocument!));

Check warning on line 651 in packages/rrweb/src/record/index.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/rrweb/src/record/index.ts#L651

[@typescript-eslint/no-non-null-assertion] Forbidden non-null assertion.
} catch (error) {
// TODO: handle internal error
console.warn(error);
Expand Down
11 changes: 9 additions & 2 deletions packages/rrweb/src/record/observers/canvas/canvas-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
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 };

Expand All @@ -47,8 +48,9 @@
blockSelector: string | null;
unblockSelector: string | null;
mirror: Mirror;
sampling?: 'all' | number;
dataURLOptions: DataURLOptions;
errorHandler?: ErrorHandler;
sampling?: 'all' | number;
}

export class CanvasManagerNoop implements CanvasManagerInterface {
Expand Down Expand Up @@ -113,11 +115,16 @@
unblockSelector,
recordCanvas,
dataURLOptions,
errorHandler,
} = options;
this.mutationCb = options.mutationCb;
this.mirror = options.mirror;
this.options = options;

if (errorHandler) {
registerErrorHandler(errorHandler);
}

if (options.enableManualSnapshot) {
return;
}
Expand Down Expand Up @@ -158,7 +165,7 @@
this.pendingCanvasMutations.set(target, []);
}

this.pendingCanvasMutations.get(target)!.push(mutation);

Check warning on line 168 in packages/rrweb/src/record/observers/canvas/canvas-manager.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/rrweb/src/record/observers/canvas/canvas-manager.ts#L168

[@typescript-eslint/no-non-null-assertion] Forbidden non-null assertion.
};

private initCanvasFPSObserver(
Expand Down Expand Up @@ -420,7 +427,7 @@
if (!valuesWithType || id === -1) return;

const values = valuesWithType.map((value) => {
const { type, ...rest } = value;

Check warning on line 430 in packages/rrweb/src/record/observers/canvas/canvas-manager.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/rrweb/src/record/observers/canvas/canvas-manager.ts#L430

[@typescript-eslint/no-unused-vars] 'type' is assigned a value but never used.
return rest;
});
const { type } = valuesWithType[0];
Expand Down
Loading