Skip to content

chore(analytics): stop sending usage events to PostHog (growth phase 3) - #367

Closed
DevelopedByDev wants to merge 7 commits into
mainfrom
codex/growth-posthog-cleanup
Closed

DevelopedByDev wants to merge 7 commits into
mainfrom
codex/growth-posthog-cleanup

Conversation

@DevelopedByDev

Copy link
Copy Markdown
Collaborator

Phase 3 of the growth analytics plan. This PR also retires the plan doc into internal/develop/admin-console.md.

Stacked on #365 (nightly job) → #366 (admin Growth panel). Merge those first. Until they merge, this diff includes their commits; the Phase 3 change is the last commit.

Merge only after the Growth panel is live in production and its backfill has run. Otherwise there is a gap where no growth numbers are visible. Before merging, also check that no PostHog dashboard or alert depends on the removed events listed below.

Removed

  • Client metrics. Removed src/shared/observability/client-metrics.ts and duplicate-tracker.ts, their call sites, and the forwarding in ObservabilityClient. Their call sites were:

    • chat-open latency;
    • chat-list cache states;
    • run recovery;
    • session refresh.
  • Server metrics. Removed src/server/observability/metrics.ts:

    • overlay.metrics.bff_request is gone, though the [BFF_METRIC] server log line stays;
    • so is the uncalled ActContextService.emitTokenBreakdown.
  • Session pings. Removed retention.engaged and auth.session.signed_in. Returning users now come from Convex active users.

  • Feature captures. Removed the remaining posthog.capture calls:

    • chat: new chat, message sent, retry;
    • Work: work-analytics.ts and its test;
    • integrations: connect, disconnect, Composio callback;
    • desktop auth callback;
    • sign-out.

    The knowledge analytics adapter is now a no-op unless a capture is injected.

  • Lifecycle mappings. Removed the billing, automation and workspace lifecycle → PostHog mappings. The lifecycle email and audit sinks are unchanged.

  • Convex. Removed convex/lib/metrics.ts (withMetrics had no users) and platform/metrics:aggregateMetricsInternal.

Kept

  • PostHog init, $pageview with a redacted URL, identify / reset, and the server client used for feature flags.
  • One server event: activation.completed, renamed user.signed_up, so signups can be tied to the pages that brought them in. Any PostHog funnel that uses the old name needs updating.
  • The functionMetrics table and its 6-hourly cleanup cron. Nothing writes the table any more. Dropping a table that still has rows could block a production schema push, so remove it in a later PR once it's confirmed empty.
  • Sentry.

Checks

  • Typecheck (scripts/ci/typecheck-pre-push.mjs, web and admin): passes.

  • Targeted ESLint on the changed files: 0 errors. The only warnings were already there.

  • Tests:

    • posthog-server (rewritten for the new mapping);
    • webKnowledgeSurfaceAdapters;
    • useAgentRunLifecycle;
    • chat-list-cache;
    • public-route-security;
    • LifecycleEventPublisher;
    • convex/growthAnalytics.convex.test.ts.

    All pass.

  • check:on-prem-convex-boundaries and check:shared-isomorphic: OK.

Preview QA from the plan is still to do. On the PR preview, send a chat, create a task and connect an integration, then confirm:

  • PostHog receives only pageviews, identify and signup;
  • feature flags still resolve;
  • there are no console errors.

🤖 Generated with Claude Code

DevelopedByDev and others added 7 commits November 1, 2026 00:54
Count each UTC day from existing tables: things created (tasks, agents,
automations, files), work done (threads, messages, automation runs, file
edits), signups, active users, W1/W4 cohorts, paid subscriptions, top-ups
and billed usage. The job runs as resumable paged mutations from a daily
cron, with a backfill entry point. Files now record when and by whom their
text last changed, so edits aren't confused with indexing or moves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The on-prem Convex boundary check tracks every cron and scheduler call
site; add the nightly growth job's entries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ero paid

Address review findings on the nightly growth rollups:

- Record file edits per (file, UTC day) as they happen, with every person
  who edited, instead of a last-edited field that a second editor, an agent
  overwrite or a post-midnight edit would overwrite before the nightly count.
- Credit task creation through the task's `created` event actor, so an
  agent creating a task for its owner doesn't make the owner active.
- Start the live paid-subscription snapshot at zero, so a night with no
  paid plans records 0 rather than leaving the earlier count in place.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Address the second round of review findings on the nightly rollups:

- Weekly/monthly actives and W1/W4 credit no longer depend on the order
  days are counted, so a backfill after the first nightly run is correct.
- Count billed spend as billing/usageTotals does: finalized reservations
  plus self-charged usage operations.
- Keep spend per (day, workspace) in its own table instead of an unbounded
  array on the job state.
- Re-count the two days before each night so late top-ups, runs and
  reservation finalizations are picked up; count partly refunded top-ups.
- Date accounts already paid at the first snapshot by their subscription,
  whichever runs first, and drop the capped backfill seeding.
- Don't credit owners with agent-drive files (`files.createdByAgent`), and
  detect edits to object-stored text by its full-text hash.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eleted

File edit rows no longer store editor ids; the editor is credited in
growthUserDays when they save, and retention is checked for every
user-day during the nightly count. Account deletion now removes the
person's growthUsers and growthUserDays rows, leaving only anonymous
totals and cohort counts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
admin/console:getGrowthSummary reads only the growth tables: 90 days of
totals, new paid accounts per day, the last 12 signup cohorts and the top
workspaces by spend. GET /api/v1/admin/growth serves it to admin, auditor
and billing operators; support has no access. The panel shows headline
numbers against the prior week, weekly trends per group, W1/W4 retention
and the top workspaces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Growth is counted from Convex now, so the client and server metrics
pipelines, retention.engaged, the signed-in ping, feature-level captures
(chat, Work, integrations, auth callback, sign-out) and the billing,
automation and workspace lifecycle mappings are removed. PostHog keeps
pageviews, identify/reset, feature flags and one signup event, renamed
user.signed_up. The unused Convex withMetrics wrapper and its aggregation
query are deleted; the functionMetrics table and cleanup cron stay until
the table is empty. The growth plan is retired into admin-console.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mintlify

mintlify Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
layernorminc 🟢 Ready View Preview Nov 1, 2026, 6:38 PM

💡 Tip: Enable Automations to automatically generate PRs for you.

@vercel

vercel Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
overlay-landing Ready Ready Preview Nov 1, 2026 6:47pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
overlay-admin Ignored Ignored Nov 1, 2026 6:47pm UTC

Request Review

@DevelopedByDev DevelopedByDev added the needs-preview Request exact-SHA hosted Preview and isolated backend for browser or end-to-end QA label Nov 1, 2026
@DevelopedByDev

Copy link
Copy Markdown
Collaborator Author

QA handoff (partial)

Hosted check: shipped browser bundles

I fetched /, /app, /app/chat, /app/work, /app/integrations, /auth/callback and /auth/composio/callback through vercel curl, then crawled the JavaScript chunks they reference (79 per preview). For each event name, the table shows how many chunks contain it.

Event string pr-366 (before) pr-367 (after)
$pageview (kept) 2 2
retention.engaged 1 0
overlay:metrics / overlay.metrics 1 / 1 0 / 0
chat_message_sent, chat_new_chat_created, chat_response_retry_clicked 1 each 0
work_task_created, work_view_opened 1 each 0
integration_connect_initiated, integration_disconnected, integration_connect_completed 1 each 0
auth_callback_success 1 0
user_signed_out 3 0

Public pages and /app return 200 on the preview.

Not yet covered

  • No signed-in browser pass yet. The planned pass is to send a chat, create a task and connect an integration, then watch PostHog network traffic and the console for errors. It hasn't run because the QA browser has no Vercel deployment-protection access: the Vercel MCP isn't connected, and the bypass and preview-login secrets are Sensitive, so they can't be read locally.
  • Server-side events (user.signed_up only; no billing, automation or workspace events, no bff_request) aren't observed on the host. The unit tests and typecheck cover them.
  • Feature flags weren't exercised.

🤖 Generated with Claude Code

@DevelopedByDev

Copy link
Copy Markdown
Collaborator Author

Superseded by #372, which includes this change together with the admin console redesign.

This branch was successfully deployed

2 active deployments
staging - docs — 101ae4ca Deployed Nov 1, 2026 by mintlify[bot]
Preview – overlay-landing — 101ae4ca Deployed Nov 1, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-preview Request exact-SHA hosted Preview and isolated backend for browser or end-to-end QA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant