Rework call events api
There were time when events with bad data were being emitted. What we found was that places where certain collaboration-related code could fail, like sending an, would still send events, and those events be in a bad state, as certain elements weren't constructed as expected, thus missing in the event. The new API guarantees that we have data in the correct configuration. In the future, we will add events for certain types of failures within Zed. Co-Authored-By: Julia <30666851+ForLoveOfCats@users.noreply.github.com>
This commit is contained in:
parent
e263805847
commit
0897ed561f
3 changed files with 62 additions and 63 deletions
|
@ -206,9 +206,14 @@ impl ActiveCall {
|
||||||
|
|
||||||
cx.spawn(|this, mut cx| async move {
|
cx.spawn(|this, mut cx| async move {
|
||||||
let result = invite.await;
|
let result = invite.await;
|
||||||
|
if result.is_ok() {
|
||||||
|
this.update(&mut cx, |this, cx| this.report_call_event("invite", cx));
|
||||||
|
} else {
|
||||||
|
// TODO: Resport collaboration error
|
||||||
|
}
|
||||||
|
|
||||||
this.update(&mut cx, |this, cx| {
|
this.update(&mut cx, |this, cx| {
|
||||||
this.pending_invites.remove(&called_user_id);
|
this.pending_invites.remove(&called_user_id);
|
||||||
this.report_call_event("invite", cx);
|
|
||||||
cx.notify();
|
cx.notify();
|
||||||
});
|
});
|
||||||
result
|
result
|
||||||
|
@ -273,13 +278,7 @@ impl ActiveCall {
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.take()
|
.take()
|
||||||
.ok_or_else(|| anyhow!("no incoming call"))?;
|
.ok_or_else(|| anyhow!("no incoming call"))?;
|
||||||
Self::report_call_event_for_room(
|
report_call_event_for_room("decline incoming", call.room_id, None, &self.client, cx);
|
||||||
"decline incoming",
|
|
||||||
Some(call.room_id),
|
|
||||||
None,
|
|
||||||
&self.client,
|
|
||||||
cx,
|
|
||||||
);
|
|
||||||
self.client.send(proto::DeclineCall {
|
self.client.send(proto::DeclineCall {
|
||||||
room_id: call.room_id,
|
room_id: call.room_id,
|
||||||
})?;
|
})?;
|
||||||
|
@ -409,31 +408,46 @@ impl ActiveCall {
|
||||||
&self.pending_invites
|
&self.pending_invites
|
||||||
}
|
}
|
||||||
|
|
||||||
fn report_call_event(&self, operation: &'static str, cx: &AppContext) {
|
pub fn report_call_event(&self, operation: &'static str, cx: &AppContext) {
|
||||||
let (room_id, channel_id) = match self.room() {
|
if let Some(room) = self.room() {
|
||||||
Some(room) => {
|
let room = room.read(cx);
|
||||||
let room = room.read(cx);
|
report_call_event_for_room(operation, room.id(), room.channel_id(), &self.client, cx);
|
||||||
(Some(room.id()), room.channel_id())
|
}
|
||||||
}
|
|
||||||
None => (None, None),
|
|
||||||
};
|
|
||||||
Self::report_call_event_for_room(operation, room_id, channel_id, &self.client, cx)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn report_call_event_for_room(
|
|
||||||
operation: &'static str,
|
|
||||||
room_id: Option<u64>,
|
|
||||||
channel_id: Option<u64>,
|
|
||||||
client: &Arc<Client>,
|
|
||||||
cx: &AppContext,
|
|
||||||
) {
|
|
||||||
let telemetry = client.telemetry();
|
|
||||||
let telemetry_settings = *settings::get::<TelemetrySettings>(cx);
|
|
||||||
let event = ClickhouseEvent::Call {
|
|
||||||
operation,
|
|
||||||
room_id,
|
|
||||||
channel_id,
|
|
||||||
};
|
|
||||||
telemetry.report_clickhouse_event(event, telemetry_settings);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn report_call_event_for_room(
|
||||||
|
operation: &'static str,
|
||||||
|
room_id: u64,
|
||||||
|
channel_id: Option<u64>,
|
||||||
|
client: &Arc<Client>,
|
||||||
|
cx: &AppContext,
|
||||||
|
) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn report_call_event_for_channel(
|
||||||
|
operation: &'static str,
|
||||||
|
channel_id: u64,
|
||||||
|
client: &Arc<Client>,
|
||||||
|
cx: &AppContext,
|
||||||
|
) {
|
||||||
|
let room = ActiveCall::global(cx).read(cx).room();
|
||||||
|
|
||||||
|
let telemetry = client.telemetry();
|
||||||
|
let telemetry_settings = *settings::get::<TelemetrySettings>(cx);
|
||||||
|
|
||||||
|
let event = ClickhouseEvent::Call {
|
||||||
|
operation,
|
||||||
|
room_id: room.map(|r| r.read(cx).id()),
|
||||||
|
channel_id: Some(channel_id),
|
||||||
|
};
|
||||||
|
telemetry.report_clickhouse_event(event, telemetry_settings);
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use call::ActiveCall;
|
use call::report_call_event_for_channel;
|
||||||
use channel::{ChannelBuffer, ChannelBufferEvent, ChannelId};
|
use channel::{ChannelBuffer, ChannelBufferEvent, ChannelId};
|
||||||
use client::proto;
|
use client::proto;
|
||||||
use clock::ReplicaId;
|
use clock::ReplicaId;
|
||||||
|
@ -42,14 +42,9 @@ impl ChannelView {
|
||||||
cx.spawn(|mut cx| async move {
|
cx.spawn(|mut cx| async move {
|
||||||
let channel_view = channel_view.await?;
|
let channel_view = channel_view.await?;
|
||||||
pane.update(&mut cx, |pane, cx| {
|
pane.update(&mut cx, |pane, cx| {
|
||||||
let room_id = ActiveCall::global(cx)
|
report_call_event_for_channel(
|
||||||
.read(cx)
|
|
||||||
.room()
|
|
||||||
.map(|room| room.read(cx).id());
|
|
||||||
ActiveCall::report_call_event_for_room(
|
|
||||||
"open channel notes",
|
"open channel notes",
|
||||||
room_id,
|
channel_id,
|
||||||
Some(channel_id),
|
|
||||||
&workspace.read(cx).app_state().client,
|
&workspace.read(cx).app_state().client,
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
|
|
|
@ -10,7 +10,7 @@ mod panel_settings;
|
||||||
mod project_shared_notification;
|
mod project_shared_notification;
|
||||||
mod sharing_status_indicator;
|
mod sharing_status_indicator;
|
||||||
|
|
||||||
use call::{ActiveCall, Room};
|
use call::{report_call_event_for_room, ActiveCall, Room};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions,
|
actions,
|
||||||
geometry::{
|
geometry::{
|
||||||
|
@ -55,18 +55,18 @@ pub fn toggle_screen_sharing(_: &ToggleScreenSharing, cx: &mut AppContext) {
|
||||||
let client = call.client();
|
let client = call.client();
|
||||||
let toggle_screen_sharing = room.update(cx, |room, cx| {
|
let toggle_screen_sharing = room.update(cx, |room, cx| {
|
||||||
if room.is_screen_sharing() {
|
if room.is_screen_sharing() {
|
||||||
ActiveCall::report_call_event_for_room(
|
report_call_event_for_room(
|
||||||
"disable screen share",
|
"disable screen share",
|
||||||
Some(room.id()),
|
room.id(),
|
||||||
room.channel_id(),
|
room.channel_id(),
|
||||||
&client,
|
&client,
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
Task::ready(room.unshare_screen(cx))
|
Task::ready(room.unshare_screen(cx))
|
||||||
} else {
|
} else {
|
||||||
ActiveCall::report_call_event_for_room(
|
report_call_event_for_room(
|
||||||
"enable screen share",
|
"enable screen share",
|
||||||
Some(room.id()),
|
room.id(),
|
||||||
room.channel_id(),
|
room.channel_id(),
|
||||||
&client,
|
&client,
|
||||||
cx,
|
cx,
|
||||||
|
@ -83,23 +83,13 @@ pub fn toggle_mute(_: &ToggleMute, cx: &mut AppContext) {
|
||||||
if let Some(room) = call.room().cloned() {
|
if let Some(room) = call.room().cloned() {
|
||||||
let client = call.client();
|
let client = call.client();
|
||||||
room.update(cx, |room, cx| {
|
room.update(cx, |room, cx| {
|
||||||
if room.is_muted(cx) {
|
let operation = if room.is_muted(cx) {
|
||||||
ActiveCall::report_call_event_for_room(
|
"enable microphone"
|
||||||
"enable microphone",
|
|
||||||
Some(room.id()),
|
|
||||||
room.channel_id(),
|
|
||||||
&client,
|
|
||||||
cx,
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
ActiveCall::report_call_event_for_room(
|
"disable microphone"
|
||||||
"disable microphone",
|
};
|
||||||
Some(room.id()),
|
report_call_event_for_room(operation, room.id(), room.channel_id(), &client, cx);
|
||||||
room.channel_id(),
|
|
||||||
&client,
|
|
||||||
cx,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
room.toggle_mute(cx)
|
room.toggle_mute(cx)
|
||||||
})
|
})
|
||||||
.map(|task| task.detach_and_log_err(cx))
|
.map(|task| task.detach_and_log_err(cx))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue