getsentry / rrweb

record and replay the web
https://www.rrweb.io/
Other
9 stars 5 forks source link

feat: Export `getCanvasManager` & allow passing it to `record()` #122

Closed mydea closed 8 months ago

mydea commented 9 months ago

This PR exports a new getCanvasManager() method which can be used to dynamically pass a canvas manager, allowing tree shaking.

This also removes the __RRWEB_EXCLUDE_CANVAS__ build flag - canvas will always be excluded now by default.

Expected usage:

import { record, getCanvasManager } from '@sentry-internal/canvas';

record({
  // other config...
  getCanvasManager,
});

The idea is that we can expose this somehow (?) from replay, so users can do e.g.:

import { Replay, getReplayCanvasManager } from '@sentry/browser';

Sentry.init({
  integrations: [
    new Replay({ canvasManager: getReplayCanvasManager() })
  ]
});

Or something like this, allowing people to opt-in to canvas recording at runtime, vs requiring a specific build step for it.

mydea commented 8 months ago

Can we make this default? (e.g. get rid of build flag?)

Yeah, I guess that makes sense here! 👍

github-actions[bot] commented 8 months ago

size-limit report 📦

Path Size
rrweb - record only (gzipped) 16.6 KB (-26.27% 🔽)
rrweb - record only (min) 57.17 KB (-27.45% 🔽)
rrweb - record with treeshaking flags (gzipped) 15.35 KB (+0.22% 🔺)
rrweb - record & getCanvasManager only (gzipped) 22.54 KB (added)
mydea commented 8 months ago

OK, I fixed the tests, seems good now. I ended up changing it so that you have to pass in a getCanvasManager method instead of the instance, which is a slightly "worse" API, but easier to implement because we need access to some of the parsed options from record, which we don't easily have otherwise 😬