Skip to content

Reduce statistics visits and visitors identifiability#863

Merged
giuscris merged 2 commits into2.xfrom
refactor/reduce-statistics-identifiability
Mar 1, 2026
Merged

Reduce statistics visits and visitors identifiability#863
giuscris merged 2 commits into2.xfrom
refactor/reduce-statistics-identifiability

Conversation

@giuscris
Copy link
Member

@giuscris giuscris commented Mar 1, 2026

This pull request updates the visitor tracking logic in the Statistics module to improve uniqueness and future-proof the identification of visitors. The main changes focus on replacing the legacy IP-based visitor keys with a new approach that incorporates the date and user agent, and introduces a migration step to handle existing data. In this way, visitors become less identifiable over time, as the anonymized IP address and user agent are hashed together with the current date, producing rotating, non-persistent identifiers instead of stable tracking keys.

Visitor tracking improvements:

  • Visitor hash generation now includes the date, anonymized IP, URI, and user agent, making visitor identification more robust and less reliant solely on IP address. (formwork/src/Statistics/Statistics.php, formwork/src/Statistics/Statistics.phpR64-R72)
  • Visitor registry keys are now based on a hash of the date, IP, and user agent, rather than just the IP, which helps reduce false positives for unique visits. (formwork/src/Statistics/Statistics.php, formwork/src/Statistics/Statistics.phpL82-R104)

Legacy data migration:

  • Added logic to migrate legacy visitor keys based on IP to the new hash-based format, ensuring backward compatibility and a smooth transition. This migration code is marked for removal in a future major release. (formwork/src/Statistics/Statistics.php, formwork/src/Statistics/Statistics.phpL82-R104)

@giuscris giuscris requested a review from Copilot March 1, 2026 16:24
@giuscris giuscris self-assigned this Mar 1, 2026
@giuscris giuscris added the enhancement New feature or request label Mar 1, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Formwork’s Statistics visitor tracking to reduce long-lived visitor identifiability by rotating identifiers (daily) and incorporating the user agent, while migrating existing visitor registry entries keyed by anonymized IP.

Changes:

  • Include $date and $userAgent in the per-page session hash used for visit de-duplication.
  • Replace legacy IP-based visitor registry keys with a daily rotating hash of date + anonymized IP + user agent.
  • Add an in-place migration step to convert existing visitors entries from $ip keys to the new hashed keys.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@giuscris giuscris merged commit 6f1c241 into 2.x Mar 1, 2026
1 check passed
@giuscris giuscris deleted the refactor/reduce-statistics-identifiability branch March 1, 2026 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants