Skip to content

feat(insights): record daily member activity per surface for organization adoption - #10532

Merged
waleedlatif1 merged 3 commits into
stagingfrom
feat/member-activity-daily
Dec 1, 2026
Merged

waleedlatif1 merged 3 commits into
stagingfrom
feat/member-activity-daily

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • New organization_member_activity_daily table: 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 counted
  • Surfaces recorded where the action happens, best effort and never blocking:
    • assistant / agent: chat turn admission (lib/mothership/chat/post.ts); org Assistant mode vs agent/plan or workspace chats
    • search_mcp: every non-rate-limited Search MCP call by a person (recordOrganizationSearchMcpActivity)
    • slack: Slack app question persisted
    • search: Search page queries (searchLiveKnowledge afterSuccess, surface dashboard)
    • workflows: runs a person starts themselves (preprocessExecution with useAuthenticatedUserAsActor); schedules and webhooks are not member activity
  • Daily retention cron /api/cron/cleanup-activity-history: daily activity after 400 days, organization_search_mcp_invocation rows after 270 days (that table had no retention). Batched, time-boxed, on the cleanup pool. Registered in docker crontab, helm and the self-hosting docs
  • 0478 indexes organization_search_mcp_invocation(created_at) concurrently for the sweep, in its own migration so 0477 stays transactional
  • scripts/backfill-member-activity-daily.ts: idempotent per-day backfill of assistant/agent/slack days from copilot_messages (automated task/job turns and benchmark chats excluded) and Search MCP days from the invocation log

Groundwork for the organization adoption view in Insights (follow-up PR reads this table).

Rollout

  • Prod scheduling of the new cron needs an infra companion: an entry in lib/constructs/cron-jobs.ts for /api/cron/cleanup-activity-history at 45 4 * * *. Not urgent: the oldest rows are far inside both retention windows
  • After deploy, run the backfill once with --before=<the day after the deploy> (dry run first)

Type of Change

  • New feature

Testing

  • lib/organizations/member-activity/history.integration.ts against 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 red
  • Backfill script run twice against a seeded local DB: job-origin turns, assistant replies and rate-limited calls excluded; second run leaves identical counts
  • Affected unit suites: lib/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, lint

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

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

vercel Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Dec 1, 2026 5:10am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The changes appear safe to merge; no new actionable issues remain.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The changes appear safe to merge; no new actionable issues remain.

Summary

Adds daily organization member activity across six surfaces, a historical backfill, and scheduled cleanup.

  • Organization members’ daily use is counted across six Sim surfaces.
  • A daily cleanup removes old organization activity history.

Reviews (3) · Last reviewed commit: "fix(insights): keep sweeping after a bat..." · Reviewed by Greptile

Comment thread apps/sim/lib/execution/preprocessing.ts Resolved

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 23 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 23 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 6f254bb into staging Dec 1, 2026
93 checks passed
@waleedlatif1
waleedlatif1 deleted the feat/member-activity-daily branch December 1, 2026 06:07

This branch was previously deployed

1 inactive deployment
Preview — 45e2f661 Deployed Dec 1, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant