Repository navigation
feat(insights): record daily member activity per surface for organization adoption - #10532
Conversation
…tion adoption Counts each person's use of the Assistant, agent chats, the Search page, the Search MCP server, the Slack app and their own workflow runs per UTC day in organization_member_activity_daily, only for members of the owning organization. Adds a daily retention sweep (member activity after 400 days, Search MCP call metadata after 270 days) and a backfill script for the history already in copilot_messages and the MCP invocation log.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
[Medium impact] The changes appear safe to merge; no new actionable issues remain. SummaryAdds daily organization member activity across six surfaces, a historical backfill, and scheduled cleanup.
Reviews (3) · Last reviewed commit: "fix(insights): keep sweeping after a bat..." · Reviewed by Greptile |
There was a problem hiding this comment.
All reported issues were addressed across 22 files
This PR changes a database schema or migrates data. Ultrareviews find 2.4x more serious bugs than standard reviews. Comment @cubic-dev-ai ultrareview to run one.
Turn on auto-fix | Re-trigger cubic
…l turns, bound retention batches
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 23 files
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
Summary
organization_member_activity_dailytable: one row per (organization, UTC day, surface, member) with a use count, first and last use. Content-free; only members of the owning organization are countedassistant/agent: chat turn admission (lib/mothership/chat/post.ts); org Assistant mode vs agent/plan or workspace chatssearch_mcp: every non-rate-limited Search MCP call by a person (recordOrganizationSearchMcpActivity)slack: Slack app question persistedsearch: Search page queries (searchLiveKnowledgeafterSuccess, surfacedashboard)workflows: runs a person starts themselves (preprocessExecutionwithuseAuthenticatedUserAsActor); schedules and webhooks are not member activity/api/cron/cleanup-activity-history: daily activity after 400 days,organization_search_mcp_invocationrows after 270 days (that table had no retention). Batched, time-boxed, on the cleanup pool. Registered in docker crontab, helm and the self-hosting docs0478indexesorganization_search_mcp_invocation(created_at)concurrently for the sweep, in its own migration so0477stays transactionalscripts/backfill-member-activity-daily.ts: idempotent per-day backfill of assistant/agent/slack days fromcopilot_messages(automated task/job turns and benchmark chats excluded) and Search MCP days from the invocation logGroundwork for the organization adoption view in Insights (follow-up PR reads this table).
Rollout
lib/constructs/cron-jobs.tsfor/api/cron/cleanup-activity-historyat45 4 * * *. Not urgent: the oldest rows are far inside both retention windows--before=<the day after the deploy>(dry run first)Type of Change
Testing
lib/organizations/member-activity/history.integration.tsagainst real Postgres (6 tests): per-surface day counts, a person is never counted toward an organization they don't belong to, workspace use counts toward the workspace's organization and nothing for one without, 20 concurrent uses lose no count, a refused write is swallowed, the sweep removes only rows past each retention. Reverting the membership guard and the increment each turns their tests redlib/knowledge/mcp,lib/execution, workflow execute route, Slack assistant, chat post, live search application (all pass)check:migrations,check:api-validation:strict,check:file-names,check:comment-hygiene,check:boundaries,check:source-conventions,check:utils,bun run generate, lintChecklist
test-auditauthoring gate)