Report editor open and save events to Amplitude
Co-authored-by: Max Brunsfeld <max@zed.dev>
This commit is contained in:
parent
f0c50c1e0a
commit
824fdb54e6
8 changed files with 137 additions and 35 deletions
|
@ -29,6 +29,7 @@ use gpui::{
|
|||
geometry::vector::{vec2f, Vector2F},
|
||||
impl_actions, impl_internal_actions,
|
||||
platform::CursorStyle,
|
||||
serde_json::json,
|
||||
text_layout, AnyViewHandle, AppContext, AsyncAppContext, ClipboardItem, Element, ElementBox,
|
||||
Entity, ModelHandle, MouseButton, MutableAppContext, RenderContext, Subscription, Task, View,
|
||||
ViewContext, ViewHandle, WeakViewHandle,
|
||||
|
@ -1053,6 +1054,7 @@ impl Editor {
|
|||
let editor_created_event = EditorCreated(cx.handle());
|
||||
cx.emit_global(editor_created_event);
|
||||
|
||||
this.report_event("open editor", cx);
|
||||
this
|
||||
}
|
||||
|
||||
|
@ -5928,6 +5930,25 @@ impl Editor {
|
|||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn report_event(&self, name: &str, cx: &AppContext) {
|
||||
if let Some((project, file)) = self.project.as_ref().zip(
|
||||
self.buffer
|
||||
.read(cx)
|
||||
.as_singleton()
|
||||
.and_then(|b| b.read(cx).file()),
|
||||
) {
|
||||
project.read(cx).client().report_event(
|
||||
name,
|
||||
json!({
|
||||
"file_extension": file
|
||||
.path()
|
||||
.extension()
|
||||
.and_then(|e| e.to_str())
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl EditorSnapshot {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue