Secure deployment with streamlit-analytics (track usage of widgets and app)

Built a Streamlit app for your company or colleagues, but have no idea who is using what pages / widgets ?

Thanks to the streamlit-analytics package, you can start tracking the usage of various app widgets and pages.

Problem with this package:

To persist your analytics data after deployment / app updates, you need to use firebase. There was not out of the box support for securely setting this up for deployed apps (Streamlit Cloud or other provider).

  • You had to push a .json file with your firebase credentials to GitHub which is a no no
  • Now all you need to do is add the contents of the .json file to .streamlit/secrets.toml and you have the option of reading the firebase credentials directly using st.secrets

Just put up the PR for this change streamlit-analytics so you can use persist app usage analytics securely through firebase.

If you want to use this or see it get merged, please give it a :+1:


Thanks! Iā€™m really eagerly waiting for this PR to be merged, as it perfectly solves my problem!

I completely agree.
I work around it by encoding the json key in base64 and storing it in secret, then temporarily generating the json key.
Here is a sample code.