I need to track spent timed on every page on my webapp. In Weweb we use TimeJs to calculate the correct time excluding idle. This work like a charm.
Next, i need to update a row in a xano table when user is leaving. My problem is we can make a workflow on page unload, but the api call is not processing when the user close the tab. I can only update time spent when user change tabs for now, which is a problem for me.
Is there a way to achieve it ?
I saw TimeMe can use websocket, but xano don’t for now
I saw the eventListener onbeforeunload but don’t know how to add this eventListener on weweb.
There are many browser events that can be used to trigger final actions before a user goes away. Before Unmount is one native in Weweb. If you check the list of triggers, scroll down you should see before Unmount.
If you don’t find that, cos I’ve not seen the editor since the summer update. You can use pagehide
Pagehide is probably the best for the use case the OP posted about, where the user is closing the tab. But it’s not natively supported by Weweb. But you can still use it with custom JS (if you want). You can read it below