Streamlit Fyr
Streamlit Fyr is a simple analytics package meant for being used as a "centralized" analytics platform for multi-app streamlit deployments.
This package takes inspiration from:
This package offers a simple SQLite backend to test out the capabilities of the package, but the central usage is to connect to an external PostgresSQL and connect multiple applications to a single DB in order to centralize page analytics.
Key features:
- Cookie-based persistent
visitor_idacross sessions. - Per-event rows in a queryable relational DB.
- Multi-app centralization via
app_namecolumn. One DB for all your Streamlit apps - Bundled Plotly dashboard page (
make_dashboard_page)
Installation
pip install streamlit-fyr # core: Tracker + SQLiteBackend + raw query()
pip install 'streamlit-fyr[dashboard]' # adds plotly for make_dashboard_page
pip install 'streamlit-fyr[postgres]' # adds psycopg driver for PostgresBackend
pip install 'streamlit-fyr[all]' # everything
The core install only ships SQLAlchemy + pandas + Streamlit. plotly and psycopg
are optional extras — install them only if you need the bundled dashboard or the
Postgres backend.
Basic Usage
SQLite backend
To test the capabilities of this package we recommend using first SQLiteBackend.
This backend will expect to receive a file name for the sqlite db file to be created.
Alternatively you can set the envrionmental variable ST_FYR_SQLITE_FILE to
your db file.
import streamlit as st
from constants import DATA_PATH
from streamlit_fyr.dashboard import make_dashboard_page
from streamlit_fyr import SQLiteBackend, Tracker
backend = SQLiteBackend("telemetry.db")
tracker = Tracker(app_name="my_st_app", backend=backend)
tracker.init()
def my_page() -> None:
"""Render a new page."""
tracker.page("my_page")
st.title("My streamlit Page!")
count = 0
if st.button("click me!"):
tracker.event("button_pressed", {"press_count": count})
count += 1
...
page_telemetry = st.Page(
make_dashboard_page(backend),
title="Telemetry",
icon=":material/analytics:",
)
pg = st.navigation({
"App": [my_page],
"Page Analytics": [page_telemetry],
})
pg.run()
Postgres backend
To enable the postgres backend you must change backend to the PostgresBackend
and add your DB connection string. Alternatively you can set the environment
variable ST_FYR_CONNECTION_STRING to your connection string and the backend
will read that value.
from streamlit_fyr import PostgresBackend, Tracker
@st.cache_resource
def get_backend():
return PostgresBackend(connection_string="postgresql+psycopg://...")
backend = get_backend()
tracker = Tracker(app_name="my_st_app", backend=backend)
## Same config as with SQLite
PostgresBackend forwards connection-pool settings to SQLAlchemy with sane
defaults (pool_size=5, max_overflow=5, pool_pre_ping=True); override them
(or pass any other create_engine kwarg) if you need to tune the pool:
PostgresBackend(
connection_string="postgresql+psycopg://...",
pool_size=10,
max_overflow=20,
pool_pre_ping=True,
)
Schema setup (provisioning the events table)
Backends need an events table (plus its indexes) before they can write. Who
creates it — and when — differs between local and production use:
- SQLite (
SQLiteBackend) defaults toensure_schema=True: the table and indexes are created on construction. Zero-config, matches the local/dev story. - Postgres (
PostgresBackend) defaults toensure_schema=False: apps do no DDL at runtime. You provision the schema once, up front, with a privileged role, then run the apps with an INSERT-only role.
Recommended multi-app pattern
Run this once at deploy time with a role that can create tables/indexes:
from streamlit_fyr import PostgresBackend
backend = PostgresBackend(connection_string="postgresql+psycopg://admin:...@host/db")
backend.ensure_schema() # creates table + indexes, backfills user_id; idempotent
Then each app constructs its backend with an INSERT-only role and skips DDL entirely (this is the default, so no flag is needed):
@st.cache_resource
def get_backend():
return PostgresBackend(connection_string="postgresql+psycopg://app_writer:...@host/db")
# ensure_schema defaults to False — no DDL, safe for INSERT-only roles
ensure_schema() is idempotent: it creates the table if missing, backfills the
user_id column on older tables, and adds any missing indexes. You can re-run
it safely on every deploy.
Identifying authenticated users
If your app has authentication, call tracker.identify() after login resolves
to attach a known identity to all subsequent events in the session:
user = get_logged_in_user() # your auth layer
tracker.identify(user.id)
identify() stores the value in Streamlit session state and writes it to every
event from that point forward alongside visitor_id. Events fired before
identify() is called (e.g. the login page itself) will have user_id = NULL.
Observing write failures
By design, telemetry failures never break the host app — if a backend write
fails, Tracker swallows the exception and continues. To avoid silently
dropping events with no signal, the library logs a full warning on the first
write failure per process (subsequent failures are logged at debug) via the
streamlit_fyr logger.
For a louder, actionable signal, pass an on_write_error callback. It is
invoked with the exception whenever a write fails, so you can surface or alert
on the failure without the library re-raising into your app:
def alert(exc: Exception) -> None:
my_error_reporter.capture(exc) # e.g. Sentry, a metric, a log
tracker = Tracker(app_name="my_st_app", backend=backend, on_write_error=alert)
The callback must not raise; if it does, its exception is logged and suppressed so the guarantee that telemetry cannot break the host app still holds.
Metadata
Release files for streamlit-fyr 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| streamlit_fyr-0.3.0.tar.gz | 12.7 kB | With provenance | Details for streamlit_fyr-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| streamlit_fyr-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for streamlit_fyr-0.3.0-py3-none-any.whl |
Total release size: 28.8 kB
Release files / streamlit_fyr-0.3.0.tar.gz
| Download URL | streamlit_fyr-0.3.0.tar.gz |
|---|---|
| Size | 12.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9b91dcc777dcb17caf4d27b1b1de9a7b5e25a28dab7996082f1e2e7db0617be5
|
|
BLAKE2b-256 checksum How to use checksums |
600229aaf3d5424ac40a0ec72d1f41cb20c56a22b5425dfe0a9ff44c55a36b0d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 15, 2026.
Transparency logRelease files / streamlit_fyr-0.3.0-py3-none-any.whl
| Download URL | streamlit_fyr-0.3.0-py3-none-any.whl |
|---|---|
| Size | 16.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cceae73dbb6dfd7480f42b8babd2d243619ea870d6195960bd93f371482aa674
|
|
BLAKE2b-256 checksum How to use checksums |
fb9b0829c873e0bcaa6768288cc5aab1719f926397f7882198900e5c4d4ed562
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 15, 2026.
Transparency logSecurity for streamlit-fyr 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for streamlit_fyr-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 15, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.