How to detect if users are online (using API connector only)

A few months ago I lucked out and saw this tweet from @AirDev

CleanShot 2023-01-27 at 11.48.40@2x

AirDev: Track users online status

Luckily I archived it for a later date. I just used it and it works great.

I did have to melt my last braincell to make it work in all environments though.

Building on top of AirDev’s suggestion, I would create this step as a Custom Event and trigger from both page load and every 10 seconds.


Would it be the same to use Schedule API Workflow instead of calling it as an API endpoint?

In the tweet, Airdev says that API point doesn’t overload Bubble. I didn’t test, but I’ll take their word for it.

The plot thickens.
That indicator will stop working as expected. The problems are:

  • timezones
  • the weird way that Bubble handles current date/time.

The solution to the timezone problem is to do use :extract Unix timestamp to fix a timezone that you are comparing things to.
– hat-tip to @sublemonster describes on this thread:

The other solution is to NOT rely on Bubble’s current date / time. Instead create a workflow that fires every 5 seconds to update a state on the page with a Unix timestamp. For my example, I subtract 10 seconds because my logic is that if the user has not been online for the last 10 seconds, than mark the user as offline.

1 Like