From eeac998959140db19c99c163dbed9cb4dcd0e7c7 Mon Sep 17 00:00:00 2001 From: Province Innovation <69924001+provinceinnovation@users.noreply.github.com> Date: Wed, 1 Apr 2026 12:00:00 +0800 Subject: [PATCH] Added mousemoveCallback threshold option to sampling config. (#492) * Added mousemoveCallback threshold option to sampling config. * Added mousemoveCallback to definitions file. --- src/record/observer.ts | 4 +++- src/types.ts | 4 ++++ typings/types.d.ts | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/record/observer.ts b/src/record/observer.ts index d71a8b0f..a3f1624b 100644 --- a/src/record/observer.ts +++ b/src/record/observer.ts @@ -131,6 +131,8 @@ function initMoveObserver( const threshold = typeof sampling.mousemove === 'number' ? sampling.mousemove : 50; + const callbackThreshold = + typeof sampling.mousemoveCallback === 'number' ? sampling.mousemoveCallback : 500; let positions: mousePosition[] = []; let timeBaseline: number | null; @@ -145,7 +147,7 @@ function initMoveObserver( ); positions = []; timeBaseline = null; - }, 500); + }, callbackThreshold); const updatePosition = throttle( (evt) => { const { target } = evt; diff --git a/src/types.ts b/src/types.ts index 907aea78..cdcc4164 100644 --- a/src/types.ts +++ b/src/types.ts @@ -165,6 +165,10 @@ export type SamplingStrategy = Partial<{ */ mousemove: boolean | number; /** + * number is the throttle threshold of mouse/touch move callback + */ + mousemoveCallback: number; + /** * false means not to record mouse interaction events * can also specify record some kinds of mouse interactions */ diff --git a/typings/types.d.ts b/typings/types.d.ts index d9671729..f29286cf 100644 --- a/typings/types.d.ts +++ b/typings/types.d.ts @@ -111,6 +111,7 @@ export declare type eventWithTime = event & { export declare type blockClass = string | RegExp; export declare type SamplingStrategy = Partial<{ mousemove: boolean | number; + mousemoveCallback: number; mouseInteraction: boolean | Record; scroll: number; input: 'all' | 'last';