diff --git a/packages/record/src/index.ts b/packages/record/src/index.ts index c2820aa1d2..e91634c12b 100644 --- a/packages/record/src/index.ts +++ b/packages/record/src/index.ts @@ -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 | null = null; + +function record( + options: recordOptions = {}, +): 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, +): 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 };