Have MetricsManager enqueue events when disconnected #3011
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, MetricsManager only enqueues events when we attempt to send
them before it has been initialized, so trying to send an event when
MetricsManager was initialized but the app is disconnected from the
server results in an error being thrown.
This generally doesn't happen very much in practice (you see it from
time to time when developing streamlit itself when the react dev server
reloads files, but I'm not aware of any other instances where we run into
this).
Some of the theme metrics that I want to add, however, will run into
this when trying to record that a user changed their app's theme while
the app is disconnected, so this needs to be fixed before those metrics
can be added.
Closes #2958