Skip to content

feat(analytics): persist privacy-safe role on product usage events#355

Merged
JSONbored merged 1 commit into
JSONbored:mainfrom
kiannidev:feat/issue-249-product-usage-events
Jun 3, 2026
Merged

feat(analytics): persist privacy-safe role on product usage events#355
JSONbored merged 1 commit into
JSONbored:mainfrom
kiannidev:feat/issue-249-product-usage-events

Conversation

@kiannidev

Copy link
Copy Markdown
Contributor

Fixes #249

Summary

  • Adds migration 0019_product_usage_event_role.sql with an indexed role column on product_usage_events, completing the privacy-safe event shape (role, surface, event name, outcome, coarse target, occurred-at).
  • Persists normalized role in recordProductUsageEvent via resolveProductUsageRole, prefers the column in daily rollup role bucketing, and sets role at MCP (miner), GitHub App, and control-panel ingestion paths.
  • Tightens metadata sanitization to strip prompts, private scoreability, reviewability, farming language, and other sensitive keys/values before D1 persistence (actors remain hashed; repos/targets redacted).
  • Extends test/unit/product-usage.test.ts for role persistence, MCP role inference, forbidden metadata redaction, and updated rollup cap fixtures.

Scope

  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked an issue, or this is small enough that the summary explains why an issue is not needed.

Validation

Verified locally with npm run test:ci on Node v24.15.0 (repo requires Node >= 22 per .nvmrc).

  • git diff --check
  • npm run actionlint
  • npm run typecheck
  • npm run test:coverage locally; global coverage stays at or above 97% for lines, statements, functions, and branches (aim for 98%+ branch coverage locally so CI variance does not fail near the threshold)
  • npm run test:workers
  • npm run build:mcp
  • npm run test:mcp-pack
  • npm run ui:openapi:check
  • npm run ui:lint
  • npm run ui:typecheck
  • npm run ui:build
  • npm audit --audit-level=moderate
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries

If any required check was skipped, explain why:

  • None.

Coverage summary (npm run test:coverage): statements 99.08%, branches 97.00%, functions 98.40%, lines 99.66%. test/unit/product-usage.test.ts: 21/21 passed.

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Public GitHub text stays sanitized, low-noise, and does not imply compensation guarantees or optimization tactics.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests.
  • API/OpenAPI/MCP behavior is updated and tested where needed.
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks.
  • Visible UI changes include screenshots or a short recording.
  • Public docs/changelogs are updated where needed; changelogs are only edited for release-prep PRs.

Notes

Add role column and migration, normalize role at write time, tighten
metadata redaction for scoreability and source leakage, and extend tests.
Fixes JSONbored#249

@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.

@kiannidev this is ready from my pass.

A few notes:

  • The role persistence is scoped cleanly across API, MCP, GitHub App, queue, and rollup paths.
  • The 0019_product_usage_event_role.sql migration is correctly sequenced after current main.
  • The sanitizer coverage is the important part here, and the tests cover the private metadata terms that should never persist.

No code changes requested.

Validation expected:

  • Keep the current green CI.
  • If another migration lands first, recheck the migration number before merge.

@dosubot dosubot Bot added the lgtm label Jun 3, 2026
@JSONbored
JSONbored merged commit a5331b1 into JSONbored:main Jun 3, 2026
4 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in gittensory - v1 roadmap Jun 3, 2026
Lobster-0429 added a commit to Lobster-0429/gittensory that referenced this pull request Jun 3, 2026
…st fallbacks

Merging main (JSONbored#347 eligibility-plan, JSONbored#355 analytics role) dropped global
branch coverage to 96.98%, below the 97% gate, failing the validate job.

- scenario-summary.ts was at 84.61% branch: the rankScenarios comparator's
  order/localeCompare tie-breakers never ran because every fixture used
  distinct scores. Add equal-score (different-name) and duplicate-name
  fixtures to exercise both fallbacks.
- repo-policy-readiness.ts owner-context '?? default' fallbacks only run
  when focusManifest is undefined; existing tests passed parsed (defined)
  manifests. Add an undefined-manifest fixture.

Global branch coverage now 97.07% (9508/9794).
@github-actions github-actions Bot mentioned this pull request Jun 4, 2026
12 tasks
@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

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

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

2 participants