Skip to content
Merged
1,090 changes: 1,089 additions & 1 deletion server/src/browser-management/classes/RemoteBrowser.ts

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions server/src/browser-management/classes/bundle-rrweb.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const esbuild = require('esbuild');

esbuild.build({
entryPoints: ['rrweb-entry.js'],
bundle: true,
minify: true,
outfile: 'rrweb-bundle.js',
format: 'iife', // so that rrwebSnapshot is available on window
globalName: 'rrwebSnapshotBundle'
}).catch(() => process.exit(1));
1 change: 1 addition & 0 deletions server/src/browser-management/classes/rrweb-bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions server/src/browser-management/classes/rrweb-entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { snapshot } from 'rrweb-snapshot';
window.rrwebSnapshot = { snapshot };
12 changes: 10 additions & 2 deletions server/src/browser-management/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import logger from "../logger";
* @returns string
* @category BrowserManagement-Controller
*/
export const initializeRemoteBrowserForRecording = (userId: string): string => {
export const initializeRemoteBrowserForRecording = (userId: string, mode: string = "dom"): string => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add type annotation for the mode parameter.

The mode parameter should be typed for better type safety and API clarity.

-export const initializeRemoteBrowserForRecording = (userId: string, mode: string = "dom"): string => {
+export const initializeRemoteBrowserForRecording = (userId: string, mode: "dom" | "screenshot" = "dom"): string => {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export const initializeRemoteBrowserForRecording = (userId: string, mode: string = "dom"): string => {
export const initializeRemoteBrowserForRecording = (userId: string, mode: "dom" | "screenshot" = "dom"): string => {
🤖 Prompt for AI Agents
In server/src/browser-management/controller.ts at line 23, the mode parameter in
the initializeRemoteBrowserForRecording function lacks a type annotation. Add an
explicit type annotation to the mode parameter, such as a string literal union
type or a specific string type, to improve type safety and clarify the expected
values for this parameter.

const id = getActiveBrowserIdByState(userId, "recording") || uuid();
createSocketConnection(
io.of(id),
Expand All @@ -37,7 +37,15 @@ export const initializeRemoteBrowserForRecording = (userId: string): string => {
browserSession.interpreter.subscribeToPausing();
await browserSession.initialize(userId);
await browserSession.registerEditorEvents();
await browserSession.subscribeToScreencast();

if (mode === "dom") {
await browserSession.subscribeToDOM();
logger.info('DOM streaming started for scraping browser in recording mode');
} else {
await browserSession.subscribeToScreencast();
logger.info('Screenshot streaming started for local browser in recording mode');
}

browserPool.addRemoteBrowser(id, browserSession, userId, false, "recording");
}
socket.emit('loaded');
Expand Down
Loading