Expose constant SKIP_TIME_THRESHOLD as inactivePeriodThreshold in replayer (#1408)
Expose constant SKIP_TIME_THRESHOLD as `inactivePeriodThreshold` config setting in replayer
This commit is contained in:
@@ -114,7 +114,7 @@
|
||||
const totalEvents = context.events.length;
|
||||
const start = context.events[0].timestamp;
|
||||
const end = context.events[totalEvents - 1].timestamp;
|
||||
const periods = getInactivePeriods(context.events);
|
||||
const periods = getInactivePeriods(context.events, replayer.config.inactivePeriodThreshold);
|
||||
// calculate the indicator width.
|
||||
const getWidth = (
|
||||
startTime: number,
|
||||
|
||||
@@ -161,20 +161,18 @@ function isUserInteraction(event: eventWithTime): boolean {
|
||||
);
|
||||
}
|
||||
|
||||
// Forked from 'rrweb' replay/index.ts. A const threshold of inactive time.
|
||||
const SKIP_TIME_THRESHOLD = 10 * 1000;
|
||||
|
||||
/**
|
||||
* Get periods of time when no user interaction happened from a list of events.
|
||||
* @param events - all events
|
||||
* @param inactivePeriodThreshold - threshold of inactive time in milliseconds
|
||||
* @returns periods of time consist with [start time, end time]
|
||||
*/
|
||||
export function getInactivePeriods(events: eventWithTime[]) {
|
||||
export function getInactivePeriods(events: eventWithTime[], inactivePeriodThreshold: number) {
|
||||
const inactivePeriods: [number, number][] = [];
|
||||
let lastActiveTime = events[0].timestamp;
|
||||
for (const event of events) {
|
||||
if (!isUserInteraction(event)) continue;
|
||||
if (event.timestamp - lastActiveTime > SKIP_TIME_THRESHOLD) {
|
||||
if (event.timestamp - lastActiveTime > inactivePeriodThreshold) {
|
||||
inactivePeriods.push([lastActiveTime, event.timestamp]);
|
||||
}
|
||||
lastActiveTime = event.timestamp;
|
||||
|
||||
Reference in New Issue
Block a user