In the above code
document.addEventListener('visibilitychange', handleVisibilityChange);
this event listener works as expected.
But the other ones dont. Basically the mousemove keydown and others. Which makes me wonder if adding these eventListeners is supported by retool?
Unfortunately eventListeners on the window is not support by Retool.
Our code runs the app in a sandbox and does not give user code access to the window for user tracking.
We currently have user tracking as a major feature for H2 of this year that our team is looking to add as this as been a common feature request.
I had suggested the custom components library as a temporary work around but it would only work for the HTML elements in the custom component (if at all, not confirmed).
I just found a workaround that can be added to your SSO options to set the Retool app to log out after a specified amount of time. You could set a timer to refresh this variable when queries run.
You can use UI or env var ( SESSION_DURATION_MINUTES ) to configure it.
Check out the image below, this option is available in version 3.52
i've gotten window event listeners working when adding them to the app Preloaded JS. try adding the window event listeners there if you're able to, this won't work for all use cases but I think for your situation you might be able to use this. I have a small example here of adding a variable and event listener to window. functions and variables need to be assigned to window.function_name = function(){} and can be called anywhere with window.function_name()
@Jack_T's solution is probably the best way to go about things, but I like providing people with options