Report telemetry on actions taken in the UI#1953
Conversation
koesie10
left a comment
There was a problem hiding this comment.
I have some small suggestions, but in general it looks good. I clicked around the MRVA UI and agree with you that this should cover all events.
|
@koesie10, @charisk, thank you both for the review. I believe I have now addressed all comments so this is ready for a re-review. It was mentioned earlier today maybe we don't have to send an extension message and we could emit telemetry events from within the webview. I don't know if that's possible but I'm happy to explore it in a followup PR. It won't change the bulk of this work as sending the extension messages isn't the hard bit. |
|
I just saw this comment:
It would generally be possible to do this, but we'd need to change the CSP when we construct the webview. In the past, we've been careful to ensure that the webview only communicates with the extension. Maybe it's something worth reconsidering. However, I think you'd need to use a different library to send the telemetry events. This would mean that the structure of webview events would be different from extension events. This wouldn't be terrible, but would require some extra work in application insights. |
Thanks for explaining. That's really helpful! Sounds to me like maybe too much effort and downsides of having two implementations, unless sending the extension messages turns out to be a big problem. Right now I don't think the volume of extension messages or the implementation of the message is too bad. |
|
Yes, and another benefit of using a single mechanism to send telemetry is that the package we are using right now batches multiple telemetry events into a single request. |
When the user makes certain actions in the UI, output telemetry for it. This is done by sending a message from the webview back to the extension backend, which can then output telemetry in the normal way. We introduce a new telemetry event name of
ui-interaction.A large source of telemetry is from react state changes. If the data shown in the UI changes then there must have been a react state change, so we can use
useStatecalls as an indicator of an event we want to emit telemetry for. Not all state changes should emit telemetry events, but only the ones that are the direct result of a user action. To make it easier, I've added auseStateWithTelemetrymethod that wrapsuseStateand allows emitting telemetry whenever the value changes.Another source of useful telemetry is when the user clicks a link. To cover these we have to identify the links and add
onClickhandlers to them.I've manually tried to click every button and perform every action I can in the MRVA results view, and I think this now sends telemetry events for all actions.
Checklist
ready-for-doc-reviewlabel there.