Daandelange / kirby3-simplestats

All your data are belong to us. -- Track pageviews, referrers and devices on your Kirby 3 website.
MIT License
60 stars 7 forks source link

Feature request: ignore localhost #18

Closed hannesherold closed 2 years ago

hannesherold commented 2 years ago

For development, it would be very helpful if the localhost environment was ignored.

For example, via a setting in plugins/simplestats/src/config/options.php: tracking => ignore => localhost => true (default).

In this context, it would also be useful if certain data could be deleted manually (for example, localhost).

Daandelange commented 2 years ago

Out of curiosity, why would you like to disable tracking on localhost ? (maybe I'm unaware of certain dev workflows) On my localhost pc, I'm using a different db file than online (different server), and I also like to know that (a different) tracking works correctly, for testing purposes. Maybe to ensure a local db (backup) doesn't get modified, but that it is still locally viewable trough the panel ? Should "not-tracking-localhost" be enabled by default as you suggest ?

Would this condition work ?

if( in_array($_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1')) ){ /* ... ignore ... */ }

As for data deletion, depending on what you mean, it will not be possible.

Daandelange commented 2 years ago

I have implemented something in 01914d6053e65450b4e2b9fd279e5f9565fd3dd9 It looks like it's working; feel free to re-open otherwise. It's not enabled by default (not-to-break stuff), that can still be discussed.

hannesherold commented 2 years ago

Thank you for addressing the issue! As an explanation of why I thought it made sense: In simple dev workflows, the entire public folder is uploaded via FTP - including the database.

Now that I think about it, it doesn't make much sense. Because once the website is online, the live database will no longer be replaced. So you're absolutely right, my problem won't even occur because you generally work locally with a different database than live.

Please excuse me for giving you unnecessary work!

Daandelange commented 2 years ago

Not unnecessary, the risk of altering your local db is reduced by enabling the option and I guess it's always very useful to be able to view stats without altering the database; for now it's the only way for visualising database files.