Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

product-analytics.md

49 lines2.5 KB

1# Product analytics
2​
3The server owns PostHog delivery, opt-out, and identity for every connected client.
4[Identity selection](../../apps/server/src/telemetry/Identify.ts) hashes an available
5provider account ID, falling back to an installation-scoped ID. This identity can
6span several clients; it does not identify a browser session. Clients do not load
7the PostHog browser SDK. Client-use events require an authenticated connection, so
8visiting the hosted app without connecting does not count as product use.
9​
10## Attribution boundaries
11​
12Client dimensions belong to the event's WebSocket connection. A server-global
13"current client" would misattribute simultaneous web, desktop, and mobile use.
14Provider execution has its own events because a turn can outlive the requesting
15connection.
16​
17Keep client and server dimensions separate. A desktop host can serve a phone or a
18remote browser, and a direct connection can cross a network. Older clients omit
19metadata. Missing client values must stay unknown rather than being backfilled
20from server properties. The legacy `clientType` property describes how the server
21runs; use `surface` for the connected client.
22​
23## Interpreting events
24​
25Use `client.turn.requested` for active-use reports. `client.connected` counts
26reconnects, so network behavior can inflate it. One identity can appear in several
27client groups during a period; adding those groups double-counts users.
28​
29Provider send and completion counts need not match. Providers can emit synthetic
30turns without a send request. Collection is best effort, with no scan or backfill
31of provider history.
32​
33Token totals cover the main agent. Child agents and model rerouting prevent a turn
34from representing one provider/model combination's full cost. For provider
35comparisons, require complete usage, no observed subagents, and no mixed models;
36compare matching model, effort, interaction mode, and terminal status. Aggregate
37output/input ratios should divide the summed totals. Averaging per-turn ratios
38lets small-input turns dominate.
39​
40Unknown counts stay absent. Partial usage contains valid observed counts but
41cannot establish a whole-turn total. Keep these distinctions when changing token
42normalization or building reports.
43​
44## Collection boundary
45​
46Keep analytics payloads to product metadata and normalized measurements. Do not
47send prompts, authentication material, raw provider payloads, user-assigned device
48names, or conversation identifiers. Client metadata is best effort; invalid values
49must not reject a connection. PostHog person profiles remain disabled.