From 13b4ade66b482280d42e186072b2251d37e07ea1 Mon Sep 17 00:00:00 2001 From: Anthony Teo Date: Wed, 31 Mar 2021 19:41:03 -0500 Subject: [PATCH 1/3] Added 2s delay --- src/replay/index.ts | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/replay/index.ts b/src/replay/index.ts index 97840cde..61528661 100644 --- a/src/replay/index.ts +++ b/src/replay/index.ts @@ -610,18 +610,15 @@ export class Replayer { if (this.inactiveEndTimestamp) { const skipOffset = this.inactiveEndTimestamp - this.getMetaData().startTime; - if (this.service.state.matches('paused')) { - this.service.send({ - type: 'PLAY', - payload: { timeOffset: skipOffset }, - }); - } else { - this.service.send({ type: 'PAUSE' }); - this.service.send({ - type: 'PLAY', - payload: { timeOffset: skipOffset }, - }); - } + this.pause(skipOffset); + setTimeout( + () => + this.service.send({ + type: 'PLAY', + payload: { timeOffset: skipOffset }, + }), + 2000, + ); this.iframe.contentDocument ?.getElementsByTagName('html')[0] .classList.remove('rrweb-paused'); From 2c54ea1fa51ccfd6edd3642423b83822bd887655 Mon Sep 17 00:00:00 2001 From: Anthony Teo Date: Wed, 31 Mar 2021 19:41:44 -0500 Subject: [PATCH 2/3] updated version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1273592b..f7b742be 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@highlight-run/rrweb", - "version": "0.10.1", + "version": "0.10.2", "description": "record and replay the web", "scripts": { "test": "npm run bundle:browser && cross-env TS_NODE_CACHE=false TS_NODE_FILES=true mocha -r ts-node/register test/**/*.test.ts", From 0cc45c306dde4f6d5ba5499a441ee853b04cb464 Mon Sep 17 00:00:00 2001 From: Anthony Teo Date: Thu, 1 Apr 2021 16:47:10 -0500 Subject: [PATCH 3/3] Changed back to fast_forwarding --- src/replay/index.ts | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/replay/index.ts b/src/replay/index.ts index 61528661..73023d50 100644 --- a/src/replay/index.ts +++ b/src/replay/index.ts @@ -43,7 +43,9 @@ import getInjectStyleRules from './styles/inject-style'; import './styles/style.css'; const SKIP_TIME_THRESHOLD = 10 * 1000; -const SKIP_TIME_INTERVAL = 5 * 1000; +const SKIP_TIME_INTERVAL = 2 * 1000; +const SKIP_TIME_MIN = 0.5 * 1000; +const SKIP_DURATION_LIMIT = 60 * 60 * 1000; // https://github.com/rollup/rollup/issues/1267#issuecomment-296395734 // tslint:disable-next-line @@ -595,6 +597,7 @@ export class Replayer { private handleInactivity(timestamp: number, resetNext?: boolean) { if (timestamp === this.inactiveEndTimestamp || resetNext) { this.inactiveEndTimestamp = null; + this.backToNormal(); } if (this.config.skipInactive && !this.inactiveEndTimestamp) { for (const interval of this.getActivityIntervals()) { @@ -608,21 +611,19 @@ export class Replayer { } } if (this.inactiveEndTimestamp) { - const skipOffset = - this.inactiveEndTimestamp - this.getMetaData().startTime; - this.pause(skipOffset); - setTimeout( - () => - this.service.send({ - type: 'PLAY', - payload: { timeOffset: skipOffset }, - }), - 2000, - ); - this.iframe.contentDocument - ?.getElementsByTagName('html')[0] - .classList.remove('rrweb-paused'); - this.emitter.emit(ReplayerEvents.Start); + const skipTime = this.inactiveEndTimestamp! - timestamp!; + const payload = { + speed: + (skipTime / SKIP_DURATION_LIMIT) * this.config.inactiveSkipTime < + SKIP_TIME_MIN + ? skipTime / SKIP_TIME_MIN + : Math.round( + Math.max(skipTime, SKIP_DURATION_LIMIT) / + this.config.inactiveSkipTime, + ), + }; + this.speedService.send({ type: 'FAST_FORWARD', payload }); + this.emitter.emit(ReplayerEvents.SkipStart, payload); } } }