mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-19 02:17:35 +03:00
Do not reset timer for each reported event
This commit is contained in:
parent
391a61cdc2
commit
00682b8903
@ -457,20 +457,24 @@ impl Telemetry {
|
||||
return;
|
||||
}
|
||||
|
||||
if state.flush_events_task.is_none() {
|
||||
let this = self.clone();
|
||||
let executor = self.executor.clone();
|
||||
state.flush_events_task = Some(self.executor.spawn(async move {
|
||||
executor.timer(FLUSH_DEBOUNCE_INTERVAL).await;
|
||||
this.flush_events();
|
||||
}));
|
||||
}
|
||||
|
||||
let signed_in = state.metrics_id.is_some();
|
||||
state.events_queue.push(EventWrapper { signed_in, event });
|
||||
|
||||
dbg!(&state.events_queue.len());
|
||||
|
||||
if state.installation_id.is_some() {
|
||||
if state.events_queue.len() >= MAX_QUEUE_LEN {
|
||||
drop(state);
|
||||
self.flush_events();
|
||||
} else {
|
||||
let this = self.clone();
|
||||
let executor = self.executor.clone();
|
||||
state.flush_events_task = Some(self.executor.spawn(async move {
|
||||
executor.timer(FLUSH_DEBOUNCE_INTERVAL).await;
|
||||
this.flush_events();
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -534,6 +538,7 @@ impl Telemetry {
|
||||
release_channel: state.release_channel,
|
||||
events,
|
||||
};
|
||||
dbg!("flush", &request_body);
|
||||
json_bytes.clear();
|
||||
serde_json::to_writer(&mut json_bytes, &request_body)?;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user