edit predictions: Onboarding funnel telemetry (#24237)

Release Notes:

- N/A
This commit is contained in:
Agus Zubiaga 2025-02-05 12:26:11 -03:00 committed by GitHub
parent 0a89d1a479
commit 630d0add19
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 82 additions and 15 deletions

View file

@ -6,6 +6,8 @@ use settings::SettingsStore;
use ui::{prelude::*, ButtonLike, Tooltip};
use util::ResultExt;
use crate::onboarding_event;
/// Prompts the user to try Zed's Edit Prediction feature
pub struct ZedPredictBanner {
dismissed: bool,
@ -53,6 +55,7 @@ impl ZedPredictBanner {
}
fn dismiss(&mut self, cx: &mut Context<Self>) {
onboarding_event!("Banner Dismissed");
persist_dismissed(cx);
self.dismissed = true;
cx.notify();
@ -107,6 +110,7 @@ impl Render for ZedPredictBanner {
),
)
.on_click(|_, window, cx| {
onboarding_event!("Banner Clicked");
window.dispatch_action(Box::new(zed_actions::OpenZedPredictOnboarding), cx)
}),
)

View file

@ -1,6 +1,6 @@
use std::{sync::Arc, time::Duration};
use crate::ZED_PREDICT_DATA_COLLECTION_CHOICE;
use crate::{onboarding_event, ZED_PREDICT_DATA_COLLECTION_CHOICE};
use client::{Client, UserStore};
use db::kvp::KEY_VALUE_STORE;
use feature_flags::FeatureFlagAppExt as _;
@ -61,16 +61,22 @@ impl ZedPredictModal {
fn view_terms(&mut self, _: &ClickEvent, _: &mut Window, cx: &mut Context<Self>) {
cx.open_url("https://zed.dev/terms-of-service");
cx.notify();
onboarding_event!("ToS Link Clicked");
}
fn view_blog(&mut self, _: &ClickEvent, _: &mut Window, cx: &mut Context<Self>) {
cx.open_url("https://zed.dev/blog/"); // TODO Add the link when live
cx.notify();
onboarding_event!("Blog Link clicked");
}
fn inline_completions_doc(&mut self, _: &ClickEvent, _: &mut Window, cx: &mut Context<Self>) {
cx.open_url("https://zed.dev/docs/configuring-zed#inline-completions");
cx.notify();
onboarding_event!("Docs Link Clicked");
}
fn accept_and_enable(&mut self, _: &ClickEvent, window: &mut Window, cx: &mut Context<Self>) {
@ -106,6 +112,11 @@ impl ZedPredictModal {
})
})
.detach_and_notify_err(window, cx);
onboarding_event!(
"Enable Clicked",
data_collection_opted_in = self.data_collection_opted_in,
);
}
fn sign_in(&mut self, _: &ClickEvent, window: &mut Window, cx: &mut Context<Self>) {
@ -122,12 +133,15 @@ impl ZedPredictModal {
this.update(&mut cx, |this, cx| {
this.sign_in_status = status;
onboarding_event!("Signed In");
cx.notify()
})?;
result
})
.detach_and_notify_err(window, cx);
onboarding_event!("Sign In Clicked");
}
fn cancel(&mut self, _: &menu::Cancel, _: &mut Window, cx: &mut Context<Self>) {
@ -159,6 +173,7 @@ impl Render for ZedPredictModal {
.track_focus(&self.focus_handle(cx))
.on_action(cx.listener(Self::cancel))
.on_action(cx.listener(|_, _: &menu::Cancel, _window, cx| {
onboarding_event!("Cancelled", trigger = "Action");
cx.emit(DismissEvent);
}))
.on_any_mouse_down(cx.listener(|this, _: &MouseDownEvent, window, _cx| {
@ -241,6 +256,7 @@ impl Render for ZedPredictModal {
.child(h_flex().absolute().top_2().right_2().child(
IconButton::new("cancel", IconName::X).on_click(cx.listener(
|_, _: &ClickEvent, _window, cx| {
onboarding_event!("Cancelled", trigger = "X click");
cx.emit(DismissEvent);
},
)),
@ -302,7 +318,7 @@ impl Render for ZedPredictModal {
.label("Read and accept the")
.on_click(cx.listener(move |this, state, _window, cx| {
this.terms_of_service = *state == ToggleState::Selected;
cx.notify()
cx.notify();
})),
)
.child(
@ -340,7 +356,11 @@ impl Render for ZedPredictModal {
.on_click(cx.listener(|this, _, _, cx| {
this.data_collection_expanded =
!this.data_collection_expanded;
cx.notify()
cx.notify();
if this.data_collection_expanded {
onboarding_event!("Data Collection Learn More Clicked");
}
})),
),
)

View file

@ -0,0 +1,9 @@
#[macro_export]
macro_rules! onboarding_event {
($name:expr) => {
telemetry::event!($name, source = "Edit Prediction Onboarding");
};
($name:expr, $($key:ident $(= $value:expr)?),+ $(,)?) => {
telemetry::event!($name, source = "Edit Prediction Onboarding", $($key $(= $value)?),+);
};
}

View file

@ -52,6 +52,8 @@ impl RateCompletionModal {
pub fn toggle(workspace: &mut Workspace, window: &mut Window, cx: &mut Context<Workspace>) {
if let Some(zeta) = Zeta::global(cx) {
workspace.toggle_modal(window, cx, |_window, cx| RateCompletionModal::new(zeta, cx));
telemetry::event!("Rate Completion Modal Open", source = "Edit Prediction");
}
}

View file

@ -3,6 +3,7 @@ mod init;
mod license_detection;
mod onboarding_banner;
mod onboarding_modal;
mod onboarding_telemetry;
mod rate_completion_modal;
pub(crate) use completion_diff_element::*;