mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-06 10:42:08 +00:00
Add app close events
This commit is contained in:
parent
510320bb47
commit
18d3b1c397
1 changed files with 18 additions and 9 deletions
|
@ -1,5 +1,6 @@
|
||||||
use crate::{TelemetrySettings, ZED_SECRET_CLIENT_TOKEN, ZED_SERVER_URL};
|
use crate::{TelemetrySettings, ZED_SECRET_CLIENT_TOKEN, ZED_SERVER_URL};
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
|
use futures::Future;
|
||||||
use gpui::{serde_json, AppContext, AppMetadata, BackgroundExecutor, Task};
|
use gpui::{serde_json, AppContext, AppMetadata, BackgroundExecutor, Task};
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
|
@ -154,19 +155,27 @@ impl Telemetry {
|
||||||
|
|
||||||
// We should only ever have one instance of Telemetry, leak the subscription to keep it alive
|
// We should only ever have one instance of Telemetry, leak the subscription to keep it alive
|
||||||
// rather than store in TelemetryState, complicating spawn as subscriptions are not Send
|
// rather than store in TelemetryState, complicating spawn as subscriptions are not Send
|
||||||
// std::mem::forget(cx.on_app_quit({
|
std::mem::forget(cx.on_app_quit({
|
||||||
// let this = this.clone();
|
let this = this.clone();
|
||||||
// move |cx| this.shutdown_telemetry(cx)
|
move |cx| this.shutdown_telemetry(cx)
|
||||||
// }));
|
}));
|
||||||
|
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
|
|
||||||
// fn shutdown_telemetry(self: &Arc<Self>, cx: &mut AppContext) -> impl Future<Output = ()> {
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
// let telemetry_settings = TelemetrySettings::get_global(cx).clone();
|
fn shutdown_telemetry(self: &Arc<Self>, _: &mut AppContext) -> impl Future<Output = ()> {
|
||||||
// self.report_app_event(telemetry_settings, "close");
|
Task::ready(())
|
||||||
// Task::ready(())
|
}
|
||||||
// }
|
|
||||||
|
// Skip calling this function in tests.
|
||||||
|
// TestAppContext ends up calling this function on shutdown and it panics when trying to find the TelemetrySettings
|
||||||
|
#[cfg(not(any(test, feature = "test-support")))]
|
||||||
|
fn shutdown_telemetry(self: &Arc<Self>, cx: &mut AppContext) -> impl Future<Output = ()> {
|
||||||
|
let telemetry_settings = TelemetrySettings::get_global(cx).clone();
|
||||||
|
self.report_app_event(telemetry_settings, "close");
|
||||||
|
Task::ready(())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn log_file_path(&self) -> Option<PathBuf> {
|
pub fn log_file_path(&self) -> Option<PathBuf> {
|
||||||
Some(self.state.lock().log_file.as_ref()?.path().to_path_buf())
|
Some(self.state.lock().log_file.as_ref()?.path().to_path_buf())
|
||||||
|
|
Loading…
Reference in a new issue