jrieke / streamlit-analytics

👀 Track & visualize user interactions with your streamlit app
MIT License
262 stars 48 forks source link

Firestore not playing nice with file_uploader #4

Open jucor opened 3 years ago

jucor commented 3 years ago

When one of the widgets is a file_uploader and Firestore is enabled, an error is thrown at stop_tracking complaining about something something not being a string something something. (sorry, did not save the exact error anymore, I worked around it, see below).

This error does not appear when Firestore is not enabled.

I suspect this is because the return value of a file uploader is sometimes None and sometimes an instance of class UploadedFile, which is not a string. That causes a problem at seralization time into Firestore.

Workaround: I only call start_tracking() after having instanciated my file_uploader widget, meaning I cannot track any widget that comes before it. Sad, but the only way to make it work so far.

Alternative: adding a conditional to automatically convert the value of file_uploader into a string (containing maybe just the filename, not the whole uploaded file).

jrieke commented 2 years ago

That's weird, the return value of file uploader is actually never stored in Firestore. I can't test this right now because I don't have an instance of Firestore set up. Maybe this was also fixed with #3. If you see this again, please post the full error message, then I can give it a look!