Open kandros opened 5 months ago
First off, thank you for picking up an issue and contributing. 🙏
Does it cover your usecase @benvinegar?
Some thoughts that come to mind:
127.0.0.1
too.You're welcome to try adding that; if you do, I'd look at prior art from other analytics tracking scripts and see what other folks do. For example, Plausible had a ticket around this and has since made it possible to track local scripts.
All of this makes the issue more complicated than at first blush (my fault for not clarifying more).
@kandros I think updating it with this condition, gonna fix all possible localhost
scenarios
if (/^localhost$|^127(?:\.[0-9]+){0,2}\.[0-9]+$|^(?:0*\:)*?:?0*1$/.test(window.location.hostname)) {
console.warn("[counterscale] localhost detected, datapoints will not be collected");
return;
}
fixes #50
I opted for skipping sending the request instead of rejecting it in
collectRequestHandler
Does it cover your usecase @benvinegar?