Allow telemetry::event! with no properties (#22190)

CC @josephTLyons

Release Notes:

- N/A
This commit is contained in:
Conrad Irwin 2024-12-18 09:41:47 -07:00 committed by GitHub
parent 433cb99170
commit 77abf13f42
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 54 additions and 78 deletions

View file

@ -1,6 +1,3 @@
use std::sync::Arc;
use client::telemetry::Telemetry;
use gpui::{AnyElement, Div, StyleRefinement};
use smallvec::SmallVec;
use ui::{prelude::*, ButtonLike};
@ -8,17 +5,15 @@ use ui::{prelude::*, ButtonLike};
#[derive(IntoElement)]
pub struct FeatureUpsell {
base: Div,
telemetry: Arc<Telemetry>,
text: SharedString,
docs_url: Option<SharedString>,
children: SmallVec<[AnyElement; 2]>,
}
impl FeatureUpsell {
pub fn new(telemetry: Arc<Telemetry>, text: impl Into<SharedString>) -> Self {
pub fn new(text: impl Into<SharedString>) -> Self {
Self {
base: h_flex(),
telemetry,
text: text.into(),
docs_url: None,
children: SmallVec::new(),
@ -67,12 +62,13 @@ impl RenderOnce for FeatureUpsell {
.child(Icon::new(IconName::ArrowUpRight)),
)
.on_click({
let telemetry = self.telemetry.clone();
let docs_url = docs_url.clone();
move |_event, cx| {
telemetry.report_app_event(format!(
"feature upsell: viewed docs ({docs_url})"
));
telemetry::event!(
"Documentation Viewed",
source = "Feature Upsell",
url = docs_url,
);
cx.open_url(&docs_url)
}
}),