Mountain/Binary/Build/PostHogPlugin/
CaptureEvent.rs1
2use crate::Binary::Build::PostHogPlugin::{CaptureAllowed, Client, DistinctId};
7
8pub fn Fn(EventName:&str, Properties:Option<Vec<(&str, &str)>>) {
9 if !CaptureAllowed::Fn() {
10 return;
11 }
12
13 let Some(C) = Client::CLIENT.get() else { return };
14
15 let mut Event = posthog_rs::Event::new(EventName, &DistinctId::Fn());
16
17 let _ = Event.insert_prop("$app", "fiddee");
18
19 let _ = Event.insert_prop("$app_version", "0.0.1");
20
21 let _ = Event.insert_prop("$build_mode", "debug");
22
23 let _ = Event.insert_prop("$component", "mountain");
24
25 if let Some(Props) = Properties {
26 for (Key, Value) in Props {
27 let _ = Event.insert_prop(Key, Value);
28 }
29 }
30
31 let _ = C.capture(Event);
32}