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

**URL:** <https://discuss.streamlit.io/t/secure-deployment-with-streamlit-analytics-track-usage-of-widgets-and-app/38983>\
**Category:** Show the Community!\
**Tags:** session-state, streamlit-cloud\
**Created:** [March 8, 2023, 7:44pm UTC](https://discuss.streamlit.io/t/secure-deployment-with-streamlit-analytics-track-usage-of-widgets-and-app/38983 "2023-03-08T19:44:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nathan\_Jones](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/nathan_jones/32/16677_2.png) [@Nathan\_Jones](https://discuss.streamlit.io/u/Nathan_Jones)\
**Post date:** [March 8, 2023, 7:44pm UTC](https://discuss.streamlit.io/t/secure-deployment-with-streamlit-analytics-track-usage-of-widgets-and-app/38983/1 "2023-03-08T19:44:24Z")

</div>

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

Thanks to the [streamlit-analytics](https://github.com/jrieke/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](https://github.com/jrieke/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 👍

---

<div class="post-metadata">

**Author:** ![jgieseler](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/jgieseler/32/47324_2.png) [@jgieseler](https://discuss.streamlit.io/u/jgieseler)\
**Post date:** [April 21, 2023, 1:01pm UTC](https://discuss.streamlit.io/t/secure-deployment-with-streamlit-analytics-track-usage-of-widgets-and-app/38983/2 "2023-04-21T13:01:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![puyo](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/puyo/32/32139_2.png) [@puyo](https://discuss.streamlit.io/u/puyo)\
**Post date:** [June 12, 2023, 1:43pm UTC](https://discuss.streamlit.io/t/secure-deployment-with-streamlit-analytics-track-usage-of-widgets-and-app/38983/3 "2023-06-12T13:43:39Z")

</div>

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.

> <https://github.com/puyodev/split_pdf/blob/342f4b031ff0256a2ee4c46b94fa608f6e80f667/main.py#L123C1-L133>

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/streamlit/original/3X/c/f/cf4c2ee0d938358f82448c5fe4b9c3c91d7ce19c.svg) [@system](https://discuss.streamlit.io/u/system)\
**Post date:** [June 11, 2024, 1:44pm UTC](https://discuss.streamlit.io/t/secure-deployment-with-streamlit-analytics-track-usage-of-widgets-and-app/38983/4 "2024-06-11T13:44:34Z")

</div>

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
