Skip to content

feat: Wrap rrweb callbacks in wrapper to better handle errors #41

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

Merged
merged 1 commit into from
Feb 8, 2023
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
4 changes: 2 additions & 2 deletions packages/rrweb/package.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"prepare": "npm run prepack", "prepare": "npm run prepack",
"prepack": "npm run bundle", "prepack": "npm run bundle",
"test": "npm run bundle:browser && jest", "test": "npm run bundle:browser && jest",
"test:headless": "npm run bundle:browser && PUPPETEER_HEADLESS=true jest", "test:debug": "npm run bundle:browser && PUPPETEER_DEBUG=true jest",
"test:watch": "PUPPETEER_HEADLESS=true npm run test -- --watch", "test:watch": "npm run test -- --watch",
"repl": "npm run bundle:browser && node scripts/repl.js", "repl": "npm run bundle:browser && node scripts/repl.js",
"dev": "yarn bundle:browser --watch", "dev": "yarn bundle:browser --watch",
"bundle:browser": "cross-env BROWSER_ONLY=true rollup --config", "bundle:browser": "cross-env BROWSER_ONLY=true rollup --config",
Expand Down
3 changes: 2 additions & 1 deletion packages/rrweb/src/record/index.ts
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
import { IframeManager } from './iframe-manager'; import { IframeManager } from './iframe-manager';
import { ShadowDomManager } from './shadow-dom-manager'; import { ShadowDomManager } from './shadow-dom-manager';
import { CanvasManager } from './observers/canvas/canvas-manager'; import { CanvasManager } from './observers/canvas/canvas-manager';
import { callbackWrapper } from '../sentry/callbackWrapper';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be generally upstreamable, so I would try to name this in a way that is not sentry specific.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually disregard this. I can see we need to separately upstream this with the amount of pending upstream changes already.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm actually thinking to upstream this as a more generic configurable errorHandler kind of thing. IMHO that probably makes the most sense from a generic rrweb usage perspective! Then we can configure the error handler to add the __rrweb__ stuff in sentry-javascript for us (long term, when we eventually update our fork to v2)



function wrapEvent(e: event): eventWithTime { function wrapEvent(e: event): eventWithTime {
return { return {
Expand Down Expand Up @@ -343,7 +344,7 @@ function record<T = eventWithTime>(
); );


const observe = (doc: Document) => { const observe = (doc: Document) => {
return initObservers( return callbackWrapper(initObservers)(
{ {
mutationCb: wrappedMutationEmit, mutationCb: wrappedMutationEmit,
mousemoveCb: (positions, source) => mousemoveCb: (positions, source) =>
Expand Down
Loading