analytics
analytics copied to clipboard
Reset goal stats
Changes
This pull request adds new button in Site > Settings > Goals to reset goals by deleting all related events. This was suggested in https://github.com/plausible/analytics/discussions/186.

Tests
- [x] Automated tests have been added
Changelog
- [x] Entry has been added to changelog
Documentation
- [x] Docs have been updated (link: https://github.com/plausible/docs/pull/247)
Dark mode
- [x] The UI has been tested both in dark and light mode
Nice one @vinibrsl, thanks!
This was a fun exercise, but I would like to discuss first whether hard deletes is the right way here. The use-case for deleting data is much broader than this PR:
People often want to remove tracking from a page whose URL was supposed to stay secret, for example. Or maybe a bot generated a bunch of bad data that needs to be cleared. Or maybe they sent data from a dev environment and want to clear that.
Beyond resetting goals, the more common use-case would be:
- Filter your dashboard by some filters
- Remove only the data that matches those filters
Currently we do hard deletes through the database CLI for these manually. I'd love for customers to be able to do it themselves but giving people the power to remove data is dangerous with hard deletes. I can imagine our support being swarmed by people wanting to recover data they accidentally deleted. It should be possible to UNDO a delete for a while after it was run.
Basically, I think we need to implement soft deletes before shipping this feature.