Skip to content

Commit

Permalink
Record: Export a version of isBlocked that can be used without prov…
Browse files Browse the repository at this point in the history
…iding config if recording has already started
  • Loading branch information
eoghanmurray committed Jul 12, 2024
1 parent 40bbc25 commit 38e251c
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions packages/record/src/index.ts
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 };

0 comments on commit 38e251c

Please sign in to comment.