Check is screen is Idle or Inactive to control timer

  • I am using a timer component, to track the time a user spends on a particular thing. And I have connected my timer to the database so that we keep updating the time spent and then set elapsedTime based on that.

I also want to include a feature where I can stop the timer if the screen has been idle/inactive for some threshhold time. Is it at all possible to do that?

Hello @Rajvi_Chokshi!

Unfortunately there currently isn't a way to track user activity in retool to trigger an event via inactivity.

Our engineers are currently working on this to integrate tools such as FullStory into retool apps.

The next best option would be to have a timer run that is reset by an app making query calls. You can track when a retool app runs a query with retoolContext.runningQueries which will be an array that will list out currently running queries.

You can have another code block check for this array's length to be greater than zero to reset the inactivity timer.