Detect issue view modal is closed in Jira

Hi,

Are there any ways to detect when an issue view modal is closed?

I am looking for a solution similar to the “avi:jira:viewed:issue” event, but one that is triggered when the native issue view modal is closed. This could be by clicking the close button, pressing the escape key, or any other method (such as closing the tab or the browser).

To provide more details, I want to calculate the time a user spends viewing/interacting with the issue. (Don’t ask why—I’m experimenting with time tracking.)

I am open to any other solutions that will help me achieve this. It doesn’t necessarily have to be an onClose event, but that’s been my best idea so far.

All the best!