Skip to content

[codex] Add activation funnel contract#133

Merged
ohong merged 26 commits into
mainfrom
codex/activation-funnel-contract
Jul 3, 2026
Merged

[codex] Add activation funnel contract#133
ohong merged 26 commits into
mainfrom
codex/activation-funnel-contract

Conversation

@ohong

@ohong ohong commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • add the activation workstream plans and implement the first activation contract slice
  • define activation as first sync confirmed in web, with typed event names and activation state derivation
  • add server-side PostHog lifecycle capture plus a privacy-limited activation event API route
  • wire lifecycle events into landing CTA/copy, signup start, auth callback, onboarding command/success, usage submit, and usage status confirmation
  • keep the existing CLI PostHog events intact while adding server-side web lifecycle coverage

Validation

  • bun install --frozen-lockfile
  • bun --cwd apps/web test -- tests/flows/activation-contract.test.ts tests/api/activation-analytics.test.ts tests/lib/analytics-server.test.ts tests/api/usage-status.test.ts tests/api/usage-submit.test.ts
  • bun --cwd apps/web typecheck
  • bun --cwd packages/cli test -- tests/commands/login.test.ts tests/commands/push.test.ts
  • bun --cwd packages/cli typecheck
  • bun --cwd apps/web build
  • bun --cwd apps/web test:e2e -- e2e/golden-path/landing-to-signup.spec.ts

Notes

  • browser PostHog consent handling is preserved; the new server route only accepts allowlisted lifecycle events and sanitizes properties
  • no prompts, code, file paths, raw usage rows, email addresses, or user-entered content are sent to PostHog
  • .claude/settings.json has an unrelated local modification and is not part of this PR

Summary by CodeRabbit

  • New Features

    • Added a clearer activation and onboarding flow with copyable sync commands, signup prompts, and completion tracking.
    • Introduced richer message, prompt, and landing-page experiences, including improved modals, attachments, and CTAs.
    • Added a faster, lazy-loaded command palette and improved sidebar/notifications behavior.
  • Bug Fixes

    • Tightened usage/status handling and empty-state behavior so pages show more accurate “no data” and first-sync guidance.
    • Improved clipboard and analytics interactions for copy and signup actions.
  • Style

    • Updated several labels, empty-state messages, and profile/header copy for clearer user-facing wording.

@vercel

vercel Bot commented Jul 2, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
straude Ready Ready Preview, Comment Jul 3, 2026 12:28pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 08584dae-a673-4cdc-a61e-0082607f85a6

📥 Commits

Reviewing files that changed from the base of the PR and between 143a5af and 4786c7a.

📒 Files selected for processing (84)
  • .claude/settings.json
  • apps/web/__tests__/api/activation-analytics.test.ts
  • apps/web/__tests__/api/profile.test.ts
  • apps/web/__tests__/api/usage-status.test.ts
  • apps/web/__tests__/api/usage-submit.test.ts
  • apps/web/__tests__/components/CommandPalette.test.tsx
  • apps/web/__tests__/components/FeedList.test.tsx
  • apps/web/__tests__/components/SubmitPromptWidget.test.tsx
  • apps/web/__tests__/components/TopHeader.test.tsx
  • apps/web/__tests__/flows/activation-contract.test.ts
  • apps/web/__tests__/lib/analytics-server.test.ts
  • apps/web/__tests__/lib/open-stats.test.ts
  • apps/web/app/(app)/layout.tsx
  • apps/web/app/(app)/post/new/CopyCommand.tsx
  • apps/web/app/(app)/u/[username]/page.tsx
  • apps/web/app/(auth)/callback/route.ts
  • apps/web/app/(auth)/layout.tsx
  • apps/web/app/(auth)/signup/page.tsx
  • apps/web/app/(landing)/layout.tsx
  • apps/web/app/(landing)/open/page.tsx
  • apps/web/app/(onboarding)/layout.tsx
  • apps/web/app/(onboarding)/onboarding/page.tsx
  • apps/web/app/admin/layout.tsx
  • apps/web/app/api/analytics/activation/route.ts
  • apps/web/app/api/app/right-sidebar/route.ts
  • apps/web/app/api/usage/status/route.ts
  • apps/web/app/api/usage/submit/route.ts
  • apps/web/app/api/users/me/route.ts
  • apps/web/app/layout.tsx
  • apps/web/components/app/activation/FirstSyncCommandCard.tsx
  • apps/web/components/app/activation/GuestSignupCta.tsx
  • apps/web/components/app/feed/ActivityCard.tsx
  • apps/web/components/app/feed/FeedList.tsx
  • apps/web/components/app/messages/MessagePresentation.tsx
  • apps/web/components/app/messages/MessagesInbox.tsx
  • apps/web/components/app/messages/message-utils.ts
  • apps/web/components/app/profile/InviteButton.tsx
  • apps/web/components/app/prompts/SubmitPromptModal.tsx
  • apps/web/components/app/prompts/SubmitPromptWidget.tsx
  • apps/web/components/app/shared/CommandPalette.tsx
  • apps/web/components/app/shared/CommandPaletteInner.tsx
  • apps/web/components/app/shared/GuestHeader.tsx
  • apps/web/components/app/shared/ResponsiveShellFrame.tsx
  • apps/web/components/app/shared/RightSidebar.tsx
  • apps/web/components/app/shared/TopHeader.tsx
  • apps/web/components/landing/CTASection.tsx
  • apps/web/components/landing/Hero.tsx
  • apps/web/components/landing/LandingActivationActions.tsx
  • apps/web/components/landing/LazyHalftoneCanvas.tsx
  • apps/web/components/landing/MobileNav.tsx
  • apps/web/components/landing/Navbar.tsx
  • apps/web/components/landing/ProductHuntBadge.tsx
  • apps/web/components/landing/WallOfLove.tsx
  • apps/web/components/landing/constants.ts
  • apps/web/components/providers/AppProviders.tsx
  • apps/web/components/providers/PostHogProvider.tsx
  • apps/web/components/providers/PublicAnalytics.tsx
  • apps/web/e2e/golden-path/landing-to-signup.spec.ts
  • apps/web/lib/analytics/activation.ts
  • apps/web/lib/analytics/client.ts
  • apps/web/lib/analytics/server.ts
  • apps/web/lib/data/usage-totals.ts
  • apps/web/lib/open-stats.ts
  • apps/web/lib/query/keys.ts
  • apps/web/lib/query/right-sidebar.ts
  • apps/web/lib/utils/after.ts
  • apps/web/lib/utils/useClipboardFeedback.ts
  • packages/cli/__tests__/ccusage.test.ts
  • packages/cli/__tests__/commands/push.test.ts
  • packages/cli/__tests__/flows/cli-sync-flow.test.ts
  • packages/cli/__tests__/resolve-push-date-range.test.ts
  • packages/cli/src/commands/login.ts
  • packages/cli/src/commands/push.ts
  • packages/cli/src/index.ts
  • packages/cli/src/lib/ccusage.ts
  • packages/cli/src/lib/telemetry.ts
  • plans/001-activation-funnel-contract.md
  • plans/002-onboarding-first-sync.md
  • plans/003-public-landing-performance.md
  • plans/004-authenticated-shell-performance.md
  • plans/005-core-app-ux-activation.md
  • plans/006-cli-first-run-snappiness.md
  • plans/007-final-integration-pass.md
  • plans/README.md

📝 Walkthrough

Walkthrough

This PR introduces an activation analytics funnel spanning client/server capture utilities, a new activation API route, onboarding/profile/feed UI changes, and analytics wiring into signup/auth-callback/usage routes. It also defers authenticated app-shell providers, right sidebar, command palette, and prompt widget for performance; refactors the public landing page and messages inbox; and adds CLI ccusage offline/online pricing-mode selection with expanded push telemetry, alongside planning documentation.

Changes

Web Activation Analytics Funnel

Layer / File(s) Summary
Activation state contract
apps/web/lib/analytics/activation.ts, apps/web/__tests__/flows/activation-contract.test.ts
Defines canonical activation events, states, and deriveActivationState/sanitizeActivationProperties utilities with contract tests.
Client/server capture wrappers
apps/web/lib/analytics/client.ts, apps/web/lib/analytics/server.ts, apps/web/lib/utils/after.ts, apps/web/__tests__/lib/analytics-server.test.ts
Adds trackActivationEvent/captureConsentedPostHogEvent client-side and captureServerActivationEvent/identifyServerActivationUser server-side, plus a resilient after() wrapper.
Activation API route
apps/web/app/api/analytics/activation/route.ts, apps/web/__tests__/api/activation-analytics.test.ts
Adds POST route validating events, managing anonymous cookies, linking identities, and capturing events.
Signup/auth callback/public analytics wiring
apps/web/app/(auth)/signup/page.tsx, apps/web/app/(auth)/callback/route.ts, apps/web/app/(auth)/layout.tsx, apps/web/app/(landing)/layout.tsx, apps/web/components/providers/PublicAnalytics.tsx
Tracks signup started/completed events and adds pageview tracking to public layouts.
Usage/users-me activation capture
apps/web/app/api/usage/status/route.ts, apps/web/app/api/usage/submit/route.ts, apps/web/app/api/users/me/route.ts, related tests
Captures activation events after usage-status polling, usage submission, and onboarding completion (gated on first sync).
Onboarding page overhaul
apps/web/app/(onboarding)/onboarding/page.tsx
Reworks sync-step copy tracking, first-sync-based completion PATCH, and removes optional profile fields.
Profile/feed activation UI
apps/web/components/app/activation/*, apps/web/components/app/feed/*, apps/web/app/(app)/u/[username]/page.tsx
Adds first-sync command card and guest signup CTA components wired into feed/profile empty states.

Estimated code review effort: 5 (Critical) | ~180 minutes

Authenticated App Shell Performance

Layer / File(s) Summary
Provider splitting
apps/web/components/providers/AppProviders.tsx, apps/web/app/layout.tsx, apps/web/app/(app)/layout.tsx, apps/web/app/admin/layout.tsx, apps/web/app/(onboarding)/layout.tsx
Centralizes providers into AppProviders, removes them from root layout, and wraps admin/onboarding/app layouts.
Right sidebar lazy load
apps/web/app/api/app/right-sidebar/route.ts, apps/web/components/app/shared/RightSidebar.tsx, apps/web/lib/query/right-sidebar.ts, apps/web/lib/query/keys.ts
Adds new aggregation API and React Query-driven LazyRightSidebar client component.
Command palette lazy load
apps/web/components/app/shared/CommandPalette.tsx, apps/web/components/app/shared/CommandPaletteInner.tsx, tests
Defers KBar palette loading until shortcut/idle trigger.
Prompt widget modal split
apps/web/components/app/prompts/*, apps/web/components/app/shared/ResponsiveShellFrame.tsx, tests
Extracts modal logic into SubmitPromptModal, simplifying the trigger widget.
Notifications fetch gating
apps/web/components/app/shared/TopHeader.tsx, tests
Enables notifications query only when dropdown is open.
Clipboard hook and open-stats snapshot
apps/web/lib/utils/useClipboardFeedback.ts, apps/web/app/(app)/post/new/CopyCommand.tsx, apps/web/components/app/profile/InviteButton.tsx, apps/web/lib/open-stats.ts, tests
Adds shared clipboard hook and converts open-stats reads to snapshot-first.

Estimated code review effort: 4 (Complex) | ~90 minutes

Public Landing Page Refactor

Layer / File(s) Summary
Shared CTA components
apps/web/components/landing/constants.ts, apps/web/components/landing/LandingActivationActions.tsx
Adds canonical command constant and SignupCtaLink/CopyCommandButton.
Section wiring
apps/web/components/landing/Hero.tsx, .../CTASection.tsx, .../Navbar.tsx, .../MobileNav.tsx
Wires shared CTA components into Hero/CTASection and delegates mobile menu to MobileNav.
Deferred visuals
apps/web/components/landing/LazyHalftoneCanvas.tsx, .../ProductHuntBadge.tsx, .../WallOfLove.tsx, apps/web/app/(landing)/open/page.tsx
Defers canvas rendering, simplifies Product Hunt badge, and removes motion from WallOfLove.
E2E coverage
apps/web/e2e/golden-path/landing-to-signup.spec.ts
Asserts canonical sync command and CTA behaviors.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Messages Inbox Presentation Refactor

Layer / File(s) Summary
Presentation components and utilities
apps/web/components/app/messages/MessagePresentation.tsx, .../message-utils.ts
Extracts MessageBubble, PendingAttachmentList, MessageImageLightbox, and shared attachment/thread helpers.
Inbox integration
apps/web/components/app/messages/MessagesInbox.tsx
Rewires message rendering to use the new presentation and utility modules.

Estimated code review effort: 3 (Moderate) | ~25 minutes

CLI Ccusage Pricing Mode and Push Telemetry

Layer / File(s) Summary
Offline/online pricing mode
packages/cli/src/lib/ccusage.ts, tests
Adds pricing-mode constants and retry logic for missing offline pricing.
Push date-range modes and telemetry
packages/cli/src/commands/push.ts, tests
Tags date-range resolution with a mode and adds detailed push telemetry properties/timings.
Telemetry shutdown helper
packages/cli/src/lib/telemetry.ts, packages/cli/src/index.ts, packages/cli/src/commands/login.ts
Adds a timed shutdown helper used by both index and push failure paths.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client (browser)
    participant ActivationAPI as /api/analytics/activation
    participant Supabase
    participant PostHog

    Client->>ActivationAPI: POST activation event (+ optional anon cookie)
    ActivationAPI->>Supabase: auth.getUser()
    alt authenticated + anon cookie present
        ActivationAPI->>PostHog: identifyServerActivationUser
    end
    ActivationAPI->>PostHog: captureServerActivationEvent
    ActivationAPI-->>Client: 200 ok (+ set anon cookie if new)
Loading
sequenceDiagram
    participant Onboarding as Onboarding Page
    participant UsersMe as PATCH /api/users/me
    participant DailyUsage as daily_usage table
    participant PostHog

    Onboarding->>UsersMe: PATCH onboarding_completed=true
    UsersMe->>DailyUsage: query latest usage row
    alt no usage row
        UsersMe-->>Onboarding: 409
    else usage exists
        UsersMe->>UsersMe: update user record
        UsersMe->>PostHog: capture activation_completed
        UsersMe-->>Onboarding: 200
    end
Loading

Possibly related PRs

  • ohong/straude#14: Both PRs modify apps/web/components/landing/Navbar.tsx and apps/web/components/landing/CTASection.tsx as part of overlapping landing redesign work.
  • ohong/straude#92: Both PRs modify /api/usage/submit and its tests, touching the same route and collector_meta handling.
  • ohong/straude#111: Both PRs change getOpenStatsForPage behavior/error handling in apps/web/lib/open-stats.ts.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/activation-funnel-contract

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

ohong added 5 commits July 3, 2026 20:02
…refactor

# Conflicts:
#	apps/web/app/api/usage/submit/route.ts
#	apps/web/types/index.ts
#	bun.lock
#	packages/cli/__tests__/ccusage-install.test.ts
#	packages/cli/__tests__/ccusage.test.ts
#	packages/cli/__tests__/commands/push.test.ts
#	packages/cli/__tests__/flows/cli-sync-flow.test.ts
#	packages/cli/package.json
#	packages/cli/src/commands/push.ts
#	packages/cli/src/lib/ccusage.ts
Merges the activation workstream integration branch into the activation funnel contract stack after CI, Claude review, CodeRabbit, and Vercel checks passed. Includes the #124 thermo quality refactor branch and the test/CI fixes made during review.
@ohong ohong marked this pull request as ready for review July 3, 2026 12:33
@ohong ohong merged commit 09bd265 into main Jul 3, 2026
5 checks passed
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