arnoson / kirby-stats

Simple and privacy friendly web statistics for Kirby CMS.
MIT License
8 stars 0 forks source link

K4 compatibility, database creation #14

Closed grommasdietz closed 8 months ago

grommasdietz commented 9 months ago

Hi Arno

I was searching for a reduced and privacy friendly way of handling statistics. Your plugin looks promising! Is it already working with Kirby 4?

While I would like to check that by myself, I don’t quite understand how to setup the database right. Neither the example folder nor the documentation is giving any hint. Maybe the database is excluded with .gitignore by accident? Or should it be created? Anyway, I appreciate any hints and your help.

Thanks in advance Jakob

arnoson commented 9 months ago

Hi Jakob

I have a test page running with this plugin and Kirby 4.0.0 and everythings seems to work!

The database uses sqlite which is created automatically if it doesn't exist. You can configure the path where the sqlite file will be created here. Also any tables are created automatically.

I should definitely improve documentation. Right now everything is still in early stages, although the basic functionality is working. The biggest downside is the mediocre bot filtering. I'll be on parental leave the next months, but I plan to spend more time developing this plugin in 2024, as I also really need a privacy friendly self hosted analytics for kirby.

grommasdietz commented 9 months ago

Thanks for your fast response. The problem on my setup was, that it has a structure with separate public folder. We can pretty easy support this by using:

'sqlite' => kirby()->root('site') . '/plugins/kirby-stats/stats.sqlite',

However, this only works when defined in index.php, not in kirby config, so I’ll create a pull request.

arnoson commented 9 months ago

I also use it mainly in public folder setups, but didn't know about the site root! I always ended up putting the sqlite in the base folder in this case. Do you think the plugin folder is a good default path? When updating the plugin it might get removed, not sure how composer behaves exactly.

arnoson commented 9 months ago

If you wan't to use the kirby roots in the config you can also use the config's ready hook

grommas commented 9 months ago

Same thoughts! Maybe a logs folder inside site?

arnoson commented 9 months ago

Logs might suggest that it is a folder containing temporary/unimportant files that are save to delete (at least this somehow is my association with the term). What about trying if there is a storage root as suggested in the public folder setup and than either store it there or in a storage folder in site for flat folder setups.

'sqlite' => kirby()->root('storage')
  ? kirby()->root('storage') . '/stats.sqlite'
  : kirby()->root('site') . '/storage/stats.sqlite'