From 1a6a3b7ba2c881ef7191e0506fe49944781c7eec Mon Sep 17 00:00:00 2001 From: Fine0830 Date: Tue, 2 Dec 2025 09:43:59 +0800 Subject: [PATCH 1/5] change perf data to integer --- src/performance/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/performance/index.ts b/src/performance/index.ts index 0901bd8..638e0d9 100644 --- a/src/performance/index.ts +++ b/src/performance/index.ts @@ -152,7 +152,7 @@ class TracePerf { }); if (partValue > 0) { setTimeout(() => { - this.coreWebMetrics.clsTime = partValue; + this.coreWebMetrics.clsTime = Math.floor(partValue); }, 3000); } }; @@ -212,7 +212,7 @@ class TracePerf { if (interaction && (!len || this.inpList[len - 1].inpTime !== interaction.latency)) { const param = { - inpTime: interaction.latency, + inpTime: Math.floor(interaction.latency), ...this.perfInfo, }; this.inpList.push(param); From 44643a851ab7d5a30c9fca434f777d8ede3b9e03 Mon Sep 17 00:00:00 2001 From: Fine0830 Date: Tue, 2 Dec 2025 09:51:22 +0800 Subject: [PATCH 2/5] Update src/performance/index.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/performance/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/performance/index.ts b/src/performance/index.ts index 638e0d9..b80a6cf 100644 --- a/src/performance/index.ts +++ b/src/performance/index.ts @@ -210,7 +210,7 @@ class TracePerf { const interaction = getLongestInteraction(); const len = this.inpList.length; - if (interaction && (!len || this.inpList[len - 1].inpTime !== interaction.latency)) { + if (interaction && (!len || this.inpList[len - 1].inpTime !== Math.floor(interaction.latency))) { const param = { inpTime: Math.floor(interaction.latency), ...this.perfInfo, From 23e789ee1c8c18ab499859abc9f560f717cb41be Mon Sep 17 00:00:00 2001 From: Fine0830 Date: Tue, 2 Dec 2025 09:58:32 +0800 Subject: [PATCH 3/5] update --- src/performance/index.ts | 15 +++++++++------ src/performance/type.ts | 7 +++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/performance/index.ts b/src/performance/index.ts index 638e0d9..6384f2a 100644 --- a/src/performance/index.ts +++ b/src/performance/index.ts @@ -21,7 +21,7 @@ import {prerenderChangeListener, onHidden, runOnce, idlePeriod} from '../service import pagePerf from './perf'; import FMP from './fmp'; import {observe} from '../services/observe'; -import {LCPMetric, INPMetric, CLSMetric} from './type'; +import {LCPMetric, INPMetric, CLSMetric, INPListItem} from './type'; import {LayoutShift} from '../services/types'; import {getVisibilityObserver} from '../services/getVisibilityObserver'; import {getActivationStart, getResourceEntry} from '../services/getEntries'; @@ -58,7 +58,7 @@ class TracePerf { private perfInfo = {}; private coreWebMetrics: Record = {}; private resources: {name: string, duration: number, size: number, protocol: string, resourceType: string}[] = []; - private inpList: Record[] = []; + private inpList: INPListItem[] = []; public getPerf(options: CustomOptionsType) { this.options = options; this.perfInfo = { @@ -152,7 +152,7 @@ class TracePerf { }); if (partValue > 0) { setTimeout(() => { - this.coreWebMetrics.clsTime = Math.floor(partValue); + this.coreWebMetrics.clsTime = partValue > 1 ? Math.floor(partValue) : Math.round(partValue); }, 3000); } }; @@ -212,9 +212,9 @@ class TracePerf { if (interaction && (!len || this.inpList[len - 1].inpTime !== interaction.latency)) { const param = { - inpTime: Math.floor(interaction.latency), + inpTime: interaction.latency, ...this.perfInfo, - }; + } as INPListItem; this.inpList.push(param); } }) @@ -242,7 +242,10 @@ class TracePerf { if (!this.inpList.length) { return; } - + this.inpList = this.inpList.map((item: INPListItem) => ({ + ...item, + inpTime: item.inpTime > 1 ? Math.floor(item.inpTime) : Math.round(item.inpTime), + })); new Report('WEBINTERACTIONS', this.options.collector).sendByBeacon(this.inpList); } private getBasicPerf() { diff --git a/src/performance/type.ts b/src/performance/type.ts index a6ef5c0..87c2aba 100644 --- a/src/performance/type.ts +++ b/src/performance/type.ts @@ -54,3 +54,10 @@ export interface CLSMetric { name: 'CLS'; entries: LayoutShift[]; } + +export interface INPListItem { + inpTime: number; + service: string; + serviceVersion: string; + pagePath: string; +} \ No newline at end of file From f28bda5d4a8e6600c28db9a220099c9f78da97d2 Mon Sep 17 00:00:00 2001 From: Fine0830 Date: Tue, 2 Dec 2025 10:00:27 +0800 Subject: [PATCH 4/5] revert --- src/performance/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/performance/index.ts b/src/performance/index.ts index 4852116..6384f2a 100644 --- a/src/performance/index.ts +++ b/src/performance/index.ts @@ -210,7 +210,7 @@ class TracePerf { const interaction = getLongestInteraction(); const len = this.inpList.length; - if (interaction && (!len || this.inpList[len - 1].inpTime !== Math.floor(interaction.latency))) { + if (interaction && (!len || this.inpList[len - 1].inpTime !== interaction.latency)) { const param = { inpTime: interaction.latency, ...this.perfInfo, From 9ff827fcd4d07f3de2a52f92f2edc55f2b5eb017 Mon Sep 17 00:00:00 2001 From: Fine0830 Date: Tue, 2 Dec 2025 10:08:19 +0800 Subject: [PATCH 5/5] fix --- src/performance/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/performance/index.ts b/src/performance/index.ts index 6384f2a..cda620d 100644 --- a/src/performance/index.ts +++ b/src/performance/index.ts @@ -242,11 +242,11 @@ class TracePerf { if (!this.inpList.length) { return; } - this.inpList = this.inpList.map((item: INPListItem) => ({ + const inpList = this.inpList.map((item: INPListItem) => ({ ...item, inpTime: item.inpTime > 1 ? Math.floor(item.inpTime) : Math.round(item.inpTime), })); - new Report('WEBINTERACTIONS', this.options.collector).sendByBeacon(this.inpList); + new Report('WEBINTERACTIONS', this.options.collector).sendByBeacon(inpList); } private getBasicPerf() { // auto report pv and perf data