Skip to content

feat(kiloclaw): add claw_trial_started and claw_transaction PostHog events#1346

Open
pedroheyerdahl wants to merge 4 commits intomainfrom
feat/kiloclaw-posthog-trial-transaction-events
Open

feat(kiloclaw): add claw_trial_started and claw_transaction PostHog events#1346
pedroheyerdahl wants to merge 4 commits intomainfrom
feat/kiloclaw-posthog-trial-transaction-events

Conversation

@pedroheyerdahl
Copy link
Contributor

Summary

Adds two server-side PostHog events to close the KiloClaw funnel visibility gap between signup and paid conversion:

  • claw_trial_started — fires in ensureProvisionAccess when a new trial subscription row is created during first provisioning. Properties: user_id, plan, trial_ends_at.
  • claw_transaction — fires on invoice.paid for KiloClaw subscription invoices with amount_paid > 0. Wires up the previously-unused invoiceLooksLikeKiloClawByPriceId classifier. Properties: user_id, plan, amount_cents, currency, stripe_invoice_id, stripe_subscription_id.

Both events use google_user_email as distinctId, matching the codebase convention. claw_transaction runs inside after() with IS_IN_AUTOMATED_TEST guard, matching the organization-seats.ts pattern for Stripe webhook PostHog events. claw_trial_started captures inline, matching the user.ts pattern for tRPC-context events.

Verification

  • pnpm typecheck — passes (no new errors, all pre-existing)
  • oxfmt --list-different — passes
  • oxlint — passes (0 warnings, 0 errors)
  • eslint — passes
  • Pre-push hook (format + lint + typecheck) — passes

Visual Changes

N/A

Reviewer Notes

  • The changes are additive — no existing queries or handler logic is modified. The INSERT in ensureProvisionAccess is unchanged (no .returning() chain).
  • invoiceLooksLikeKiloClawByPriceId was written previously but never wired up — this PR connects it to the invoice.paid handler in stripe.ts.
  • PostHog captures are no-ops outside production (the client returns stubs in dev/test), so these changes cannot affect test behavior.

@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Mar 20, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (6 files)
  • kiloclaw/src/config.ts
  • kiloclaw/src/durable-objects/kiloclaw-instance.test.ts
  • kiloclaw/src/durable-objects/kiloclaw-instance/fly-machines.ts
  • kiloclaw/src/durable-objects/kiloclaw-instance/index.ts
  • kiloclaw/src/fly/client.ts
  • kiloclaw/wrangler.jsonc

Reviewed by gpt-5.4-20260305 · 736,047 tokens

…vents

Add server-side PostHog tracking for KiloClaw trial creation and
subscription payments to close the funnel visibility gap between
signup and paid conversion.
@pedroheyerdahl pedroheyerdahl force-pushed the feat/kiloclaw-posthog-trial-transaction-events branch from 4104c8a to 60bddfe Compare March 20, 2026 21:46
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.

2 participants