Skip to content
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

Export isBlocked alongside rrweb.record #1534

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
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 };
Loading