Skip to content

Commit

Permalink
upstream: perf: Avoid an extra function call and object clone during …
Browse files Browse the repository at this point in the history
…event emission (#180)

performance: remove a nested function call and an object clone during
event emission

- rename `event` to `eventWithoutTime`, but maintain backwards
compatibility
- `eventWithTime` (with time) could be renamed to `event` in a future
version

This is an extension of PR rrweb-io#1339 authored by: mydea
<[email protected]>
  • Loading branch information
billyvg authored Apr 22, 2024
2 parents de6cd2b + cb5608b commit e53e6a6
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 190 deletions.
5 changes: 5 additions & 0 deletions .changeset/event-single-wrap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'rrweb': patch
---

perf: Avoid an extra function call and object clone during event emission
5 changes: 3 additions & 2 deletions packages/rrweb/src/record/iframe-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import CrossOriginIframeMirror from './cross-origin-iframe-mirror';
import { EventType, IncrementalSource } from '@sentry-internal/rrweb-types';
import type {
eventWithTime,
eventWithoutTime,
mutationCallBack,
} from '@sentry-internal/rrweb-types';
import type { StylesheetManager } from './stylesheet-manager';
Expand Down Expand Up @@ -52,7 +53,7 @@ export class IframeManager implements IframeManagerInterface {
new WeakMap();
private mirror: Mirror;
private mutationCb: mutationCallBack;
private wrappedEmit: (e: eventWithTime, isCheckout?: boolean) => void;
private wrappedEmit: (e: eventWithoutTime, isCheckout?: boolean) => void;
private loadListener?: (iframeEl: HTMLIFrameElement) => unknown;
private stylesheetManager: StylesheetManager;
private recordCrossOriginIframes: boolean;
Expand All @@ -62,7 +63,7 @@ export class IframeManager implements IframeManagerInterface {
mutationCb: mutationCallBack;
stylesheetManager: StylesheetManager;
recordCrossOriginIframes: boolean;
wrappedEmit: (e: eventWithTime, isCheckout?: boolean) => void;
wrappedEmit: (e: eventWithoutTime, isCheckout?: boolean) => void;
}) {
this.mutationCb = options.mutationCb;
this.wrappedEmit = options.wrappedEmit;
Expand Down
Loading

0 comments on commit e53e6a6

Please sign in to comment.