History

zed: Fix session ID mismatching for workspace and telemetry (#43659)

I don't think this caused any problems for us but you never know ... Release Notes: - N/A *or* Added/Fixed/Improved ...

Lukas Wirth committed 11 months ago

Commit 4e3aa0b1 parent 05764e82 files · +15 −11Browse files

Unified · Split

2 files
  1. crates/session/src/session.rs +3 −6
  2. crates/zed/src/main.rs +12 −5
crates/session/src/session.rs+3−6
@@ -3,7 +3,6 @@ use std::time::Duration; · 2 unmodified lines
3use db::kvp::KEY_VALUE_STORE;3use db::kvp::KEY_VALUE_STORE;
4use gpui::{App, AppContext as _, Context, Subscription, Task, WindowId};4use gpui::{App, AppContext as _, Context, Subscription, Task, WindowId};
5use util::ResultExt;5use util::ResultExt;
6use uuid::Uuid;
7 6
8pub struct Session {7pub struct Session {
9 session_id: String,8 session_id: String,
@@ -15,11 +14,9 @@ const SESSION_ID_KEY: &str = "session_id"; · 5 unmodified lines
15const SESSION_WINDOW_STACK_KEY: &str = "session_window_stack";14const SESSION_WINDOW_STACK_KEY: &str = "session_window_stack";
16 15
17impl Session {16impl Session {
18 pub async fn new() -> Self {17 pub async fn new(session_id: String) -> Self {
19 let old_session_id = KEY_VALUE_STORE.read_kvp(SESSION_ID_KEY).ok().flatten();18 let old_session_id = KEY_VALUE_STORE.read_kvp(SESSION_ID_KEY).ok().flatten();
20 19
21 let session_id = Uuid::new_v4().to_string();
22
23 KEY_VALUE_STORE20 KEY_VALUE_STORE
24 .write_kvp(SESSION_ID_KEY.to_string(), session_id.clone())21 .write_kvp(SESSION_ID_KEY.to_string(), session_id.clone())
25 .await22 .await
@@ -43,10 +40,10 @@ impl Session { · 17 unmodified lines
43 }40 }
44 }41 }
45 42
46 // #[cfg(any(test, feature = "test-support"))]43 #[cfg(any(test, feature = "test-support"))]
47 pub fn test() -> Self {44 pub fn test() -> Self {
48 Self {45 Self {
49 session_id: Uuid::new_v4().to_string(),46 session_id: uuid::Uuid::new_v4().to_string(),
50 old_session_id: None,47 old_session_id: None,
51 old_window_ids: None,48 old_window_ids: None,
52 }49 }
crates/zed/src/main.rs+12−5
@@ -287,14 +287,16 @@ pub fn main() { · 286 unmodified lines
287 287
288 let app = Application::new().with_assets(Assets);288 let app = Application::new().with_assets(Assets);
289 289
290 let system_id = app.background_executor().block(system_id()).ok();290 let system_id = app.background_executor().spawn(system_id());
291 let installation_id = app.background_executor().block(installation_id()).ok();291 let installation_id = app.background_executor().spawn(installation_id());
292 let session_id = Uuid::new_v4().to_string();292 let session_id = Uuid::new_v4().to_string();
293 let session = app.background_executor().block(Session::new());293 let session = app
294 .background_executor()
295 .spawn(Session::new(session_id.clone()));
294 296
295 app.background_executor()297 app.background_executor()
296 .spawn(crashes::init(InitCrashHandler {298 .spawn(crashes::init(InitCrashHandler {
297 session_id: session_id.clone(),299 session_id,
298 zed_version: app_version.to_string(),300 zed_version: app_version.to_string(),
299 binary: "zed".to_string(),301 binary: "zed".to_string(),
300 release_channel: release_channel::RELEASE_CHANNEL_NAME.clone(),302 release_channel: release_channel::RELEASE_CHANNEL_NAME.clone(),
@@ -505,11 +507,16 @@ pub fn main() { · 204 unmodified lines
505 debugger_ui::init(cx);507 debugger_ui::init(cx);
506 debugger_tools::init(cx);508 debugger_tools::init(cx);
507 client::init(&client, cx);509 client::init(&client, cx);
510
511 let system_id = cx.background_executor().block(system_id).ok();
512 let installation_id = cx.background_executor().block(installation_id).ok();
513 let session = cx.background_executor().block(session);
514
508 let telemetry = client.telemetry();515 let telemetry = client.telemetry();
509 telemetry.start(516 telemetry.start(
510 system_id.as_ref().map(|id| id.to_string()),517 system_id.as_ref().map(|id| id.to_string()),
511 installation_id.as_ref().map(|id| id.to_string()),518 installation_id.as_ref().map(|id| id.to_string()),
512 session_id.clone(),519 session.id().to_owned(),
513 cx,520 cx,
514 );521 );
515 522

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t