A Python library for building page analytics in Streamlit applications through logging.
The solution instruments all st.<widget>
with a wrapper function which emits logs,
these logs can then be processed to derive analytics information.
This solution is inspired from jrieke/streamlit-analytics idea.
Use the releases to download assets:
To run it locally, Download the wheel(.whl
) file and install or
install from git:
pip install \
git+https://github.com/Snowflake-Labs/streamlit-page-analytics@latest
Download the streamlit_page_analytics-<version>.zip
file and copy it to a
Snowflake Internal Stage for use in SiS and run the following command:
ALTER STREAMLIT <your-streamlit-name> SET
IMPORTS = ('@<your-internal-stage>/<path/to/your/zip/file>');
import streamlit as st
from streamlit_page_analytics import StreamlitPageAnalytics
with StreamlitPageAnalytics.track(
name="my-app", session_id=f"{session_id}", user_id=f"{user_id}"
):
st.title("My Awesome App")
st.button('my awesome button')
or
import streamlit as st
from streamlit_page_analytics import StreamlitPageAnalytics
page_analytics = StreamlitPageAnalytics(
name="my-app", session_id=f"{session_id}", user_id=f"{user_id}"
)
page_analytics.start_tracking()
st.title("My Awesome App")
st.button('my awesome button')
page_analytics.stop_tracking()
The following Streamlit widgets are currently supported:
st.button
- Click eventsst.checkbox
- Change eventsst.radio
- Change eventsst.selectbox
- Change eventsst.multiselect
- Change eventsst.slider
- Change eventsst.select_slider
- Change eventsst.text_input
- Change eventsst.number_input
- Change eventsst.text_area
- Change eventsst.date_input
- Change eventsst.time_input
- Change eventsst.file_uploader
- Change eventsst.color_picker
- Change events
Use the sample analytics script to setup analytics on top of the logs can be quickly built using dynamic tables.
License: Apache 2.0
This is not an official Snowflake product or feature.