Agent analytics

Product analytics for the AI agents and chatbots you ship to your users: how many people use the agent, what they ask, whether conversations get resolved,...

Embed
Preview of the card
<a href="https://lucidace.com/help/agent-analytics"><img src="https://lucidace.com/help/_api/public/orgs/af34862a-c837-4478-8335-0505efe40459/spaces/2f4b888b-c4e6-488b-81bd-6e838fb12d2e/pages/faad4f3e-90a7-4a38-b06a-b33b4f24cf8d/social-card.svg?v=3e7ae33eec8b" alt="Agent analytics" width="600" height="315"></a>

Product analytics for the AI agents and chatbots you ship to your users: how many people use the agent, what they ask, whether conversations get resolved, where users rephrase in frustration, and whether agent users retain better. Conversations and outcomes are ordinary analytics objects: funnel steps, trend series, retention events, cohort criteria and breakdowns.

Out of scope by design of the seam: tokens, latency, model names and traces of LLM calls. That telemetry belongs to Watchtower. Lucida never captures or charts it. $ai_trace_id (the 32 hex digit W3C trace id of the agent run, the same id Watchtower records) is the join key between the two: a conversation that carries it links to the trace in Watchtower, and shows its LLM cost once the Watchtower connector has synced that trace's runs. Cost per user is then the sum over a person's conversations.

To get the cost column, connect Watchtower (Connectors, Watchtower) with a read token and stream llm_runs; send $ai_trace_id on $ai_conversation_started. The cost is Watchtower's number for the trace (sum of its runs, USD). It is empty for a conversation with no trace id, with no synced runs yet, or without the connector. Runs of the last hour are re-read, so a recent conversation's cost can still grow.

Capture

Text is not collected by default. Messages carry length, a similarity fingerprint (for rephrase detection) and a local sentiment flag; the words themselves stay on the device. Opt in with captureText, and even then emails, card numbers and phone numbers are masked on the client (the same detectors as replay masking) and masked again by the worker. Consent and opt-out apply exactly as for every other event.

Browser:

const lucida = init("lc_pk_...", { ai: { captureText: false } });
const convo = lucida.ai.startConversation({ agentName: "support-bot", agentVersion: "2.3", traceId });
convo.message("user", prompt);
convo.message("assistant", reply);
convo.feedback({ kind: "thumbs", value: 1 });
convo.end("resolved", "refund_issued");

Node (lucida.ai.startConversation({ distinctId, agentName })) and Python (client.ai_conversation(distinct_id, agent_name="support-bot"), Lucida(..., capture_text=False)) expose the same handle: message, feedback, end, outcome (a resolution known later). Any other SDK can send the events directly:

Event

Properties

$ai_conversation_started

common props

$ai_message

$ai_role (user/assistant), $ai_message_index, $ai_text_length; user messages also $ai_text_hash (simhash64 hex) and $ai_sentiment (-1/0/1); $ai_text only with text capture

$ai_feedback

$ai_feedback_kind (thumbs/rating/comment), $ai_feedback_value (thumbs 1/-1, rating 1-5), $ai_feedback_comment only with text capture

$ai_conversation_ended

optional $ai_outcome (resolved, unresolved, escalated, abandoned, error), $ai_resolution

$ai_outcome

same as ended, sent later

Common props: $ai_conversation_id (required), $ai_agent_name, $ai_agent_version, $ai_topic, $ai_use_case (your own labels win over AI labels), $ai_trace_id (32 hex chars, else dropped). The fingerprint, sentiment lexicon and redaction are specified by the conformance vectors in testdata/agent-analytics/ so every SDK computes the same values.

Admin option: PUT /v1/projects/{id}/settings/ingest with drop_agent_text: true removes $ai_text and $ai_feedback_comment server-side even when an SDK sends them. All ingest settings: Ingest settings reference.

Processor pattern (embedded products)

When you hold your customer's end users as a processor (your product is embedded in theirs), send $ai_* events with $process_person_profile: false, distinct_id set to conv_<conversation id>, and no message text or email. No person profile is created.

  • Conversation-keyed metrics work: conversations, resolved_pct, avg_user_turns, feedback.

  • Person-keyed metrics (users, active_users, adoption_pct, retention) report null with person_coverage saying why.

  • Erasure works by distinct id: POST /v1/projects/{p}/persons/bulk_delete {"distinct_ids":["conv_..."]} (Developer guide 4).

How conversations are computed

ClickHouse keeps a per-conversation rollup (agent_conversations, filled by a materialized view, dedupe-safe). Derived at read time:

  • Outcome: the explicit outcome if any; otherwise ended; otherwise abandoned after 30 minutes without activity; otherwise active.

  • Rephrase: consecutive user messages whose fingerprints differ in 20 bits or fewer.

  • Rage prompt: 2+ rephrases, or 2+ negative user messages, or one of each.

  • Unresolved: outcome unresolved, escalated, abandoned or error, or any thumbs-down.

  • Adoption %: persons with a conversation / persons with any event in the range.

  • Retention: new persons split into agent users and non-agent users by their first period.

Topics and use cases

Hourly, the agent_analytics.topics job sends up to 200 unlabeled first prompts per project (text-captured conversations only, masked again) to the AI service (POST /v1/ai/agent-topics/label), which clusters them and asks the project's own configured model (bring your own key, go/ai/llm) to name each cluster with a topic and use case, reusing existing topic names. Labels land in agent_conversation_labels. POST .../agent-analytics/topics/run runs it now. Without captured text, set topic / useCase yourself on startConversation.

API

All under /v1/projects/{project_id}/agent-analytics, with from, to, agent: GET /overview, GET /topics, POST /topics/run, GET /conversations (outcome, topic, rage, unresolved, feedback, cursor paginated), GET /conversations/{id} (transcript; text shown only if captured and the viewer has pii:read, plus watchtower_trace_url when a Watchtower connector is set up), GET /feedback, GET /retention?period=week&periods=8&lookback_days=90 (first-seen lookback 1..365).

Lite mode (DuckDB) computes the same per-conversation rules from events directly; topics there come from the SDK $ai_topic only.

Query IR

  • Series / funnel step / retention event: {"type":"agent_conversation","status":"resolved","agent":"support-bot"} with status started, message, ended, resolved, unresolved, escalated, abandoned, rage, positive_feedback (thumbs up or rating 4-5), negative_feedback (thumbs down or rating 1-2).

  • Breakdowns: {"key":"agent:topic"}, {"key":"agent:outcome"}, {"key":"agent:agent_name"}.

  • Cohort criterion: {"type":"performed","agent_conversation":{"status":"rage"},"count":{"op":"gte","n":2},"window":{"days":30}}.

Web

AI > Agent analytics: Overview, Topics, Conversations, Unresolved, Feedback, Retention, plus a transcript page per conversation (masked text shows [masked]; trace and replay links when present). The built-in dashboard template Agent analytics gives a starting dashboard.

Usage of your own MCP server

If you ship an MCP server, see which tools people use with one ordinary event per tool call, from the Node or Python SDK in the server's tool handler:

lucida.capture({ distinctId: caller, event: "$mcp_tool_call", properties: { tool: "search_docs", client: "claude-desktop" } });
client.capture(caller, "$mcp_tool_call", {"tool": "search_docs", "client": "claude-desktop"})

Dashboards > New from template > MCP tool usage charts calls per tool and distinct callers per tool, and the event works as a funnel step, cohort criterion or breakdown like any other. Durations and error rates of the calls are request telemetry, which belongs to Watchtower: send them there, not as event properties.

Verify

cargo test -p lc-query -p lc-cohort -p lc-api -p lc-worker -p lc-jobs
LC_CH_URL=http://127.0.0.1:18123 cargo test -p lc-query --test it_clickhouse agent
cd go && go test ./ai/agenttopics ./cmd/lc-ai ./ai/ir
pnpm --filter @lucida-analytics/sdk-core test; pnpm --filter @lucida/web exec vitest run src/features/agent-analytics
cd sdks/python && pytest tests/test_agent.py
Updated