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: Refactor module scope vars & export mirror & takeFullSnapshot directly #113

Merged
merged 3 commits into from
Oct 27, 2023

Conversation

mydea
Copy link
Member

@mydea mydea commented Oct 17, 2023

Currently, we use these from record.xx, which is not ideal thinking about treeshaking and lazy loading.

This moves these to be proper exports so we can use the in Replay without having to import record and everything that comes with it (=everything).

@mydea mydea requested a review from billyvg October 17, 2023 07:58
@mydea mydea self-assigned this Oct 17, 2023
let canvasManager!: CanvasManager;
let recording = false;

const mirror = createMirror();
export const mirror = createMirror();
Copy link
Member

Choose a reason for hiding this comment

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

🤔

so rrweb1 did have mirror exported directly, but they deprecated that -- I'm not sure the reasoning (it's possible they wanted to keep compatibility and decided to have a different interface to mirror, but maybe worthwhile to dig in and see why they changed public interface to mirror.

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 so that mirror was different - it was a shared mirror for recording/replaying, I believe (also that mirror was a noop by now).

This is different in that we just always export the recording mirror from @sentry/rrweb.

@mydea mydea force-pushed the fn/custom-exports branch from a5bcc01 to 677e95d Compare October 25, 2023 09:15
@mydea mydea changed the title feat: Export takeFullSnapshot and mirror from record feat: Refactor module scope vars & export mirror & takeFullSnapshot directly Oct 25, 2023
@mydea
Copy link
Member Author

mydea commented Oct 25, 2023

I've updated this to actually remove as much module scope vars as possible, removing things we put on record.xxx that we don't actually need (this cannot be tree shaken), and streamlining this as much as possible. This should safe us a few bytes...!

@github-actions
Copy link

github-actions bot commented Oct 27, 2023

size-limit report 📦

Path Size
rrweb - record only (gzipped) 23 KB (-0.22% 🔽)
rrweb - record only (min) 80.57 KB (-0.26% 🔽)
rrweb - record with treeshaking flags (gzipped) 15.8 KB (-0.29% 🔽)

@mydea mydea force-pushed the fn/custom-exports branch from 39ceb88 to c22a3e8 Compare October 27, 2023 08:01
@mydea mydea merged commit ab97f8f into sentry-v2 Oct 27, 2023
12 checks passed
@mydea mydea deleted the fn/custom-exports branch October 27, 2023 08:10
mydea added a commit to getsentry/sentry-javascript that referenced this pull request Oct 31, 2023
- feat: Export getCanvasManager & allow passing it to record() [#122](getsentry/rrweb#122)
- feat: Remove hooks related code, which is not used [#126](getsentry/rrweb#126)
- feat: Remove plugins related code, which is not used [#123](getsentry/rrweb#123)
- feat: Refactor module scope vars & export mirror & `takeFullSnapshot` directly [#113](getsentry/rrweb#113)
- fix(rrweb): Fix rule.style being undefined [#121](getsentry/rrweb#121)
- ref: Avoid unnecessary cloning of objects or arrays [#125](getsentry/rrweb#125)
- ref: Avoid cloning events to add timestamp [#124](getsentry/rrweb#124)
mydea added a commit to getsentry/sentry-javascript that referenced this pull request Oct 31, 2023
- feat: Export getCanvasManager & allow passing it to record() [#122](getsentry/rrweb#122)
- feat: Remove hooks related code, which is not used [#126](getsentry/rrweb#126)
- feat: Remove plugins related code, which is not used [#123](getsentry/rrweb#123)
- feat: Refactor module scope vars & export mirror & `takeFullSnapshot` directly [#113](getsentry/rrweb#113)
- fix(rrweb): Fix rule.style being undefined [#121](getsentry/rrweb#121)
- ref: Avoid unnecessary cloning of objects or arrays [#125](getsentry/rrweb#125)
- ref: Avoid cloning events to add timestamp [#124](getsentry/rrweb#124)
mydea added a commit to getsentry/sentry-javascript that referenced this pull request Oct 31, 2023
- feat: Export getCanvasManager & allow passing it to record() [#122](getsentry/rrweb#122)
- feat: Remove hooks related code, which is not used [#126](getsentry/rrweb#126)
- feat: Remove plugins related code, which is not used [#123](getsentry/rrweb#123)
- feat: Refactor module scope vars & export mirror & `takeFullSnapshot` directly [#113](getsentry/rrweb#113)
- fix(rrweb): Fix rule.style being undefined [#121](getsentry/rrweb#121)
- ref: Avoid unnecessary cloning of objects or arrays [#125](getsentry/rrweb#125)
- ref: Avoid cloning events to add timestamp [#124](getsentry/rrweb#124)
mydea added a commit to getsentry/sentry-javascript that referenced this pull request Oct 31, 2023
- feat: Export getCanvasManager & allow passing it to record()
[#122](getsentry/rrweb#122)
- feat: Remove hooks related code, which is not used
[#126](getsentry/rrweb#126)
- feat: Remove plugins related code, which is not used
[#123](getsentry/rrweb#123)
- feat: Refactor module scope vars & export mirror & `takeFullSnapshot`
directly [#113](getsentry/rrweb#113)
- fix(rrweb): Fix rule.style being undefined
[#121](getsentry/rrweb#121)
- ref: Avoid unnecessary cloning of objects or arrays
[#125](getsentry/rrweb#125)
- ref: Avoid cloning events to add timestamp
[#124](getsentry/rrweb#124)


Note: With this update, canvas is _always_ excluded, unless we opt in by
passing a `getCanvasManager` function to `record()`. We'll provide a way
to do this once we have a fully formed canvas story. For now, this will
reduce bundle size considerably for all SDK users.
billyvg pushed a commit that referenced this pull request Apr 26, 2024
…t` directly (#113)

Currently, we use these from `record.xx`, which is not ideal thinking
about treeshaking and lazy loading.

This moves these to be proper exports so we can use the in Replay
without having to import `record` and everything that comes with it
(=everything).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants