Skip to content

Commit 1730d49

Browse files
committed
fix performance reset bug
1 parent f6a6d2c commit 1730d49

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/queries/sql/reports/getPerformance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ async function clickhouseQuery(
138138
const chart = await rawQuery<{ t: string; p50: number; p75: number; p95: number }[]>(
139139
`
140140
select
141-
${getDateSQL('created_at', 'minute', timezone)} t,
141+
${getDateSQL('created_at', unit, timezone)} t,
142142
quantile(0.5)(${metric}) as p50,
143143
quantile(0.75)(${metric}) as p75,
144144
quantile(0.95)(${metric}) as p95

src/tracker/index.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,17 @@
331331
send({ ...getPayload(), ...metrics }, 'performance');
332332
};
333333

334-
flushPerformance = sendPerformance;
334+
flushPerformance = () => {
335+
sendPerformance();
336+
Object.keys(metrics).forEach(k => {
337+
delete metrics[k];
338+
});
339+
clsValue = 0;
340+
inpValue = 0;
341+
sent = false;
342+
if (timeoutId) clearTimeout(timeoutId);
343+
timeoutId = setTimeout(sendPerformance, 10000);
344+
};
335345
timeoutId = setTimeout(sendPerformance, 10000);
336346

337347
document.addEventListener('visibilitychange', () => {

0 commit comments

Comments
 (0)