mask input options and sampling options (#252)

* part of #80, support mask input options

* close #188 enhance sampling options
Use a more general sampling strategy interface to describe the
configuration of sampling events collection.

Implemented mousmove, mouse interaction, scroll and input sampling
strategy.
This commit is contained in:
yz-yu
2020-07-18 15:05:19 +08:00
committed by GitHub
parent 286b520907
commit 7de7eb5e54
8 changed files with 888 additions and 93 deletions

View File

@@ -1,4 +1,9 @@
import { serializedNodeWithId, idNodeMap, INode } from 'rrweb-snapshot';
import {
serializedNodeWithId,
idNodeMap,
INode,
MaskInputOptions,
} from 'rrweb-snapshot';
import { PackFn, UnpackFn } from './packer/base';
export enum EventType {
@@ -126,6 +131,28 @@ export type eventWithTime = event & {
export type blockClass = string | RegExp;
export type SamplingStrategy = Partial<{
/**
* false means not to record mouse/touch move events
* number is the throttle threshold of recording mouse/touch move
*/
mousemove: boolean | number;
/**
* false means not to record mouse interaction events
* can also specify record some kinds of mouse interactions
*/
mouseInteraction: boolean | Record<string, boolean | undefined>;
/**
* number is the throttle threshold of recording scroll
*/
scroll: number;
/**
* 'all' will record all the input events
* 'last' will only record the last input value while input a sequence of chars
*/
input: 'all' | 'last';
}>;
export type recordOptions<T> = {
emit?: (e: T, isCheckout?: boolean) => void;
checkoutEveryNth?: number;
@@ -133,10 +160,13 @@ export type recordOptions<T> = {
blockClass?: blockClass;
ignoreClass?: string;
maskAllInputs?: boolean;
maskInputOptions?: MaskInputOptions;
inlineStylesheet?: boolean;
hooks?: hooksParam;
mousemoveWait?: number;
packFn?: PackFn;
sampling?: SamplingStrategy;
// departed, please use sampling options
mousemoveWait?: number;
};
export type observerParam = {
@@ -149,10 +179,10 @@ export type observerParam = {
mediaInteractionCb: mediaInteractionCallback;
blockClass: blockClass;
ignoreClass: string;
maskAllInputs: boolean;
maskInputOptions: MaskInputOptions;
inlineStylesheet: boolean;
styleSheetRuleCb: styleSheetRuleCallback;
mousemoveWait: number;
sampling: SamplingStrategy;
};
export type hooksParam = {