ai onboarding: Add telemetry event capturing (#34960)

Danilo Leal , Katie Geer , and Joseph T. Lyons created

Release Notes:

- N/A

Co-authored-by: Katie Geer <katie@zed.dev>
Co-authored-by: Joseph T. Lyons <JosephTLyons@gmail.com>

Change summary

Cargo.lock                                |  1 
crates/agent_ui/src/message_editor.rs     |  4 ++
crates/ai_onboarding/Cargo.toml           |  1 
crates/ai_onboarding/src/ai_onboarding.rs | 37 ++++++++++++++++++++----
4 files changed, 37 insertions(+), 6 deletions(-)

Detailed changes

Cargo.lock 🔗

@@ -347,6 +347,7 @@ dependencies = [
  "proto",
  "serde",
  "smallvec",
+ "telemetry",
  "ui",
  "workspace-hack",
  "zed_actions",

crates/agent_ui/src/message_editor.rs 🔗

@@ -910,6 +910,10 @@ impl MessageEditor {
                                                         .on_click({
                                                             let focus_handle = focus_handle.clone();
                                                             move |_event, window, cx| {
+                                                                telemetry::event!(
+                                                                    "Agent Message Sent",
+                                                                    agent = "zed",
+                                                                );
                                                                 focus_handle.dispatch_action(
                                                                     &Chat, window, cx,
                                                                 );

crates/ai_onboarding/Cargo.toml 🔗

@@ -22,6 +22,7 @@ language_model.workspace = true
 proto.workspace = true
 serde.workspace = true
 smallvec.workspace = true
+telemetry.workspace = true
 ui.workspace = true
 workspace-hack.workspace = true
 zed_actions.workspace = true

crates/ai_onboarding/src/ai_onboarding.rs 🔗

@@ -183,6 +183,7 @@ impl ZedAiOnboarding {
                         .full_width()
                         .style(ButtonStyle::Tinted(ui::TintColor::Accent))
                         .on_click(move |_, _window, cx| {
+                            telemetry::event!("Upgrade To Pro Clicked", state = "young-account");
                             cx.open_url(&zed_urls::upgrade_to_zed_pro_url(cx))
                         }),
                 )
@@ -210,6 +211,7 @@ impl ZedAiOnboarding {
                         .full_width()
                         .style(ButtonStyle::Tinted(ui::TintColor::Accent))
                         .on_click(move |_, _window, cx| {
+                            telemetry::event!("Start Trial Clicked", state = "post-sign-in");
                             cx.open_url(&zed_urls::start_trial_url(cx))
                         }),
                 )
@@ -234,7 +236,10 @@ impl ZedAiOnboarding {
                     .icon(IconName::ArrowUpRight)
                     .icon_color(Color::Muted)
                     .icon_size(IconSize::XSmall)
-                    .on_click(move |_, _window, cx| cx.open_url(&zed_urls::terms_of_service(cx))),
+                    .on_click(move |_, _window, cx| {
+                        telemetry::event!("Review Terms of Service Click");
+                        cx.open_url(&zed_urls::terms_of_service(cx))
+                    }),
             )
             .child(
                 Button::new("accept_terms", "Accept")
@@ -242,7 +247,9 @@ impl ZedAiOnboarding {
                     .style(ButtonStyle::Tinted(TintColor::Accent))
                     .on_click({
                         let callback = self.accept_terms_of_service.clone();
-                        move |_, window, cx| (callback)(window, cx)
+                        move |_, window, cx| {
+                            telemetry::event!("Accepted Terms of Service");
+                            (callback)(window, cx)}
                     }),
             )
             .into_any_element()
@@ -267,7 +274,10 @@ impl ZedAiOnboarding {
                     .style(ButtonStyle::Tinted(ui::TintColor::Accent))
                     .on_click({
                         let callback = self.sign_in.clone();
-                        move |_, window, cx| callback(window, cx)
+                        move |_, window, cx| {
+                            telemetry::event!("Start Trial Clicked", state = "pre-sign-in");
+                            callback(window, cx)
+                        }
                     }),
             )
             .into_any_element()
@@ -294,7 +304,13 @@ impl ZedAiOnboarding {
                                     IconButton::new("dismiss_onboarding", IconName::Close)
                                         .icon_size(IconSize::Small)
                                         .tooltip(Tooltip::text("Dismiss"))
-                                        .on_click(move |_, window, cx| callback(window, cx)),
+                                        .on_click(move |_, window, cx| {
+                                            telemetry::event!(
+                                                "Banner Dismissed",
+                                                source = "AI Onboarding",
+                                            );
+                                            callback(window, cx)
+                                        }),
                                 ),
                             )
                         },
@@ -331,7 +347,13 @@ impl ZedAiOnboarding {
                             IconButton::new("dismiss_onboarding", IconName::Close)
                                 .icon_size(IconSize::Small)
                                 .tooltip(Tooltip::text("Dismiss"))
-                                .on_click(move |_, window, cx| callback(window, cx)),
+                                .on_click(move |_, window, cx| {
+                                    telemetry::event!(
+                                        "Banner Dismissed",
+                                        source = "AI Onboarding",
+                                    );
+                                    callback(window, cx)
+                                }),
                         ),
                     )
                 },
@@ -359,7 +381,10 @@ impl ZedAiOnboarding {
                     .style(ButtonStyle::Outlined)
                     .on_click({
                         let callback = self.continue_with_zed_ai.clone();
-                        move |_, window, cx| callback(window, cx)
+                        move |_, window, cx| {
+                            telemetry::event!("Banner Dismissed", source = "AI Onboarding");
+                            callback(window, cx)
+                        }
                     }),
             )
             .into_any_element()