amplitude / Amplitude-TypeScript

TypeScript Amplitude Analytics SDK
https://amplitude.github.io/Amplitude-TypeScript/
MIT License
129 stars 36 forks source link

feat(session replay): delay compresion #885

Closed jxiwang closed 1 week ago

jxiwang commented 1 week ago

Summary

Delays the compression of events emitted by rrrweb record using requestIdleCallback.

Checklist

jxiwang commented 1 week ago

@lewgordon-amplitude

Thanks for the feedback!

  1. For the timeout, I considered not including one but am also concerned with the case that the compression doesn't get fired. Even if the timeout is reached, the compression should get pushed to the back of the event queue in cases like when the page takes > 2s to load. Although I'm not entirely sure that doesn't have performance implications still. I could remove the timeout, and we could monitor the effects.

  2. Good call on the callbacks being generated per event. I'll add an event queue based on the timeRemaining, and I actually did not know idleDeadline could provide that information. Pretty cool that it does do that!

Agreed on adding an option so we can have control over testing this, and we can let customers know this is something they could turn on.