How to check if an app is active

I use Shortcuts to trigger a Toggl timer when I open certain apps. I would like to add a 10 second delay because I don’t really want to track every time I pop into the app for just a few seconds. The part I can’t figure out is if after I have the shortcut “wait” for 10 seconds, is there something (probably a script of some kind) I can run that will check to see if the app is still open?