Skip to content

fix(replay): Add missing rrweb type declarations #6464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/replay/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { eventWithTime, recordOptions } from 'rrweb/typings/types';
import type { eventWithTime, recordOptions } from './types/rrweb';

export type RecordingEvent = eventWithTime;
export type RecordingOptions = recordOptions<eventWithTime>;
export type RecordingOptions = recordOptions;

export type RecordedEvents = Uint8Array | string;

Expand Down
38 changes: 38 additions & 0 deletions packages/replay/src/types/rrweb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* eslint-disable @typescript-eslint/naming-convention */

type blockClass = string | RegExp;
type maskTextClass = string | RegExp;

enum EventType {
DomContentLoaded = 0,
Load = 1,
FullSnapshot = 2,
IncrementalSnapshot = 3,
Meta = 4,
Custom = 5,
Plugin = 6,
}

/**
* This is a partial copy of rrweb's eventWithTime type which only contains the properties
* we specifcally need in the SDK.
*/
export type eventWithTime = {
type: EventType;
data: unknown;
timestamp: number;
delay?: number;
};

/**
* This is a partial copy of rrweb's recording options which only contains the properties
* we specifically us in the SDK. Users can specify additional properties, hence we add the
* Record<string, unknown> union type.
*/
export type recordOptions = {
maskAllInputs?: boolean;
blockClass?: blockClass;
ignoreClass?: string;
maskTextClass?: maskTextClass;
blockSelector?: string;
} & Record<string, unknown>;