Skip to content

Commit a84e798

Browse files
committed
release of 0.3.2
1 parent c77952e commit a84e798

3 files changed

Lines changed: 12 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.3.2
2+
3+
* (macOS) Fixed an issue where sessions could span multiple days if the app was left open overnight
4+
15
## 0.3.1
26

37
* Wait for event to be flushed on panic

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "tauri-plugin-aptabase"
3-
version = "0.3.1"
3+
version = "0.3.2"
44
license = "MIT"
55
description = "Tauri Plugin for Aptabase: Open Source, Privacy-First and Simple Analytics for Mobile, Desktop and Web Apps"
66
authors = [ "Guilherme Oenning" ]

src/client.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use log::debug;
22
use reqwest::header::{HeaderMap, HeaderValue};
33
use serde_json::{json, Value};
4-
use std::{sync::Mutex, time::Duration, time::Instant};
4+
use std::{sync::Mutex, time::Duration};
55
use time::{format_description::well_known::Rfc3339, OffsetDateTime};
66
use uuid::Uuid;
77

@@ -16,14 +16,14 @@ static HTTP_REQUEST_TIMEOUT: Duration = Duration::from_secs(10);
1616
#[derive(Debug, Clone)]
1717
pub struct TrackingSession {
1818
pub id: String,
19-
pub last_touch_ts: Instant,
19+
pub last_touch_ts: OffsetDateTime,
2020
}
2121

2222
impl TrackingSession {
2323
fn new() -> Self {
2424
TrackingSession {
2525
id: Uuid::new_v4().to_string(),
26-
last_touch_ts: Instant::now(),
26+
last_touch_ts: OffsetDateTime::now_utc(),
2727
}
2828
}
2929
}
@@ -66,11 +66,11 @@ impl AptabaseClient {
6666
pub(crate) fn eval_session_id(&self) -> String {
6767
let mut session = self.session.lock().expect("could not lock session");
6868

69-
// session timeout since last touched, start a new one!
70-
if session.last_touch_ts.elapsed() > SESSION_TIMEOUT {
71-
*session = TrackingSession::new()
69+
let now = OffsetDateTime::now_utc();
70+
if (now - session.last_touch_ts) > SESSION_TIMEOUT {
71+
*session = TrackingSession::new();
7272
} else {
73-
session.last_touch_ts = Instant::now()
73+
session.last_touch_ts = now;
7474
}
7575
return session.id.clone();
7676
}

0 commit comments

Comments
 (0)