/plausible-events

Primary LanguagePythonBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

plausible-events

PyPI version

This small library allows to easily use the Plausible Events API.

  • Privacy-focused. Uses the open-source and privacy-focused Plausible Analytics. IP addresses are only used to correctly count unique users and for approximate geolocation, but are never stored (also not by ipify, which is used to obtain the public IP address of the caller).
  • Doesn't slow down the main application. Calls to record events are non-blocking, the necessary http requests happen on a separate thread.
  • Doesn't show errors, but tries again. Failed event recordings are re-tried indefinitely, i.e. events aren't lost if network connectivity is temporarily interrupted.

Installation

pip install plausible-events

Examples

from plausible_events import PlausibleEvents

# create object to record events for your plausible.io domain
pe = PlausibleEvents(domain='my.domain.com')

# record a page view event with a (hypothetical) path
pe.pageview('/login/user')

# record a custom event with additional custom properties
pe.event('my event', dict(os='mac', var='foo'))

What is Plausible Analytics?

Plausible Analytics is a transparent and fully open source analytics software. From their website:

Plausible is open source analytics. Our source code is available and accessible on GitHub so anyone can read it, inspect it and review it to verify that our actions match with our words. We welcome feedback and have a public roadmap. If you're happy to manage your own infrastructure, you can self-host Plausible too.