diff --git a/crates/copilot/src/copilot.rs b/crates/copilot/src/copilot.rs index b9e850b371..07c54c7785 100644 --- a/crates/copilot/src/copilot.rs +++ b/crates/copilot/src/copilot.rs @@ -47,9 +47,21 @@ pub fn init(http: Arc, node_runtime: Arc, cx: &mut }); cx.set_global(copilot.clone()); - ////////////////////////////////////// - // SUBSCRIBE TO COPILOT EVENTS HERE // - ////////////////////////////////////// + cx.subscribe(&copilot, |_, event, _| { + match event { + Event::CompletionAccepted { uuid, file_type } => { + // Build event object and pass it in + // telemetry.report_clickhouse_event(event, settings.telemetry()) + } + Event::CompletionsDiscarded { uuids, file_type } => { + for uuid in uuids { + // Build event object and pass it in + // telemetry.report_clickhouse_event(event, settings.telemetry()) + } + } + }; + }) + .detach(); cx.observe(&copilot, |handle, cx| { let status = handle.read(cx).status();