feat: inject rrweb in browser context

This commit is contained in:
Karishma Shukla
2025-06-30 15:09:24 +05:30
committed by GitHub
parent 64d53fd5df
commit 3ccf58cdce

View File

@@ -670,7 +670,7 @@ export class RemoteBrowser {
}; };
return { return {
snapshot: processedSnapshot, snapshot: snapshot,
resources, resources,
baseUrl, baseUrl,
viewport, viewport,
@@ -1253,11 +1253,11 @@ export class RemoteBrowser {
patchedGetter.apply(navigator); patchedGetter.apply(navigator);
patchedGetter.toString();` patchedGetter.toString();`
); );
this.currentPage = await this.context.newPage();
await this.currentPage.addInitScript({ path: './server/src/browser-management/classes/rrweb-bundle.js' }); await this.currentPage.addInitScript({ path: './server/src/browser-management/classes/rrweb-bundle.js' });
this.currentPage = await this.context.newPage();
await this.setupPageEventListeners(this.currentPage); await this.setupPageEventListeners(this.currentPage);
const viewportSize = await this.currentPage.viewportSize(); const viewportSize = await this.currentPage.viewportSize();
@@ -2221,7 +2221,10 @@ export class RemoteBrowser {
if (typeof window.rrwebSnapshot === "undefined") { if (typeof window.rrwebSnapshot === "undefined") {
throw new Error("rrweb-snapshot library not available"); throw new Error("rrweb-snapshot library not available");
} }
return window.rrwebSnapshot.snapshot(document); return window.rrwebSnapshot.snapshot(document, {
inlineImages: true,
collectFonts: true,
});
}); });
// Process the snapshot to proxy resources // Process the snapshot to proxy resources
@@ -2479,8 +2482,6 @@ export class RemoteBrowser {
await this.currentPage?.close(); await this.currentPage?.close();
this.currentPage = newPage; this.currentPage = newPage;
if (this.currentPage) { if (this.currentPage) {
await this.currentPage.addInitScript({ path: './server/src/browser-management/classes/rrweb-bundle.js' });
await this.setupPageEventListeners(this.currentPage); await this.setupPageEventListeners(this.currentPage);
this.client = await this.currentPage.context().newCDPSession(this.currentPage); this.client = await this.currentPage.context().newCDPSession(this.currentPage);