tracker: changes to resource fails tracking

This commit is contained in:
nick-delirium 2024-12-18 14:48:54 +01:00
parent b6080b2492
commit 3b68bebf40
No known key found for this signature in database
GPG key ID: 93ABD695DF5FDBA0
3 changed files with 25 additions and 3 deletions

View file

@ -129,14 +129,14 @@ export const Resource = (resource: IResource) => {
export function getResourceFromResourceTiming(msg: ResourceTiming, sessStart: number) {
// duration might be duration=0 when cached
const success = msg.duration > 0 || msg.encodedBodySize > 0 || msg.transferredSize > 0
const failed = msg.duration === 0 && msg.ttfb === 0 && msg.headerSize === 0 && msg.encodedBodySize === 0 && msg.transferredSize === 0
const type = getResourceType(msg.initiator, msg.url)
return Resource({
...msg,
type,
method: type === ResourceType.FETCH ? ".." : "GET", // should be GET for all non-XHR/Fetch resources, right?
success,
status: success ? '2xx-3xx' : '4xx-5xx',
success: !failed,
status: !failed ? '2xx-3xx' : '4xx-5xx',
time: Math.max(0, msg.timestamp - sessStart)
})
}

View file

@ -1,3 +1,8 @@
## 15.0.4
- support for spritemaps (svg with `use` tags)
- improvements for missing resources tracking
## 15.0.3
- fixing `failuresOnly` option for network

View file

@ -121,6 +121,23 @@ export default function (app: App, opts: Partial<Options>): void {
if (shouldSkip) {
return
}
const failed = entry.responseEnd === 0 && entry.transferSize === 0
if (failed) {
app.send(
ResourceTiming(
entry.startTime + getTimeOrigin(),
0,
0,
0,
0,
0,
entry.name,
entry.initiatorType,
0,
true,
),
)
}
app.send(
ResourceTiming(
entry.startTime + getTimeOrigin(),