fix(analytics): store bounded product-usage rollup dimensions complete#384
Merged
JSONbored merged 2 commits intoJun 4, 2026
Merged
Conversation
JSONbored
approved these changes
Jun 4, 2026
Owner
JSONbored
left a comment
There was a problem hiding this comment.
@galuis116 this looks good.
A few notes:
- The bounded dimension handling is now complete without turning the top-N behavior into an unbounded storage path.
- The high-diversity coverage is the right regression shape here.
- No code changes requested.
Validation expected:
- Keep the current green CI run.
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.
Closes #383.
Summary
buildProductUsageDailyRollupRecordstored every dimension viacountProductUsageDimensions, which keeps only the top 20 by frequency. That is correct for the unboundedbyRepo/byCommand/byTool/byRouteClassdimensions (shown as display top-N), butbyEventis a bounded event-name enum (~22 distinct names) that the weekly value report consumes by exact-name lookup (sumEvent->byEvent.find(eventName)). On a day with more than 20 distinct event types, the lowest-frequency events drop off the cut — and the report's flagship signals (agent_pr_packet_completed,agent_preflight_branch_completed,agent_command_replied/skipped) are exactly the low-frequency ones, so the public weekly value report under-counts them (reads 0 for that day).Scope
src/db/repositories.ts— store the bounded enum dimensions (bySurface/byOutcome/byEvent) complete via aFULL_DIMENSION_LIMIT, while the genuinely-unboundedbyRepo/byCommand/byTool/byRouteClasskeep their display top-N. A comment marks the bounded-vs-unbounded distinction so the two classes can't be conflated again.test/unit/product-usage.test.ts— high-diversity-day test.No schema, API, or public-surface changes (the rollup record shape is unchanged; only the bounded dimensions are no longer truncated).
Validation
Branch coverage stays >= 97%. CI
validateis green.Safety
byEventholds bounded, sanitized event names (already redacted/normalized at record time) and small per-day counts — storing the complete bounded enum adds no actor/repo PII and only marginally more rows (bounded by the enum size).Notes