fix: capture resource timing phases in web probe (#658)
Co-authored-by: Codex <codex@noreply.local>
This commit is contained in:
@@ -1026,6 +1026,29 @@ async function samplePage(reason) {
|
|||||||
rect: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) },
|
rect: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) },
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
const resourceTimingSample = (entry) => ({
|
||||||
|
name: entry.name.split(/[?#]/u)[0].slice(0, 240),
|
||||||
|
initiatorType: entry.initiatorType,
|
||||||
|
startTime: Math.round(entry.startTime),
|
||||||
|
duration: Math.round(entry.duration),
|
||||||
|
workerStart: Math.round(entry.workerStart || 0),
|
||||||
|
redirectStart: Math.round(entry.redirectStart || 0),
|
||||||
|
redirectEnd: Math.round(entry.redirectEnd || 0),
|
||||||
|
fetchStart: Math.round(entry.fetchStart || 0),
|
||||||
|
domainLookupStart: Math.round(entry.domainLookupStart || 0),
|
||||||
|
domainLookupEnd: Math.round(entry.domainLookupEnd || 0),
|
||||||
|
connectStart: Math.round(entry.connectStart || 0),
|
||||||
|
connectEnd: Math.round(entry.connectEnd || 0),
|
||||||
|
secureConnectionStart: Math.round(entry.secureConnectionStart || 0),
|
||||||
|
requestStart: Math.round(entry.requestStart || 0),
|
||||||
|
responseStart: Math.round(entry.responseStart || 0),
|
||||||
|
responseEnd: Math.round(entry.responseEnd || 0),
|
||||||
|
transferSize: Number.isFinite(Number(entry.transferSize)) ? Number(entry.transferSize) : null,
|
||||||
|
encodedBodySize: Number.isFinite(Number(entry.encodedBodySize)) ? Number(entry.encodedBodySize) : null,
|
||||||
|
decodedBodySize: Number.isFinite(Number(entry.decodedBodySize)) ? Number(entry.decodedBodySize) : null,
|
||||||
|
nextHopProtocol: entry.nextHopProtocol || null,
|
||||||
|
responseStatus: Number.isFinite(Number(entry.responseStatus)) ? Number(entry.responseStatus) : null,
|
||||||
|
});
|
||||||
const url = location.href;
|
const url = location.href;
|
||||||
const routeSessionMatch = url.match(/\/workbench\/sessions\/([^/?#]+)/u);
|
const routeSessionMatch = url.match(/\/workbench\/sessions\/([^/?#]+)/u);
|
||||||
const activeSession = document.querySelector('[data-active="true"][data-session-id], [aria-selected="true"][data-session-id], .active[data-session-id]');
|
const activeSession = document.querySelector('[data-active="true"][data-session-id], [aria-selected="true"][data-session-id], .active[data-session-id]');
|
||||||
@@ -1133,7 +1156,7 @@ async function samplePage(reason) {
|
|||||||
content: String(element.getAttribute("content") || "").slice(0, 200),
|
content: String(element.getAttribute("content") || "").slice(0, 200),
|
||||||
})).filter((item) => item.key).sort((a, b) => a.key.localeCompare(b.key)),
|
})).filter((item) => item.key).sort((a, b) => a.key.localeCompare(b.key)),
|
||||||
},
|
},
|
||||||
performance: performance.getEntriesByType("resource").slice(-30).map((entry) => ({ name: entry.name.split(/[?#]/u)[0].slice(0, 240), initiatorType: entry.initiatorType, startTime: Math.round(entry.startTime), duration: Math.round(entry.duration) })),
|
performance: performance.getEntriesByType("resource").slice(-80).map(resourceTimingSample),
|
||||||
};
|
};
|
||||||
}).catch((error) => ({ error: errorSummary(error), url: currentPageUrl() }));
|
}).catch((error) => ({ error: errorSummary(error), url: currentPageUrl() }));
|
||||||
const sample = {
|
const sample = {
|
||||||
|
|||||||
Reference in New Issue
Block a user