jrieke / streamlit-analytics

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

Tracking buttons with the same name #24

Open amirmk89 opened 1 year ago

amirmk89 commented 1 year ago

Hi, awesome tool!

I have a use case where several buttons have the same text, and currently the analytics tool tracks all of them as a single button. Each of the buttons has a unique key, and I thought it could be useful to support key based indexing instead of, e.g., button label based. Is this possible in streamlit-analytics?

Thanks!

nathanjones4323 commented 1 year ago

Same here

I believe the issue happens during the "monkey patching" of the widgets inside main.py Here & Here & Here

The widget state/key gets set by default to the label of the widget during the "monkey patching", so even if you have a key set for the widget inside of your app, the state_dict used to track widget interaction will use the label of the widget.

Maybe you could move the "monkey patching" inside of your app page, but that seems messy. Ideally, we have the "monkey patched" widgets inside main.py inherit the key from the app file.