Add timestamp delta to telemetry events (#3365)

Joseph T. Lyons created

- [X] assistant_events
- [X] call_events
- [X] copilot_events
- [X] cpu_events
- [X] download_events
- [X] editor_events
- [X] memory_events
- [X] page_events
- [X] panic_events
---
- [X] For each of the previous tables:
    - [X] backup events to comp
    - [X] make new table (changing any time fields to be datetime64)
    - [X] copy data
    - [X] rename old table
    - [X] rename new table
---
- [ ] Delete all old tables once (going to hold off on this for some
time - want to make sure things are working correctly)
    - [X] we see new data coming in on new tables
    - [X] old times truncate correctly
    - [X] new times show millisecond values
---
- [X] check dashboards to make sure queries didn't get broken from
changing time data type
    - [X] Fix broken charts
- [X] monitor vercel for runtime errors

---

- [X] zed.dev changes
- [X] chrono changes to panicked_on
    - [X] Make sure new panics are good
- [X] remove commented out code and dbg code
- [X] triple check that both crate versions have the changes
- [X] make sure all event function calls use the same original arguments
- [X] Finish testing version 2

Release Notes:

- N/A

Change summary

Cargo.lock                              |   2 
crates/assistant/src/assistant_panel.rs |  14 +-
crates/call/src/call.rs                 |  23 +--
crates/call2/src/call2.rs               |  23 +--
crates/client/Cargo.toml                |   1 
crates/client/src/telemetry.rs          | 150 ++++++++++++++++++++++++--
crates/client2/Cargo.toml               |   1 
crates/client2/src/telemetry.rs         | 150 ++++++++++++++++++++++++--
crates/editor/src/editor.rs             |  14 +-
crates/editor2/src/editor.rs            |  14 +-
crates/zed/src/main.rs                  |   9 -
crates/zed2/src/main.rs                 |  11 -
12 files changed, 322 insertions(+), 90 deletions(-)

Detailed changes

Cargo.lock 🔗

@@ -1550,6 +1550,7 @@ dependencies = [
  "anyhow",
  "async-recursion 0.3.2",
  "async-tungstenite",
+ "chrono",
  "collections",
  "db",
  "feature_flags",
@@ -1586,6 +1587,7 @@ dependencies = [
  "anyhow",
  "async-recursion 0.3.2",
  "async-tungstenite",
+ "chrono",
  "collections",
  "db2",
  "feature_flags2",

crates/assistant/src/assistant_panel.rs 🔗

@@ -15,7 +15,7 @@ use ai::{
 use ai::prompts::repository_context::PromptCodeSnippet;
 use anyhow::{anyhow, Result};
 use chrono::{DateTime, Local};
-use client::{telemetry::AssistantKind, ClickhouseEvent, TelemetrySettings};
+use client::{telemetry::AssistantKind, TelemetrySettings};
 use collections::{hash_map, HashMap, HashSet, VecDeque};
 use editor::{
     display_map::{
@@ -3803,12 +3803,12 @@ fn report_assistant_event(
         .default_open_ai_model
         .clone();
 
-    let event = ClickhouseEvent::Assistant {
-        conversation_id,
-        kind: assistant_kind,
-        model: model.full_name(),
-    };
     let telemetry_settings = *settings::get::<TelemetrySettings>(cx);
 
-    telemetry.report_clickhouse_event(event, telemetry_settings)
+    telemetry.report_assistant_event(
+        telemetry_settings,
+        conversation_id,
+        assistant_kind,
+        model.full_name(),
+    )
 }

crates/call/src/call.rs 🔗

@@ -5,10 +5,7 @@ pub mod room;
 use anyhow::{anyhow, Result};
 use audio::Audio;
 use call_settings::CallSettings;
-use client::{
-    proto, ClickhouseEvent, Client, TelemetrySettings, TypedEnvelope, User, UserStore,
-    ZED_ALWAYS_ACTIVE,
-};
+use client::{proto, Client, TelemetrySettings, TypedEnvelope, User, UserStore, ZED_ALWAYS_ACTIVE};
 use collections::HashSet;
 use futures::{channel::oneshot, future::Shared, Future, FutureExt};
 use gpui::{
@@ -485,12 +482,8 @@ pub fn report_call_event_for_room(
 ) {
     let telemetry = client.telemetry();
     let telemetry_settings = *settings::get::<TelemetrySettings>(cx);
-    let event = ClickhouseEvent::Call {
-        operation,
-        room_id: Some(room_id),
-        channel_id,
-    };
-    telemetry.report_clickhouse_event(event, telemetry_settings);
+
+    telemetry.report_call_event(telemetry_settings, operation, Some(room_id), channel_id)
 }
 
 pub fn report_call_event_for_channel(
@@ -504,12 +497,12 @@ pub fn report_call_event_for_channel(
     let telemetry = client.telemetry();
     let telemetry_settings = *settings::get::<TelemetrySettings>(cx);
 
-    let event = ClickhouseEvent::Call {
+    telemetry.report_call_event(
+        telemetry_settings,
         operation,
-        room_id: room.map(|r| r.read(cx).id()),
-        channel_id: Some(channel_id),
-    };
-    telemetry.report_clickhouse_event(event, telemetry_settings);
+        room.map(|r| r.read(cx).id()),
+        Some(channel_id),
+    )
 }
 
 #[cfg(test)]

crates/call2/src/call2.rs 🔗

@@ -5,10 +5,7 @@ pub mod room;
 use anyhow::{anyhow, Result};
 use audio::Audio;
 use call_settings::CallSettings;
-use client::{
-    proto, ClickhouseEvent, Client, TelemetrySettings, TypedEnvelope, User, UserStore,
-    ZED_ALWAYS_ACTIVE,
-};
+use client::{proto, Client, TelemetrySettings, TypedEnvelope, User, UserStore, ZED_ALWAYS_ACTIVE};
 use collections::HashSet;
 use futures::{channel::oneshot, future::Shared, Future, FutureExt};
 use gpui::{
@@ -484,12 +481,8 @@ pub fn report_call_event_for_room(
 ) {
     let telemetry = client.telemetry();
     let telemetry_settings = *TelemetrySettings::get_global(cx);
-    let event = ClickhouseEvent::Call {
-        operation,
-        room_id: Some(room_id),
-        channel_id,
-    };
-    telemetry.report_clickhouse_event(event, telemetry_settings);
+
+    telemetry.report_call_event(telemetry_settings, operation, Some(room_id), channel_id)
 }
 
 pub fn report_call_event_for_channel(
@@ -504,12 +497,12 @@ pub fn report_call_event_for_channel(
 
     let telemetry_settings = *TelemetrySettings::get_global(cx);
 
-    let event = ClickhouseEvent::Call {
+    telemetry.report_call_event(
+        telemetry_settings,
         operation,
-        room_id: room.map(|r| r.read(cx).id()),
-        channel_id: Some(channel_id),
-    };
-    telemetry.report_clickhouse_event(event, telemetry_settings);
+        room.map(|r| r.read(cx).id()),
+        Some(channel_id),
+    )
 }
 
 #[cfg(test)]

crates/client/Cargo.toml 🔗

@@ -12,6 +12,7 @@ doctest = false
 test-support = ["collections/test-support", "gpui/test-support", "rpc/test-support"]
 
 [dependencies]
+chrono = { version = "0.4", features = ["serde"] }
 collections = { path = "../collections" }
 db = { path = "../db" }
 gpui = { path = "../gpui" }

crates/client/src/telemetry.rs 🔗

@@ -1,4 +1,5 @@
 use crate::{TelemetrySettings, ZED_SECRET_CLIENT_TOKEN, ZED_SERVER_URL};
+use chrono::{DateTime, Utc};
 use gpui::{executor::Background, serde_json, AppContext, Task};
 use lazy_static::lazy_static;
 use parking_lot::Mutex;
@@ -31,6 +32,7 @@ struct TelemetryState {
     flush_clickhouse_events_task: Option<Task<()>>,
     log_file: Option<NamedTempFile>,
     is_staff: Option<bool>,
+    first_event_datetime: Option<DateTime<Utc>>,
 }
 
 const CLICKHOUSE_EVENTS_URL_PATH: &'static str = "/api/events";
@@ -77,29 +79,35 @@ pub enum ClickhouseEvent {
         vim_mode: bool,
         copilot_enabled: bool,
         copilot_enabled_for_language: bool,
+        milliseconds_since_first_event: i64,
     },
     Copilot {
         suggestion_id: Option<String>,
         suggestion_accepted: bool,
         file_extension: Option<String>,
+        milliseconds_since_first_event: i64,
     },
     Call {
         operation: &'static str,
         room_id: Option<u64>,
         channel_id: Option<u64>,
+        milliseconds_since_first_event: i64,
     },
     Assistant {
         conversation_id: Option<String>,
         kind: AssistantKind,
         model: &'static str,
+        milliseconds_since_first_event: i64,
     },
     Cpu {
         usage_as_percentage: f32,
         core_count: u32,
+        milliseconds_since_first_event: i64,
     },
     Memory {
         memory_in_bytes: u64,
         virtual_memory_in_bytes: u64,
+        milliseconds_since_first_event: i64,
     },
 }
 
@@ -140,6 +148,7 @@ impl Telemetry {
                 flush_clickhouse_events_task: Default::default(),
                 log_file: None,
                 is_staff: None,
+                first_event_datetime: None,
             }),
         });
 
@@ -195,20 +204,18 @@ impl Telemetry {
                     return;
                 };
 
-                let memory_event = ClickhouseEvent::Memory {
-                    memory_in_bytes: process.memory(),
-                    virtual_memory_in_bytes: process.virtual_memory(),
-                };
-
-                let cpu_event = ClickhouseEvent::Cpu {
-                    usage_as_percentage: process.cpu_usage(),
-                    core_count: system.cpus().len() as u32,
-                };
-
                 let telemetry_settings = cx.update(|cx| *settings::get::<TelemetrySettings>(cx));
 
-                this.report_clickhouse_event(memory_event, telemetry_settings);
-                this.report_clickhouse_event(cpu_event, telemetry_settings);
+                this.report_memory_event(
+                    telemetry_settings,
+                    process.memory(),
+                    process.virtual_memory(),
+                );
+                this.report_cpu_event(
+                    telemetry_settings,
+                    process.cpu_usage(),
+                    system.cpus().len() as u32,
+                );
             }
         })
         .detach();
@@ -231,7 +238,123 @@ impl Telemetry {
         drop(state);
     }
 
-    pub fn report_clickhouse_event(
+    pub fn report_editor_event(
+        self: &Arc<Self>,
+        telemetry_settings: TelemetrySettings,
+        file_extension: Option<String>,
+        vim_mode: bool,
+        operation: &'static str,
+        copilot_enabled: bool,
+        copilot_enabled_for_language: bool,
+    ) {
+        let event = ClickhouseEvent::Editor {
+            file_extension,
+            vim_mode,
+            operation,
+            copilot_enabled,
+            copilot_enabled_for_language,
+            milliseconds_since_first_event: self.milliseconds_since_first_event(),
+        };
+
+        self.report_clickhouse_event(event, telemetry_settings)
+    }
+
+    pub fn report_copilot_event(
+        self: &Arc<Self>,
+        telemetry_settings: TelemetrySettings,
+        suggestion_id: Option<String>,
+        suggestion_accepted: bool,
+        file_extension: Option<String>,
+    ) {
+        let event = ClickhouseEvent::Copilot {
+            suggestion_id,
+            suggestion_accepted,
+            file_extension,
+            milliseconds_since_first_event: self.milliseconds_since_first_event(),
+        };
+
+        self.report_clickhouse_event(event, telemetry_settings)
+    }
+
+    pub fn report_assistant_event(
+        self: &Arc<Self>,
+        telemetry_settings: TelemetrySettings,
+        conversation_id: Option<String>,
+        kind: AssistantKind,
+        model: &'static str,
+    ) {
+        let event = ClickhouseEvent::Assistant {
+            conversation_id,
+            kind,
+            model,
+            milliseconds_since_first_event: self.milliseconds_since_first_event(),
+        };
+
+        self.report_clickhouse_event(event, telemetry_settings)
+    }
+
+    pub fn report_call_event(
+        self: &Arc<Self>,
+        telemetry_settings: TelemetrySettings,
+        operation: &'static str,
+        room_id: Option<u64>,
+        channel_id: Option<u64>,
+    ) {
+        let event = ClickhouseEvent::Call {
+            operation,
+            room_id,
+            channel_id,
+            milliseconds_since_first_event: self.milliseconds_since_first_event(),
+        };
+
+        self.report_clickhouse_event(event, telemetry_settings)
+    }
+
+    pub fn report_cpu_event(
+        self: &Arc<Self>,
+        telemetry_settings: TelemetrySettings,
+        usage_as_percentage: f32,
+        core_count: u32,
+    ) {
+        let event = ClickhouseEvent::Cpu {
+            usage_as_percentage,
+            core_count,
+            milliseconds_since_first_event: self.milliseconds_since_first_event(),
+        };
+
+        self.report_clickhouse_event(event, telemetry_settings)
+    }
+
+    pub fn report_memory_event(
+        self: &Arc<Self>,
+        telemetry_settings: TelemetrySettings,
+        memory_in_bytes: u64,
+        virtual_memory_in_bytes: u64,
+    ) {
+        let event = ClickhouseEvent::Memory {
+            memory_in_bytes,
+            virtual_memory_in_bytes,
+            milliseconds_since_first_event: self.milliseconds_since_first_event(),
+        };
+
+        self.report_clickhouse_event(event, telemetry_settings)
+    }
+
+    fn milliseconds_since_first_event(&self) -> i64 {
+        let mut state = self.state.lock();
+        match state.first_event_datetime {
+            Some(first_event_datetime) => {
+                let now: DateTime<Utc> = Utc::now();
+                now.timestamp_millis() - first_event_datetime.timestamp_millis()
+            }
+            None => {
+                state.first_event_datetime = Some(Utc::now());
+                0
+            }
+        }
+    }
+
+    fn report_clickhouse_event(
         self: &Arc<Self>,
         event: ClickhouseEvent,
         telemetry_settings: TelemetrySettings,
@@ -275,6 +398,7 @@ impl Telemetry {
 
     fn flush_clickhouse_events(self: &Arc<Self>) {
         let mut state = self.state.lock();
+        state.first_event_datetime = None;
         let mut events = mem::take(&mut state.clickhouse_events_queue);
         state.flush_clickhouse_events_task.take();
         drop(state);

crates/client2/Cargo.toml 🔗

@@ -12,6 +12,7 @@ doctest = false
 test-support = ["collections/test-support", "gpui/test-support", "rpc/test-support"]
 
 [dependencies]
+chrono = { version = "0.4", features = ["serde"] }
 collections = { path = "../collections" }
 db = { package = "db2", path = "../db2" }
 gpui = { package = "gpui2", path = "../gpui2" }

crates/client2/src/telemetry.rs 🔗

@@ -1,4 +1,5 @@
 use crate::{TelemetrySettings, ZED_SECRET_CLIENT_TOKEN, ZED_SERVER_URL};
+use chrono::{DateTime, Utc};
 use gpui::{serde_json, AppContext, AppMetadata, BackgroundExecutor, Task};
 use lazy_static::lazy_static;
 use parking_lot::Mutex;
@@ -29,6 +30,7 @@ struct TelemetryState {
     flush_clickhouse_events_task: Option<Task<()>>,
     log_file: Option<NamedTempFile>,
     is_staff: Option<bool>,
+    first_event_datetime: Option<DateTime<Utc>>,
 }
 
 const CLICKHOUSE_EVENTS_URL_PATH: &'static str = "/api/events";
@@ -75,29 +77,35 @@ pub enum ClickhouseEvent {
         vim_mode: bool,
         copilot_enabled: bool,
         copilot_enabled_for_language: bool,
+        milliseconds_since_first_event: i64,
     },
     Copilot {
         suggestion_id: Option<String>,
         suggestion_accepted: bool,
         file_extension: Option<String>,
+        milliseconds_since_first_event: i64,
     },
     Call {
         operation: &'static str,
         room_id: Option<u64>,
         channel_id: Option<u64>,
+        milliseconds_since_first_event: i64,
     },
     Assistant {
         conversation_id: Option<String>,
         kind: AssistantKind,
         model: &'static str,
+        milliseconds_since_first_event: i64,
     },
     Cpu {
         usage_as_percentage: f32,
         core_count: u32,
+        milliseconds_since_first_event: i64,
     },
     Memory {
         memory_in_bytes: u64,
         virtual_memory_in_bytes: u64,
+        milliseconds_since_first_event: i64,
     },
 }
 
@@ -135,6 +143,7 @@ impl Telemetry {
                 flush_clickhouse_events_task: Default::default(),
                 log_file: None,
                 is_staff: None,
+                first_event_datetime: None,
             }),
         });
 
@@ -190,16 +199,6 @@ impl Telemetry {
                     return;
                 };
 
-                let memory_event = ClickhouseEvent::Memory {
-                    memory_in_bytes: process.memory(),
-                    virtual_memory_in_bytes: process.virtual_memory(),
-                };
-
-                let cpu_event = ClickhouseEvent::Cpu {
-                    usage_as_percentage: process.cpu_usage(),
-                    core_count: system.cpus().len() as u32,
-                };
-
                 let telemetry_settings = if let Ok(telemetry_settings) =
                     cx.update(|cx| *TelemetrySettings::get_global(cx))
                 {
@@ -208,8 +207,16 @@ impl Telemetry {
                     break;
                 };
 
-                this.report_clickhouse_event(memory_event, telemetry_settings);
-                this.report_clickhouse_event(cpu_event, telemetry_settings);
+                this.report_memory_event(
+                    telemetry_settings,
+                    process.memory(),
+                    process.virtual_memory(),
+                );
+                this.report_cpu_event(
+                    telemetry_settings,
+                    process.cpu_usage(),
+                    system.cpus().len() as u32,
+                );
             }
         })
         .detach();
@@ -232,7 +239,123 @@ impl Telemetry {
         drop(state);
     }
 
-    pub fn report_clickhouse_event(
+    pub fn report_editor_event(
+        self: &Arc<Self>,
+        telemetry_settings: TelemetrySettings,
+        file_extension: Option<String>,
+        vim_mode: bool,
+        operation: &'static str,
+        copilot_enabled: bool,
+        copilot_enabled_for_language: bool,
+    ) {
+        let event = ClickhouseEvent::Editor {
+            file_extension,
+            vim_mode,
+            operation,
+            copilot_enabled,
+            copilot_enabled_for_language,
+            milliseconds_since_first_event: self.milliseconds_since_first_event(),
+        };
+
+        self.report_clickhouse_event(event, telemetry_settings)
+    }
+
+    pub fn report_copilot_event(
+        self: &Arc<Self>,
+        telemetry_settings: TelemetrySettings,
+        suggestion_id: Option<String>,
+        suggestion_accepted: bool,
+        file_extension: Option<String>,
+    ) {
+        let event = ClickhouseEvent::Copilot {
+            suggestion_id,
+            suggestion_accepted,
+            file_extension,
+            milliseconds_since_first_event: self.milliseconds_since_first_event(),
+        };
+
+        self.report_clickhouse_event(event, telemetry_settings)
+    }
+
+    pub fn report_assistant_event(
+        self: &Arc<Self>,
+        telemetry_settings: TelemetrySettings,
+        conversation_id: Option<String>,
+        kind: AssistantKind,
+        model: &'static str,
+    ) {
+        let event = ClickhouseEvent::Assistant {
+            conversation_id,
+            kind,
+            model,
+            milliseconds_since_first_event: self.milliseconds_since_first_event(),
+        };
+
+        self.report_clickhouse_event(event, telemetry_settings)
+    }
+
+    pub fn report_call_event(
+        self: &Arc<Self>,
+        telemetry_settings: TelemetrySettings,
+        operation: &'static str,
+        room_id: Option<u64>,
+        channel_id: Option<u64>,
+    ) {
+        let event = ClickhouseEvent::Call {
+            operation,
+            room_id,
+            channel_id,
+            milliseconds_since_first_event: self.milliseconds_since_first_event(),
+        };
+
+        self.report_clickhouse_event(event, telemetry_settings)
+    }
+
+    pub fn report_cpu_event(
+        self: &Arc<Self>,
+        telemetry_settings: TelemetrySettings,
+        usage_as_percentage: f32,
+        core_count: u32,
+    ) {
+        let event = ClickhouseEvent::Cpu {
+            usage_as_percentage,
+            core_count,
+            milliseconds_since_first_event: self.milliseconds_since_first_event(),
+        };
+
+        self.report_clickhouse_event(event, telemetry_settings)
+    }
+
+    pub fn report_memory_event(
+        self: &Arc<Self>,
+        telemetry_settings: TelemetrySettings,
+        memory_in_bytes: u64,
+        virtual_memory_in_bytes: u64,
+    ) {
+        let event = ClickhouseEvent::Memory {
+            memory_in_bytes,
+            virtual_memory_in_bytes,
+            milliseconds_since_first_event: self.milliseconds_since_first_event(),
+        };
+
+        self.report_clickhouse_event(event, telemetry_settings)
+    }
+
+    fn milliseconds_since_first_event(&self) -> i64 {
+        let mut state = self.state.lock();
+        match state.first_event_datetime {
+            Some(first_event_datetime) => {
+                let now: DateTime<Utc> = Utc::now();
+                now.timestamp_millis() - first_event_datetime.timestamp_millis()
+            }
+            None => {
+                state.first_event_datetime = Some(Utc::now());
+                0
+            }
+        }
+    }
+
+    fn report_clickhouse_event(
         self: &Arc<Self>,
         event: ClickhouseEvent,
         telemetry_settings: TelemetrySettings,
@@ -276,6 +399,7 @@ impl Telemetry {
 
     fn flush_clickhouse_events(self: &Arc<Self>) {
         let mut state = self.state.lock();
+        state.first_event_datetime = None;
         let mut events = mem::take(&mut state.clickhouse_events_queue);
         state.flush_clickhouse_events_task.take();
         drop(state);

crates/editor/src/editor.rs 🔗

@@ -24,7 +24,7 @@ use ::git::diff::DiffHunk;
 use aho_corasick::AhoCorasick;
 use anyhow::{anyhow, Context, Result};
 use blink_manager::BlinkManager;
-use client::{ClickhouseEvent, Client, Collaborator, ParticipantIndex, TelemetrySettings};
+use client::{Client, Collaborator, ParticipantIndex, TelemetrySettings};
 use clock::{Global, ReplicaId};
 use collections::{BTreeMap, Bound, HashMap, HashSet, VecDeque};
 use convert_case::{Case, Casing};
@@ -8946,12 +8946,12 @@ impl Editor {
         let telemetry = project.read(cx).client().telemetry().clone();
         let telemetry_settings = *settings::get::<TelemetrySettings>(cx);
 
-        let event = ClickhouseEvent::Copilot {
+        telemetry.report_copilot_event(
+            telemetry_settings,
             suggestion_id,
             suggestion_accepted,
             file_extension,
-        };
-        telemetry.report_clickhouse_event(event, telemetry_settings);
+        )
     }
 
     #[cfg(any(test, feature = "test-support"))]
@@ -8998,14 +8998,14 @@ impl Editor {
             .show_copilot_suggestions;
 
         let telemetry = project.read(cx).client().telemetry().clone();
-        let event = ClickhouseEvent::Editor {
+        telemetry.report_editor_event(
+            telemetry_settings,
             file_extension,
             vim_mode,
             operation,
             copilot_enabled,
             copilot_enabled_for_language,
-        };
-        telemetry.report_clickhouse_event(event, telemetry_settings)
+        )
     }
 
     /// Copy the highlighted chunks to the clipboard as JSON. The format is an array of lines,

crates/editor2/src/editor.rs 🔗

@@ -24,7 +24,7 @@ use ::git::diff::DiffHunk;
 use aho_corasick::AhoCorasick;
 use anyhow::{anyhow, Context as _, Result};
 use blink_manager::BlinkManager;
-use client::{ClickhouseEvent, Client, Collaborator, ParticipantIndex, TelemetrySettings};
+use client::{Client, Collaborator, ParticipantIndex, TelemetrySettings};
 use clock::ReplicaId;
 use collections::{BTreeMap, Bound, HashMap, HashSet, VecDeque};
 use convert_case::{Case, Casing};
@@ -8968,12 +8968,12 @@ impl Editor {
         let telemetry = project.read(cx).client().telemetry().clone();
         let telemetry_settings = *TelemetrySettings::get_global(cx);
 
-        let event = ClickhouseEvent::Copilot {
+        telemetry.report_copilot_event(
+            telemetry_settings,
             suggestion_id,
             suggestion_accepted,
             file_extension,
-        };
-        telemetry.report_clickhouse_event(event, telemetry_settings);
+        )
     }
 
     #[cfg(any(test, feature = "test-support"))]
@@ -9020,14 +9020,14 @@ impl Editor {
             .show_copilot_suggestions;
 
         let telemetry = project.read(cx).client().telemetry().clone();
-        let event = ClickhouseEvent::Editor {
+        telemetry.report_editor_event(
+            telemetry_settings,
             file_extension,
             vim_mode,
             operation,
             copilot_enabled,
             copilot_enabled_for_language,
-        };
-        telemetry.report_clickhouse_event(event, telemetry_settings)
+        )
     }
 
     /// Copy the highlighted chunks to the clipboard as JSON. The format is an array of lines,

crates/zed/src/main.rs 🔗

@@ -3,6 +3,7 @@
 
 use anyhow::{anyhow, Context, Result};
 use backtrace::Backtrace;
+use chrono::Utc;
 use cli::FORCE_CLI_MODE_ENV_VAR_NAME;
 use client::{
     self, Client, TelemetrySettings, UserStore, ZED_APP_VERSION, ZED_SECRET_CLIENT_TOKEN,
@@ -34,7 +35,6 @@ use std::{
         Arc, Weak,
     },
     thread,
-    time::{SystemTime, UNIX_EPOCH},
 };
 use util::{
     channel::{parse_zed_link, ReleaseChannel},
@@ -404,7 +404,7 @@ struct Panic {
     os_name: String,
     os_version: Option<String>,
     architecture: String,
-    panicked_on: u128,
+    panicked_on: i64,
     #[serde(skip_serializing_if = "Option::is_none")]
     installation_id: Option<String>,
     session_id: String,
@@ -490,10 +490,7 @@ fn init_panic_hook(app: &App, installation_id: Option<String>, session_id: Strin
                 .ok()
                 .map(|os_version| os_version.to_string()),
             architecture: env::consts::ARCH.into(),
-            panicked_on: SystemTime::now()
-                .duration_since(UNIX_EPOCH)
-                .unwrap()
-                .as_millis(),
+            panicked_on: Utc::now().timestamp_millis(),
             backtrace,
             installation_id: installation_id.clone(),
             session_id: session_id.clone(),

crates/zed2/src/main.rs 🔗

@@ -6,6 +6,7 @@
 
 use anyhow::{anyhow, Context as _, Result};
 use backtrace::Backtrace;
+use chrono::Utc;
 use cli::FORCE_CLI_MODE_ENV_VAR_NAME;
 use client::UserStore;
 use db::kvp::KEY_VALUE_STORE;
@@ -38,7 +39,6 @@ use std::{
         Arc,
     },
     thread,
-    time::{SystemTime, UNIX_EPOCH},
 };
 use theme::ActiveTheme;
 use util::{
@@ -172,7 +172,7 @@ fn main() {
         // })
         // .detach();
 
-        // client.telemetry().start(installation_id, session_id, cx);
+        client.telemetry().start(installation_id, session_id, cx);
 
         let app_state = Arc::new(AppState {
             languages,
@@ -428,7 +428,7 @@ struct Panic {
     os_name: String,
     os_version: Option<String>,
     architecture: String,
-    panicked_on: u128,
+    panicked_on: i64,
     #[serde(skip_serializing_if = "Option::is_none")]
     installation_id: Option<String>,
     session_id: String,
@@ -514,10 +514,7 @@ fn init_panic_hook(app: &App, installation_id: Option<String>, session_id: Strin
                 .as_ref()
                 .map(SemanticVersion::to_string),
             architecture: env::consts::ARCH.into(),
-            panicked_on: SystemTime::now()
-                .duration_since(UNIX_EPOCH)
-                .unwrap()
-                .as_millis(),
+            panicked_on: Utc::now().timestamp_millis(),
             backtrace,
             installation_id: installation_id.clone(),
             session_id: session_id.clone(),