Skip to content

feat(analytics): add role activation and retention rollups - #310

Merged
JSONbored merged 7 commits into
JSONbored:mainfrom
bitloi:feat/issue-250-role-retention-rollups
Jun 2, 2026
Merged

feat(analytics): add role activation and retention rollups#310
JSONbored merged 7 commits into
JSONbored:mainfrom
bitloi:feat/issue-250-role-retention-rollups

Conversation

@bitloi

@bitloi bitloi commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds aggregate role segmentation to product usage daily rollups for role, activation, surface, and 7/30-day retention analysis.
  • Keeps the issue feat(analytics): add role activation and retention rollups #250 analytics privacy boundary by exposing only rollup counts, not per-user identifiers or raw role metadata.
  • Refreshes the generated OpenAPI snapshot and the MCP package latest fallback required by the current local validation gate.

Closes #250

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

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

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

  • Adds migration 0017_product_usage_role_retention_rollups.sql for new daily-rollup JSON columns.
  • Role inference is intentionally conservative: explicit sanitized role metadata is preferred, known event types provide safe fallbacks, and unknown values remain unknown.
  • Retention metrics are computed at aggregate rollup time and split by role and surface while preserving the existing privacy model.
  • No visible UI layout change was made, so screenshots are not applicable.

@dosubot

dosubot Bot commented Jun 2, 2026

Copy link
Copy Markdown

Documentation Updates

1 document(s) were updated by changes in this PR:

Gittensory Architecture
View Changes
@@ -103,7 +103,7 @@
 
 ### **I. Database Layer (`src/db/`)**
 
-The database uses Drizzle ORM with Cloudflare D1 (SQLite) [[30]](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/src/db/client.ts). The schema spans 50+ tables across 16 migrations [[31]](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/migrations), grouped into six categories: GitHub integration (installations, repositories, repositorySettings), sync state (repoSyncState, repoSyncSegments), scoring (scoringModelSnapshots, scorePreviews, contributorEvidence), agent orchestration (agentRuns, agentActions, agentContextSnapshots), auth/compliance (authSessions, auditEvents), and analytics (productUsageEvents, productUsageDailyRollups) [[32]](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/src/db/schema.ts).
+The database uses Drizzle ORM with Cloudflare D1 (SQLite) [[30]](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/src/db/client.ts). The schema spans 50+ tables across 17 migrations [[31]](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/migrations), grouped into six categories: GitHub integration (installations, repositories, repositorySettings), sync state (repoSyncState, repoSyncSegments), scoring (scoringModelSnapshots, scorePreviews, contributorEvidence), agent orchestration (agentRuns, agentActions, agentContextSnapshots), auth/compliance (authSessions, auditEvents), and analytics (productUsageEvents, productUsageDailyRollups) [[32]](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/src/db/schema.ts). Daily usage rollups track activation funnels, role segmentation, surface-level activation, and 7-day and 30-day retention metrics.
 
 ### **J. Queue Processor (`src/queue/`)**
 
@@ -336,7 +336,7 @@
 
 ### Data Layer
 
-**Database:** Cloudflare D1 (SQLite at the edge) with a binding named [`DB`](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/wrangler.jsonc#L50-L57) pointing to the `gittensory` database. The schema comprises [50+ tables across 16 migrations](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/migrations), spanning GitHub integration, sync state, scoring, agent orchestration, auth/compliance, and analytics.
+**Database:** Cloudflare D1 (SQLite at the edge) with a binding named [`DB`](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/wrangler.jsonc#L50-L57) pointing to the `gittensory` database. The schema comprises [50+ tables across 17 migrations](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/migrations), spanning GitHub integration, sync state, scoring, agent orchestration, auth/compliance, and analytics. Daily usage rollups track activation funnels, role segmentation, surface-level activation, and 7-day and 30-day retention metrics.
 
 **ORM:** [Drizzle ORM ^0.45.0](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/package.json#L62) provides type-safe query construction and schema management.
 

How did I do? Any feedback?  Join Discord

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

@bitloi no changes requested. CI is green, the migration and rollup coverage are in place.

@dosubot dosubot Bot added the lgtm label Jun 2, 2026
@JSONbored
JSONbored merged commit 94ffebe into JSONbored:main Jun 2, 2026
4 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in gittensory - v1 roadmap Jun 2, 2026
@JSONbored JSONbored added gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. and removed feature gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. labels Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

feat(analytics): add role activation and retention rollups

2 participants