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';