rrweb icon indicating copy to clipboard operation
rrweb copied to clipboard

ref: Avoid cloning events to add `timestamp`

Open mydea opened this issue 2 years ago • 3 comments

We are always passing in fresh objects to this method, so instead of cloning this into a new object, we can just put the timestamp on the given object directly and return it, saving a bit of processing cost.

mydea avatar Oct 25 '23 11:10 mydea

🦋 Changeset detected

Latest commit: 065587aa4dc7861e9f1e96c02088cca8ec3e2f47

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
rrweb Patch
rrweb-snapshot Patch
rrdom Patch
rrdom-nodejs Patch
rrweb-player Patch
@rrweb/types Patch
@rrweb/web-extension Patch
rrvideo Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar Oct 25 '23 11:10 changeset-bot[bot]

This is modifying the underlying object? Are you sure there aren't any typing problems with this, or possible knock on problems? (I can't think of anything over and above it being 'less clean')

eoghanmurray avatar Feb 26 '24 16:02 eoghanmurray

Yes, but as far as I can tell we are always passing in a fresh object into this anyhow. We've been running this on our fork at Sentry without problems (as far as I can tell...) for some time now!

mydea avatar Feb 27 '24 08:02 mydea

I've gone a bit further with #1441 to avoid that extra function call at all

eoghanmurray avatar Apr 09 '24 11:04 eoghanmurray

And thank you for the contribution!

(I couldn't make commits directly to this PR)

eoghanmurray avatar Apr 09 '24 11:04 eoghanmurray

(actually #1441 needs some more work)

eoghanmurray avatar Apr 09 '24 12:04 eoghanmurray

#1441 is ready now as a larger change than this one

eoghanmurray avatar Apr 11 '24 10:04 eoghanmurray

#1441 has been merged and I've tagged you in the merge commit, thank you for the PR!

eoghanmurray avatar Apr 19 '24 11:04 eoghanmurray