Expand description
§PostHog Plugin
Debug-only PostHog analytics integration. Captures lifecycle events,
IPC commands, and errors during dev runs; compile-time gated to
cfg(debug_assertions) so release builds drop the entire stack.
Layout (one export per file, file name = identity):
Initialize::Fn- boot the global ingestion client.CaptureEvent::Fn- generic event emitter with$app/$componentstandard props.CaptureError::Fn- emit underland:mountain:errorwith tag + message.CaptureIPC::Fn- emit underland:mountain:ipc:invokewith method name.CaptureHandler::Fn- emit underland:mountain:handler:completewithfeature+duration_ms+ok. Powers the Feature Parity dashboard’s Node-vs-Rust handler latency comparison.
Module-private helpers:
Constants-Authorize/Beam/Report/Brandbaked from.env.Land.PostHog.Client::CLIENT-OnceLock<posthog_rs::Client>singleton.DistinctId::Fn- pinned-or-derived dev distinct id.CaptureAllowed::Fn-debug_assertions&&Report != off.
Modules§
- Capture
Allowed 🔒 - Capture gate. Combines the compile-time
debug_assertionscheck with the master telemetry kill switch (Capture) and the per-pipeReporttoggle, both baked at build time. Cheap early-exit consulted by every PostHog capture path. - Capture
Error - Convenience wrapper that emits an error event under the
land:mountain:errorname witherror_tag+error_message. The Errors & Reliability dashboard rolls these up alongside Cocoon / Sky errors via a singleevent LIKE 'land:%:error'clause. - Capture
Event - Capture a named event with optional properties. Stamps the standard
Mountain identity (
$app,$app_version,$build_mode,$component) on every event before merging caller props. - Capture
Handler - Capture a
land:mountain:handler:completeevent for one IPC handler invocation.Featureis the Mountain-side route key (e.g.file:read,extensions:getInstalled);DurationMsmeasures the handler body only (Tauri-frame overhead excluded);Okreports whether the handler returnedOk(_). - CaptureIPC
- Convenience wrapper for IPC dispatch instrumentation. Emits
land:mountain:ipc:invokewith the wiremethodname. Pair withCaptureHandler::Fnto also stampland:mountain:handler:completewithduration_msonce the handler returns. - Client 🔒
- Module-private singleton holding the PostHog ingestion client.
Populated once by
Initialize::Fn; everyCapture*::Fnreads through this static. - Constants 🔒
- Build-time PostHog credentials baked from
.env.Land.PostHogviacargo:rustc-env.env!always resolves at compile time so even a clean checkout builds without a populated.env. - Distinct
Id 🔒 - Machine-stable distinct ID for the dev session. When the
Brandenv var is populated, it wins - same value across every process in the same dev run. Otherwise falls back toland-dev-<USER>. - Hydrate
Runtime Environment - Hydrate the running process’s environment from the compile-baked
Constantsso child processes spawned later (Cocoon Node, Sky webview) see the same telemetry config Mountain itself was built with - even when the user runs the bare binary without sourcing.env.Land.PostHog. - Initialize
- Bring up the global PostHog client and emit
land:mountain:session:start. Must be called once during boot; re-entrancy is safe because the underlyingOnceLock::setreturnsErron subsequent attempts.