Replies: 2 comments
-
Hi! |
Beta Was this translation helpful? Give feedback.
-
After some testing, I realized I was mistaken. The real issue seems to be that clicks are not registered right away if an error condition exists (this can be an error on the same page as the button, such as my example below, or an error on the target page if the button click causes page navigation). Here's a minimally reproducible example (assume the JSON connection string for firebase is included as a streamlit secret as per the documentation): entrypoint.py import streamlit as st
import streamlit_analytics2 as streamlit_analytics
if __name__ == "__main__":
with streamlit_analytics.track(
firestore_project_name="project",
firestore_collection_name="streamlit-analytics",
streamlit_secrets_firestore_key="firebase",
session_id="1234",
):
st.button("Clicking this does nothing")
if st.button("Force error"):
raise RuntimeError("This is an intentional error!") When I click It's reasonable that this is not a big concern given that the page caused an error condition, but notable perhaps. I've also observed this behavior with |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I know this is on the roadmap but seems currently not enabled (unless I'm misreading the README status?). So I'm wondering: what is the best practice right now? I somewhat blindly just use
with streamlit_analytics.track():
on every page (including my entrypoint) to track clicks, but what I've noticed is that a click to a button on entrypoint.py that navigates to another page isn't captured until I navigate back to entrypoint.py (which is not ideal, since users may never navigate back). Any workarounds for now I can try to capture the click event as soon as it happens, regardless of page?Beta Was this translation helpful? Give feedback.
All reactions