I packaged your 'minimal' example into a app() function (so I can run it as a page in a multi-page streamlit app). Similar to what's being done here.
import streamlit as st
import datetime
try:
import streamlit_analytics
except ImportError:
import subprocess, sys # Install streamlit-analytics on first run (not included in requirements.txt).
subprocess.check_call([sys.executable, "-m", "pip", "install", "streamlit_analytics"])
import streamlit_analytics
def app():
with streamlit_analytics.track(verbose=True):
st.text_input("Write your name")
st.selectbox("Select your favorite", ["cat", "dog", "flower"])
st.button("Click me")
However, I got the following error using streamlit 1.4
File "/home/appuser/venv/lib/python3.7/site-packages/streamlit/script_runner.py", line 379, in _run_script
"""
File "/app/k_internal_tools/app.py", line 23, in <module>
apps.run()
File "/app/k_internal_tools/multiapp.py", line 64, in run
functions[titles.index(title)]()
File "/app/k_internal_tools/apps/tracking.py", line 12, in app
with streamlit_analytics.track(verbose=True):
File "/usr/local/lib/python3.7/contextlib.py", line 112, in __enter__
return next(self.gen)
File "/home/appuser/venv/lib/python3.7/site-packages/streamlit_analytics/main.py", line 443, in track
load_from_json=load_from_json,
File "/home/appuser/venv/lib/python3.7/site-packages/streamlit_analytics/main.py", line 282, in start_tracking
last_time=datetime.datetime.now(),
File "/home/appuser/venv/lib/python3.7/site-packages/streamlit_analytics/session_state.py", line 92, in get
(not hasattr(s, "_main_dg") and s.enqueue == ctx.enqueue)
I packaged your 'minimal' example into a app() function (so I can run it as a page in a multi-page streamlit app). Similar to what's being done here.
However, I got the following error using streamlit 1.4
Any ideas?