Copilot commented on code in PR #167:
URL: 
https://github.com/apache/skywalking-client-js/pull/167#discussion_r2579300378


##########
src/performance/index.ts:
##########
@@ -212,7 +212,7 @@ class TracePerf {
 
           if (interaction && (!len ||  this.inpList[len - 1].inpTime !== 
interaction.latency)) {

Review Comment:
   The comparison between `this.inpList[len - 1].inpTime` (floored value) and 
`interaction.latency` (raw value) may cause duplicate entries to be added when 
latency values have fractional milliseconds. Consider comparing floored values: 
`this.inpList[len - 1].inpTime !== Math.floor(interaction.latency)` to ensure 
consistent comparison.
   ```suggestion
             if (interaction && (!len ||  this.inpList[len - 1].inpTime !== 
Math.floor(interaction.latency))) {
   ```



##########
src/performance/index.ts:
##########
@@ -152,7 +152,7 @@ class TracePerf {
       });
       if (partValue > 0) {
         setTimeout(() => {
-          this.coreWebMetrics.clsTime = partValue;
+          this.coreWebMetrics.clsTime = Math.floor(partValue);

Review Comment:
   CLS (Cumulative Layout Shift) values are typically small decimals between 0 
and 1 (e.g., 0.05, 0.1, 0.25). Using `Math.floor()` will convert all CLS values 
less than 1 to 0, effectively destroying the metric's usefulness. Consider 
multiplying by a factor (e.g., 1000) before flooring to preserve precision: 
`Math.floor(partValue * 1000)`, or use `Math.round()` with a multiplier if 
integer values are required.
   ```suggestion
             this.coreWebMetrics.clsTime = Math.floor(partValue * 1000);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to