track_event() mechanism for analytics and plugins

* Closes #2240
* Documentation for event plugin hooks, refs #2240
* Include example track_event plugin in docs, refs #2240
* Tests for track_event() and register_events() hooks, refs #2240
* Initial documentation for core events, refs #2240
* Internals documentation for datasette.track_event()
This commit is contained in:
Simon Willison 2024-01-31 15:21:40 -08:00 committed by GitHub
commit bcc4f6bf1f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 614 additions and 10 deletions

View file

@ -100,7 +100,11 @@ def test_spatialite_error_if_cannot_find_load_extension_spatialite():
def test_plugins_cli(app_client):
runner = CliRunner()
result1 = runner.invoke(cli, ["plugins"])
assert json.loads(result1.output) == EXPECTED_PLUGINS
actual_plugins = sorted(
[p for p in json.loads(result1.output) if p["name"] != "TrackEventPlugin"],
key=lambda p: p["name"],
)
assert actual_plugins == EXPECTED_PLUGINS
# Try with --all
result2 = runner.invoke(cli, ["plugins", "--all"])
names = [p["name"] for p in json.loads(result2.output)]