Repository navigation
Description
[analytics] track weekly InferenceX client API requests / 统计 InferenceX 客户端每周 API 请求量
Summary
Measure whether the skills package generates online API usage. The existing US-region InferenceX PostHog project is confirmed; the inspected event inventory has no existing skill event definitions, and the CLI currently sends no package attribution. Reuse that project and the existing server capture path.
Authenticated settings audit (2026-09-22): Confirmed the existing US Cloud project and us.i.posthog.com ingestion host. Event-definition searches for skill and cli_api returned no definitions. Ingestion filtering is disabled. Discard-IP is enabled, but the active GeoIP transformation processes events before that discard and explicitly honors $geoip_disable; set this property on every new event. The existing server helper uses an identified aggregate, so the new event needs a separate anonymous aggregate. No settings were changed. A dedicated UTC weekly report will avoid inheriting browser/person-based defaults.
Contract and acceptance
- Emit
cli_api_request_receivedfor marked public GET requests: catalog entries classifiedpublished-read, plus/api/openapi.json. Capture once at ingress before the CDN cache; never duplicate capture in handlers. Retries count separately. Delivery is best effort, not exactly-once accounting. source=cli|skilldescribes the transport: formal CLI or packaged raw-API recipe. A skill invoking the CLI counts ascli. Mark both paths with the packaged version; validate bounded whole markers and normalize dynamic routes. Reject malformed markers and unknown/private routes.- Weekly charts use total events for server-derived production environment and normal traffic, Monday-based UTC weeks, with the current week labeled partial. Separate CI/demo/validation traffic. Headers are self-reported attribution, never authentication.
- Use a new constant aggregate identity with
$process_person_profile=false; do not reuse the existing identifiedserveridentity. Capture only source, normalized version/route, environment and finite traffic class. Exclude prompts, spreadsheet contents, query strings, concrete IDs, raw headers, IP addresses, cookies and persistent user/install identifiers. - Attach a timeout-bounded capture promise to the request lifetime without delaying responses. Missing configuration, rejection, timeout and non-2xx capture responses must preserve API status, body, cache and embed behavior. Do not retry analytics delivery.
- Document and test opt-out for both senders, including retries; omit all recognized attribution markers. Restrict automatic markers to first-party requests. No direct client-to-PostHog calls.
- Verify negative cases, normalization, single capture, privacy and failure isolation locally; inspect the payload and PostHog report configuration again before PR. Deployed acceptance requires one cold and one warm request with cache evidence and matching test events, excluded from usage charts.
Not measured: unique people, downloads, skill invocations, successful analyses, final response status or offline usage. Unmarked/opted-out traffic and failed deliveries are absent. Server deployment and live cache/ingestion acceptance precede client publication; this issue does not authorize merging or releasing.
中文说明
目标是判断技能包是否产生实际在线 API 请求。已确认现有美国区域的 InferenceX PostHog 项目;已检查的事件清单没有技能专用事件,CLI 也尚未发送包来源标识。复用该项目和已有服务端发送链路。
已认证设置审计(2026-09-22): 已确认现有 US Cloud 项目和 us.i.posthog.com 接收地址。以 skill、cli_api 搜索事件定义均无结果。入口过滤关闭;丢弃 IP 已启用,但当前 GeoIP 转换在丢弃前运行,且明确支持 $geoip_disable,因此每个新事件都须设置该属性。已有服务端发送器使用已识别的聚合身份,新事件需要独立匿名聚合标识。本次未修改设置。新增按 UTC 周统计的报表,避免继承浏览器或个人维度的默认口径。
验收约定:
- 对带标识的公开 GET 请求发送
cli_api_request_received:包含目录中标为published-read的接口及/api/openapi.json。在 CDN 缓存之前的入口只发送一次,handler 不重复记录。每次重试独立计数;统计尽力交付,不承诺零丢失或恰好一次。 source=cli|skill表示正式 CLI 或打包的原始 API 示例。skill 调用 CLI 时计为cli。两条路径均使用包版本标识;完整校验标识及长度,规范化动态路径,排除无效标识、未知接口和非公开接口。- 周报统计服务端确认的生产环境中普通流量的事件总数,按 UTC 周一划分,当前周注明尚未结束。CI、演示和验收流量单独标记。请求头仅用于来源归类,不能用于身份认证。
- 使用新的固定聚合标识,并设置
$process_person_profile=false;不复用已有的已识别server身份。只记录来源、规范化版本与接口、环境及限定类别的流量标记。不记录提示词、表格内容、查询参数、具体 ID、原始请求头、IP、cookie 或持久用户/安装标识。 - 将有超时上限的事件发送 promise 接入请求生命周期,不阻塞响应。配置缺失、发送异常、超时和非成功 HTTP 状态均不得改变 API 状态、正文、缓存或嵌入页行为;事件发送不重试。
- 两类请求均提供并测试关闭统计的方法,覆盖重试并移除全部可识别标记。自动标记仅发送至第一方接口;客户端不直接访问 PostHog。
- 本地验证排除条件、路径规范化、单次发送、隐私和故障隔离;提 PR 前再次核对 payload 与 PostHog 报表配置。部署验收用同一安全接口的一次冷缓存与一次热缓存请求,保存缓存证据并确认对应测试事件;这些事件不计入使用量。
不统计独立用户、下载量、skill 调用次数、分析成功次数、最终响应状态或离线使用。无标识、已关闭统计及发送失败的请求不会进入报表。客户端发布前须部署服务端并完成缓存与入账验收;本 issue 不授权合并或发布。
Activity