Add options to mask texts (#540)

* feat: add options to mask texts

* feat: add the default mask function

* refactor: rename options to identify the difference between  mask text and mask input

* test: add tests about masking

* doc: add options about masking

* chore: bump up rrweb-snapshot version
This commit is contained in:
re-fort
2026-04-01 12:00:00 +08:00
committed by GitHub
parent 861fac54ea
commit b1b25447ff
12 changed files with 895 additions and 10 deletions

View File

@@ -163,6 +163,8 @@ export type eventWithTime = event & {
export type blockClass = string | RegExp;
export type maskTextClass = string | RegExp;
export type SamplingStrategy = Partial<{
/**
* false means not to record mouse/touch move events
@@ -196,9 +198,12 @@ export type recordOptions<T> = {
blockClass?: blockClass;
blockSelector?: string;
ignoreClass?: string;
maskTextClass?: maskTextClass;
maskTextSelector?: string;
maskAllInputs?: boolean;
maskInputOptions?: MaskInputOptions;
maskInputFn?: MaskInputFn;
maskTextFn?: MaskTextFn;
slimDOMOptions?: SlimDOMOptions | 'all' | true;
inlineStylesheet?: boolean;
hooks?: hooksParam;
@@ -222,8 +227,11 @@ export type observerParam = {
blockClass: blockClass;
blockSelector: string | null;
ignoreClass: string;
maskTextClass: maskTextClass;
maskTextSelector: string | null;
maskInputOptions: MaskInputOptions;
maskInputFn?: MaskInputFn;
maskTextFn?: MaskTextFn;
inlineStylesheet: boolean;
styleSheetRuleCb: styleSheetRuleCallback;
canvasMutationCb: canvasMutationCallback;
@@ -583,6 +591,8 @@ export enum ReplayerEvents {
export type MaskInputFn = (text: string) => string;
export type MaskTextFn = (text: string) => string;
// store the state that would be changed during the process(unmount from dom and mount again)
export type ElementState = {
// [scrollLeft,scrollTop]