Include only the worst requests in HAR export
This commit is contained in:
parent
7527288d95
commit
acaa9430a1
|
@ -303,4 +303,8 @@ export default class ExtendedRequest {
|
||||||
connection: "443",
|
connection: "443",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getMaxPriority() {
|
||||||
|
return Math.max(...this.stolenData.map((entry) => entry.getPriority()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,9 +22,36 @@ function handleNewFile(
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateFakeHAR(entries: StolenDataEntry[]) {
|
function generateFakeHAR(entries: StolenDataEntry[]) {
|
||||||
const requests = entries
|
const requests = unique(entries.map((entry) => entry.request))
|
||||||
.sort((entry1, entry2) => entry2.getPriority() - entry1.getPriority())
|
.sort((request1, request2) => {
|
||||||
.map((entry) => entry.request);
|
if (request1.shorthost < request2.shorthost) {
|
||||||
|
return -1;
|
||||||
|
} else if (request1.shorthost > request2.shorthost) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return request2.getMaxPriority() - request1.getMaxPriority();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.filter((_, index, array) => {
|
||||||
|
if (index !== 0 && array[index].shorthost == array[index - 1].shorthost) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
.sort(
|
||||||
|
(entry1, entry2) => entry2.getMaxPriority() - entry1.getMaxPriority()
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
"GENERATEHAR! Got",
|
||||||
|
entries.length,
|
||||||
|
"entries, ",
|
||||||
|
unique(entries.map((e) => e.request)),
|
||||||
|
"requests. Filtered down to",
|
||||||
|
requests.length,
|
||||||
|
"requests"
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
log: {
|
log: {
|
||||||
version: "1.2",
|
version: "1.2",
|
||||||
|
@ -47,7 +74,7 @@ function generateFakeHAR(entries: StolenDataEntry[]) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
entries: unique(requests).map((r) => r.toHAR()),
|
entries: requests.map((r) => r.toHAR()),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user