mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-07 02:57:34 +00:00
Do not rely on user's system time for telemetry events (#2597)
Some user's don't have their system clocks configured right and we are seeing events 10 years into the future. I'm stripping out the code that adds time via the client and am adding it in on zed.dev. We will lose a little accuracy, as the time will be when the batch hits the server, but I think its negligible (currently, batches send up every 30 seconds, at the max) and worth it to protect our data from user's who wonkily dont set care about their system time. - https://github.com/zed-industries/zed.dev/pull/332 Release Notes: - N/A
This commit is contained in:
commit
db5bb4ec03
1 changed files with 4 additions and 17 deletions
|
@ -4,14 +4,7 @@ use gpui::{executor::Background, serde_json, AppContext, Task};
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use std::{
|
use std::{env, io::Write, mem, path::PathBuf, sync::Arc, time::Duration};
|
||||||
env,
|
|
||||||
io::Write,
|
|
||||||
mem,
|
|
||||||
path::PathBuf,
|
|
||||||
sync::Arc,
|
|
||||||
time::{Duration, SystemTime, UNIX_EPOCH},
|
|
||||||
};
|
|
||||||
use tempfile::NamedTempFile;
|
use tempfile::NamedTempFile;
|
||||||
use util::http::HttpClient;
|
use util::http::HttpClient;
|
||||||
use util::{channel::ReleaseChannel, TryFutureExt};
|
use util::{channel::ReleaseChannel, TryFutureExt};
|
||||||
|
@ -59,7 +52,6 @@ struct ClickhouseEventRequestBody {
|
||||||
|
|
||||||
#[derive(Serialize, Debug)]
|
#[derive(Serialize, Debug)]
|
||||||
struct ClickhouseEventWrapper {
|
struct ClickhouseEventWrapper {
|
||||||
time: u128,
|
|
||||||
signed_in: bool,
|
signed_in: bool,
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
event: ClickhouseEvent,
|
event: ClickhouseEvent,
|
||||||
|
@ -193,14 +185,9 @@ impl Telemetry {
|
||||||
|
|
||||||
let mut state = self.state.lock();
|
let mut state = self.state.lock();
|
||||||
let signed_in = state.metrics_id.is_some();
|
let signed_in = state.metrics_id.is_some();
|
||||||
state.clickhouse_events_queue.push(ClickhouseEventWrapper {
|
state
|
||||||
time: SystemTime::now()
|
.clickhouse_events_queue
|
||||||
.duration_since(UNIX_EPOCH)
|
.push(ClickhouseEventWrapper { signed_in, event });
|
||||||
.unwrap()
|
|
||||||
.as_millis(),
|
|
||||||
signed_in,
|
|
||||||
event,
|
|
||||||
});
|
|
||||||
|
|
||||||
if state.installation_id.is_some() {
|
if state.installation_id.is_some() {
|
||||||
if state.clickhouse_events_queue.len() >= MAX_QUEUE_LEN {
|
if state.clickhouse_events_queue.len() >= MAX_QUEUE_LEN {
|
||||||
|
|
Loading…
Reference in a new issue