1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//! Per-endpoint product-analytics emission helper.
//!
//! Mirrors the `send_telemetry("… API Endpoint Invoked", user.id, {…})`
//! calls in the Python FastAPI routers
//! (`cognee/api/v1/*/routers/get_*_router.py`). Each `/api/v1/*` handler
//! calls [`emit`] near its top so the wire payload matches Python.
//!
//! The whole surface is gated by the `telemetry` cargo feature: with it
//! off (e.g. a `--no-default-features` build), [`emit`] compiles to a
//! noop and `cognee-telemetry` is not even a dependency. Callers pass a
//! fully-built `serde_json::Value::Object` of `additional_properties`
//! and never need a `#[cfg(...)]` of their own.
//!
//! `cognee_version` is intentionally **omitted** from the per-endpoint
//! properties: the base `send_telemetry` payload already carries it at
//! `properties.cognee_version`, so the on-the-wire field is present
//! exactly once and matches Python (which spreads it into
//! `additional_properties`).
use Value;
use Uuid;
/// Emit a `"… API Endpoint Invoked"` analytics event for `user_id` with
/// the given `additional_properties` object.
///
/// No-op when the `telemetry` feature is disabled. Fire-and-forget —
/// returns immediately; transport errors are swallowed at debug level on
/// the `cognee.telemetry` tracing target.
/// No-op stand-in when the `telemetry` feature is disabled. Keeps router
/// handlers free of `#[cfg]` clutter.