Open-Measurement-JSClients icon indicating copy to clipboard operation
Open-Measurement-JSClients copied to clipboard

id for setTimeout and setInterval are prone to errors

Open luiza-cicone opened this issue 1 year ago • 0 comments

Hello,

We are using the verification client setTimeout method to compute a custom viewability. As it is using an internal generation of id's (starting at 0) it is prone to errors as it is using a falsy value and so we need to explicitly check against undefined if (timeoutId !== undefined) { ... } instead of if(timeoutId) { ... }

I can suggest a PR where we change the id returned to start at 1. WDYT? https://github.com/InteractiveAdvertisingBureau/Open-Measurement-JSClients/blob/master/src/verification-client/verification-client.js#L381

Thanks!

luiza-cicone avatar Apr 19 '24 14:04 luiza-cicone