Skip to main content

Mountain/Binary/Build/PostHogPlugin/
CaptureEvent.rs

1#![allow(non_snake_case)]
2
3//! Capture a named event with optional properties. Stamps the standard
4//! Mountain identity (`$app`, `$app_version`, `$build_mode`,
5//! `$component`) on every event before merging caller props.
6
7use crate::Binary::Build::PostHogPlugin::{CaptureAllowed, Client, DistinctId};
8
9pub fn Fn(EventName:&str, Properties:Option<Vec<(&str, &str)>>) {
10	if !CaptureAllowed::Fn() {
11		return;
12	}
13
14	let Some(C) = Client::CLIENT.get() else { return };
15
16	let mut Event = posthog_rs::Event::new(EventName, &DistinctId::Fn());
17
18	let _ = Event.insert_prop("$app", "land-editor");
19	let _ = Event.insert_prop("$app_version", "0.0.1");
20	let _ = Event.insert_prop("$build_mode", "debug");
21	let _ = Event.insert_prop("$component", "mountain");
22
23	if let Some(Props) = Properties {
24		for (Key, Value) in Props {
25			let _ = Event.insert_prop(Key, Value);
26		}
27	}
28
29	let _ = C.capture(Event);
30}