News for hackers. Stuff that matters.
Re:Bear Does Analytics with CSS by TekMol on Wednesday November 01, 2023 @05:55AM (#38096336)
That is easy to fix though. Just use a temporary salt.

Pseudo code:

    if salt.day < today():
        salt = {day: today(), salt: random()}
    ip_hash = sha256(ip + salt.salt)
Re:Bear Does Analytics with CSS by __alexs on Wednesday November 01, 2023 @06:54AM (#38096703)
Assuming you don't store the salts, this produces a value that is useless for anything but counting something like DAU. Which you could equally just do by counting them all and deleting all the data at the end of the day, or using a cardinality estimator like HLL.
Re:Bear Does Analytics with CSS by TekMol on Wednesday November 01, 2023 @08:34AM (#38097380)
DAU in regards to a given page.

Have you read the article? That is what the author's goal seems to be.

He wants to prevent multiple requests to the same page by the same IP counted multiple times.

Re:Bear Does Analytics with CSS by tatersolid on Wednesday November 01, 2023 @05:53PM (#38105840)
Is that more efficiently done with an appropriate caching header on the page as it is served?

Cache-Control: private, max-age=86400

This prevents repeat requests for normal browsers from hitting the server.

Re:Bear Does Analytics with CSS by dvdkon on Wednesday November 01, 2023 @09:42AM (#38098061)
That same uselessness for long-term identification of users is what makes this approach compliant with laws regulating use of PII, since what you have after a small time window isn't actually PII (unless correlated with another dataset, but that's always the case).
Re:Bear Does Analytics with CSS by SamBam on Wednesday November 01, 2023 @11:14AM (#38099344)
That's precisely all that OP is storing in the original article.

They're just getting a list of hashes per day, and associated client info. They have no idea if the same user visit them on multiple days, because the hashes will be different.

Re:Bear Does Analytics with CSS by kevincox on Wednesday November 01, 2023 @09:18AM (#38097797)
Of course if you have multiple severs or may reboot you need to store the salt somewhere. If you are going to bother storing the salt and cleaning it up after the day is over it may be just as easy to clean the hashes at the end of the day (and keep the total count) which is equivalent. This should work unless you want to keep individual counts around for something like seeing distribution of requests per IP or similar. But in that case you could just replace the hashes with random values at the end of the day to fully anonymize them since you no longer need to increment then.