Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(replay): Add missing rrweb type declarations (#6464)
To generate type declarations, we use `tsc` (`yarn build:types`) which doesn't pull external type declarations into the resulting `.d.ts` files. We import types from rrweb which our internal types rely on. Because we now vendor rrweb, the rrweb-internal types are no longer getting installed in our users node_modules, producing typescript errors when they build their projects. To hotfix this, this PR vendors a "light" version of the two rrweb types we use.
- Loading branch information
Showing
2 changed files
with
40 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>; |