What problem does it solve?
Writing Streamlit apps for the PostHog sandbox requires knowing the posthog_apps.query() bridge, the fixed package set, and Streamlit's rerun model — mistakes like uncached queries, unsafe string interpolation into HogQL, or importing unavailable packages cause failures that are hard to diagnose from inside the sandbox.
Core Features & Use Cases
- PostHog data access: Query PostHog with HogQL through the pre-authenticated posthog_apps.query() bridge, which returns pandas DataFrames and raises RuntimeError on failure.
- Rerun-safe patterns: Cache bridge calls with st.cache_data and persist state with st.session_state so widget interactions don't re-fire every query.
- Safe parameterization: Constrain widget inputs with selectboxes, sliders, and type coercion instead of interpolating free text into HogQL, preventing viewers from abusing the author's data access.
- Use Case: Build a single-file app.py that charts daily event counts over a slider-selected day range, with cached queries and st.error handling for failed queries.
Quick Start
Write a Streamlit app that shows daily PostHog event counts for the last 7 days as a bar chart.