feat(onboarding): replace Cargo with a PostHog sign-up event

JU
1d ago
+107-112

Summary

Sign-ups no longer go to Cargo. When onboarding creates the organization, the Console sends a user-signed-up PostHog event, and a PostHog → HubSpot destination does what Cargo used to do.

  • Console:
    • The user-signed-up event is sent once, from the completion step that creates the organization, after the profile form. It carries:
      • email, first name, last name, company, job title, phone;
      • organization_id, signup_source: Console;
      • UTM params and gclid.
    • Removed useSignUpCargo and the NX_PUBLIC_CARGO_API_TOKEN env var, including in the build workflow.
    • useCreateUserSignUp no longer tracks anything.
  • PostHog destination (live, outside this repo): HubSpot - Inbound sign-up.
    • Company: finds the company by email domain or creates it, and sets lead_source = Inbound. Personal email domains are skipped. The company is resolved before the contact so HubSpot's auto-association doesn't create a duplicate.
    • Contact: creates or updates it with lifecyclestage = lead and contact_source = Inbound, and associates it with the company. An existing lifecycle stage is never downgraded.
    • Form: submits the HubSpot "Trial - All" form, as Cargo did, so form-based workflows and conversion reporting keep working.

After merge

  • Remove NX_PUBLIC_CARGO_API_TOKEN from the GitHub repository variables.
  • Turn off the Cargo model / HubSpot sync on the Cargo side.
  • Re-enable "Filter out internal and test users" on the PostHog destination. It is temporarily off for testing.

Test plan

  • Unit tests for domains-onboarding-feature and domains-users-sign-up-feature pass.
  • End-to-end test from local onboarding with a new email domain. In HubSpot:
    • one company was created with lead_source = Inbound;
    • the contact was created as lead / Inbound and associated with that company;
    • the "Trial - All" conversion was recorded.

šŸ¤– Generated with Claude Code


Summary by cubic

Sign-ups no longer go to Cargo: onboarding now sends a user-signed-up PostHog event when it creates the organization, and a PostHog → HubSpot destination handles the lead like Cargo did.

  • The event is sent once from the completion step that creates the organization, after the profile form, with profile fields, organization_id, signup_source: Console, and attribution params.
  • Restores UTM/gclid capture at app entry in main.tsx (it stopped working after the move to TanStack Router), and reads stored values via a new getStoredUtmParams helper instead of an onboarding-local copy. Capture is best-effort and never breaks app startup when localStorage is unavailable.
  • Removed useSignUpCargo and the NX_PUBLIC_CARGO_API_TOKEN env var, including from the build workflow.
  • The PostHog destination creates or updates the HubSpot company and contact as inbound leads and submits the "Trial - All" form.

After merge

  • Remove NX_PUBLIC_CARGO_API_TOKEN from the GitHub repository variables.
  • Turn off the Cargo model and its HubSpot sync.
  • Re-enable "Filter out internal and test users" on the PostHog destination (temporarily off for testing).