fix performance reset bug

This commit is contained in:
Francis Cao
2026-03-05 10:23:00 -08:00
parent f6a6d2cc31
commit 1730d495e5
2 changed files with 12 additions and 2 deletions
+1 -1
View File
@@ -138,7 +138,7 @@ async function clickhouseQuery(
const chart = await rawQuery<{ t: string; p50: number; p75: number; p95: number }[]>(
`
select
${getDateSQL('created_at', 'minute', timezone)} t,
${getDateSQL('created_at', unit, timezone)} t,
quantile(0.5)(${metric}) as p50,
quantile(0.75)(${metric}) as p75,
quantile(0.95)(${metric}) as p95
+11 -1
View File
@@ -331,7 +331,17 @@
send({ ...getPayload(), ...metrics }, 'performance');
};
flushPerformance = sendPerformance;
flushPerformance = () => {
sendPerformance();
Object.keys(metrics).forEach(k => {
delete metrics[k];
});
clsValue = 0;
inpValue = 0;
sent = false;
if (timeoutId) clearTimeout(timeoutId);
timeoutId = setTimeout(sendPerformance, 10000);
};
timeoutId = setTimeout(sendPerformance, 10000);
document.addEventListener('visibilitychange', () => {