mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
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:
parent
890615b3f2
commit
bcc4f6bf1f
22 changed files with 614 additions and 10 deletions
|
|
@ -593,6 +593,26 @@ Using either of these pattern will result in the in-memory database being served
|
|||
|
||||
This removes a database that has been previously added. ``name=`` is the unique name of that database.
|
||||
|
||||
.. _datasette_track_event:
|
||||
|
||||
await .track_event(event)
|
||||
-------------------------
|
||||
|
||||
``event`` - ``Event``
|
||||
An instance of a subclass of ``datasette.events.Event``.
|
||||
|
||||
Plugins can call this to track events, using classes they have previously registered. See :ref:`plugin_event_tracking` for details.
|
||||
|
||||
The event will then be passed to all plugins that have registered to receive events using the :ref:`plugin_hook_track_event` hook.
|
||||
|
||||
Example usage, assuming the plugin has previously registered the ``BanUserEvent`` class:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
await datasette.track_event(
|
||||
BanUserEvent(user={"id": 1, "username": "cleverbot"})
|
||||
)
|
||||
|
||||
.. _datasette_sign:
|
||||
|
||||
.sign(value, namespace="default")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue