Skip to content

Instantly share code, notes, and snippets.

Created March 19, 2023 19:24
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Track time spent in app: network-efficient case tracking last active timestamp
lazy_static! {
static ref LAST_USER_ACTION_UNIX_TIMESTAMP: AtomicI64 = AtomicI64::new(0);
pub fn last_active_timestamp() -> i64 {
// Call this on app start and on every user app active action, e.g. every keystroke
pub fn record_last_active_timestamp() {
LAST_USER_ACTION_UNIX_TIMESTAMP.fetch_max(Utc::now().timestamp(), Ordering::SeqCst);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment