Skip to content

feat(analytics): add privacy-safe usage event spine - #182

Merged
JSONbored merged 2 commits into
JSONbored:mainfrom
oktofeesh1:codex/analytics-usage-event-spine
Jun 1, 2026
Merged

feat(analytics): add privacy-safe usage event spine#182
JSONbored merged 2 commits into
JSONbored:mainfrom
oktofeesh1:codex/analytics-usage-event-spine

Conversation

@oktofeesh1

@oktofeesh1 oktofeesh1 commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds privacy-safe product usage events for API, MCP, GitHub App, extension, and control-panel flows.
  • Stores hashed actor/session identifiers and sanitized metadata separate from audit logs.
  • Surfaces usage summary metrics in the operator dashboard.

What changed

  • Adds D1 migration, schema, and repository helpers for product_usage_events.
  • Instruments key app/API, MCP, and GitHub App command paths with best-effort telemetry.
  • Redacts actor names, tokens, source/body/diff content, wallet/hotkey/coldkey details, and local paths before persistence.
  • Requires a dedicated PRODUCT_USAGE_HASH_SALT for actor/session hashing; without it, hashes are null.
  • Adds no-leak and telemetry-failure regressions across API, MCP, queue, and repository tests.

Why

Validation

  • npm run test:ci
  • npm run test -- test/unit/product-usage.test.ts test/unit/queue.test.ts test/integration/api.test.ts test/integration/routes-errors.test.ts
  • npm run typecheck
  • Codex Security diff scan: no reportable findings after actor-redaction hardening.
  • Codex Security diff scan rerun after removing the API-token hash-salt fallback: no reportable findings.

Notes

  • Telemetry writes are best-effort and do not fail user-facing routes.
  • Hashing uses PRODUCT_USAGE_HASH_SALT only; if no dedicated salt is configured, actor/session hashes are null.

@oktofeesh1
oktofeesh1 requested a review from JSONbored as a code owner June 1, 2026 10:43
@dosubot dosubot Bot added the size:XL label Jun 1, 2026
@superagent-security superagent-security Bot added the pr:flagged PR flagged for review by security analysis. label Jun 1, 2026

@superagent-security superagent-security Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superagent found 1 security concern(s).

Comment thread src/db/repositories.ts
@superagent-security superagent-security Bot removed the pr:flagged PR flagged for review by security analysis. label Jun 1, 2026
@oktofeesh1
oktofeesh1 force-pushed the codex/analytics-usage-event-spine branch 2 times, most recently from ccb86ed to 245ec06 Compare June 1, 2026 18:19
Adds product_usage_events storage and repository helpers with hashed actor/session identifiers and sanitized metadata.

Instruments API, MCP, extension, and GitHub App command surfaces, with telemetry write failures isolated from product paths.

Adds unit and integration regressions for no token, source, local-path, or raw actor leakage and resilient analytics failure handling.

Validation:

- npm run test:ci

- Codex Security diff scan
Removes API-token fallback from product usage pseudonymization so credentials are never used as hash material.

Adds a regression proving actor and session hashes stay null when only the API token is configured.

Validation:

- npm run test:ci

- npm run test -- test/unit/product-usage.test.ts

- Codex Security diff scan
@oktofeesh1
oktofeesh1 force-pushed the codex/analytics-usage-event-spine branch from 245ec06 to 7433583 Compare June 1, 2026 18:28

@JSONbored JSONbored left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oktofeesh1 This is ready from my side. The usage-event spine is a large foundational change, but the branch is green, merge-clean, and covers the D1 schema, API routes, MCP surface, queue ingestion, repositories, and integration/unit tests.

A few notes:

  • The event model is privacy-safe by construction rather than storing raw private context.
  • The API/MCP wiring and route-error tests are included, which is the right bar for this surface.
  • This should land before the dependent analytics rollup/reporting PRs.

@dosubot dosubot Bot added the lgtm label Jun 1, 2026
@JSONbored
JSONbored merged commit 49ec4a2 into JSONbored:main Jun 1, 2026
3 checks passed
@JSONbored JSONbored added gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. and removed feature gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. labels Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(analytics): add privacy-safe product usage event spine

2 participants