Skip to content

feat(analytics): identify users universally + instrument onboarding funnel - #30

Merged
gkhngyk merged 1 commit into
mainfrom
feat/posthog-funnel-tracking
May 16, 2026
Merged

gkhngyk merged 1 commit into
mainfrom
feat/posthog-funnel-tracking

Conversation

@gkhngyk

@gkhngyk gkhngyk commented May 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • PostHog was creating events under random anonymous distinct_ids for anyone who didn't pass through the sign-in form (page reloads, OAuth returns, email-confirm landings, etc.). Clicking an ID in PostHog showed "No profile associated with this ID", and the funnel below the sign-up step was opaque — we couldn't see where users dropped off in onboarding.
  • This PR fixes both layers behind that gap.

Layer 1 — universal identify

`AuthProvider` now subscribes to Supabase's `onAuthStateChange` and calls:

  • `identify(user.id, { email })` on `INITIAL_SESSION` / `SIGNED_IN`
  • `reset()` on `SIGNED_OUT`

The form-level `identify()` in `sign-in-form` is removed as redundant — auth state is now the single source of truth, so every signed-in user gets a person profile regardless of how they landed.

Layer 2 — onboarding funnel + person enrichment

The onboarding page now fires a structured step funnel:

  • `onboarding_step_viewed` on every step render (1–6) with `{ step, step_name }`
  • `onboarding_step_completed` on every transition, carrying step-specific props:
    • Step 1 (brand_setup): `brand_name`, `brand_domain`, `has_description`
    • Step 2 (brand_details): `region`, `language`
    • Step 3 (topics): `topic_count`
    • Step 4 (prompts): `prompt_count`, `topic_count`
    • Step 5 (competitors): `competitor_count`
    • Step 6 (plan): `plan_id`
  • `setPersonProperties` at meaningful points so the person record accrues `company_url`, `region`, `language`, `onboarding_completed`, `intended_plan` as the user advances.
  • New milestone events: `onboarding_plan_selected` (when a plan is picked), `onboarding_finished` (self-hosted completion).

Existing `onboarding_brand_created` / `onboarding_prompts_saved` events are kept for backward compatibility with anything already wired up to them.

Privacy

  • No prompt text or topic names are sent — only counts.
  • Brand name / domain / region / language are sent as person properties so PostHog can segment users without us echoing PII in every event.

Test plan

  • Existing logged-in session → `$identify` fires on next dashboard load; person profile populates with email.
  • Sign out → `reset` (anonymous), sign in → `$identify` again.
  • Fresh signup + onboarding → `onboarding_step_viewed` (1) → `step_completed` (1) → `step_viewed` (2) → … through to plan selection.
  • PostHog Persons → user shows `company_url`, `region`, `language`, `onboarding_completed`, `intended_plan` properties.
  • PostHog → Insights → Funnel built from `onboarding_step_viewed` events shows real drop-off per step.

…unnel

PostHog was creating events under random anonymous distinct_ids for
anyone who didn't pass through the sign-in form (page reloads, OAuth
returns, email-confirm landings, etc.), so clicking an ID in PostHog
showed "No profile associated with this ID" and the funnel below the
sign-up step was opaque.

This commit fixes the two layers behind that gap:

1. AuthProvider now subscribes to Supabase's onAuthStateChange and
   calls identify() on INITIAL_SESSION / SIGNED_IN, reset() on
   SIGNED_OUT. The form-level identify() in sign-in-form is removed
   as redundant — auth state is the single source of truth.

2. Onboarding page fires a structured step funnel:
   - onboarding_step_viewed on every step render (1..6)
   - onboarding_step_completed on every transition, carrying
     step-specific props (brand_domain, region, topic_count,
     prompt_count, competitor_count, plan_id)
   - setPersonProperties at meaningful points so the person record
     accrues company_url, region, language, onboarding_completed,
     intended_plan as the user advances

Existing onboarding_brand_created / onboarding_prompts_saved events
stay in place for backward compatibility with anything already wired
up to them.
@vercel

vercel Bot commented May 16, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
ansvisor Ready Ready Preview, Comment May 16, 2026 3:08pm

Request Review

@gkhngyk
gkhngyk merged commit b80f9e8 into main May 16, 2026
2 checks passed
@gkhngyk
gkhngyk deleted the feat/posthog-funnel-tracking branch May 16, 2026 15:09
@gkhngyk gkhngyk mentioned this pull request May 26, 2026

This branch was successfully deployed

1 active deployment
Preview — 9f57c2ae Deployed May 16, 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