feat(analytics): persist privacy-safe role on product usage events#355
Merged
JSONbored merged 1 commit intoJun 3, 2026
Merged
Conversation
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
approved these changes
Jun 3, 2026
Owner
JSONbored
left a comment
There was a problem hiding this comment.
@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.sqlmigration is correctly sequenced after currentmain. - 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.
web-dev0521
added a commit
to web-dev0521/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).
12 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #249
Summary
0019_product_usage_event_role.sqlwith an indexedrolecolumn onproduct_usage_events, completing the privacy-safe event shape (role, surface, event name, outcome, coarse target, occurred-at).recordProductUsageEventviaresolveProductUsageRole, prefers the column in daily rollup role bucketing, and sets role at MCP (miner), GitHub App, and control-panel ingestion paths.test/unit/product-usage.test.tsfor role persistence, MCP role inference, forbidden metadata redaction, and updated rollup cap fixtures.Scope
CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
Verified locally with
npm run test:cion Node v24.15.0 (repo requires Node >= 22 per.nvmrc).git diff --checknpm run actionlintnpm run typechecknpm run test:coveragelocally; 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:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderateIf any required check was skipped, explain why:
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
Notes
product_usage_eventstable and repository helpers from the v1 analytics foundation; does not read or writeaudit_events.role: "miner"on usage events.