-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Record: Export a version of
isBlocked
that can be used without prov…
…iding config if recording has already started
- Loading branch information
1 parent
40bbc25
commit 38e251c
Showing
1 changed file
with
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,38 @@ | ||
import { record } from 'rrweb'; | ||
import { record as rrwebRecord, type recordOptions } from 'rrweb'; | ||
import { type listenerHandler, type eventWithTime } from '@rrweb/types'; | ||
|
||
export { record }; | ||
let currentOptions: recordOptions<eventWithTime> | null = null; | ||
|
||
function record( | ||
options: recordOptions<eventWithTime> = {}, | ||
): listenerHandler | undefined { | ||
// save what options were used | ||
currentOptions = options; | ||
return rrwebRecord(options); | ||
} | ||
|
||
/* | ||
* a public version of utils.isBlocked which can be used to check a node after a recording is started | ||
*/ | ||
function isBlocked( | ||
node: Node, | ||
options?: recordOptions<eventWithTime>, | ||
): boolean { | ||
if (options === undefined) { | ||
if (currentOptions === null) { | ||
throw new Error( | ||
'Either call after rrweb.record, or else pass in your recording config as the second argument', | ||
); | ||
} else { | ||
options = currentOptions; | ||
} | ||
} | ||
return utils.isBlocked( | ||
node, | ||
options.blockClass || 'rr-block', | ||
options.blockSelector || null, | ||
true, | ||
); | ||
} | ||
|
||
export { record, isBlocked }; |