0029_marketing_events.sql 935 B

123456789101112131415161718192021222324
  1. -- 0029_marketing_events — minimal funnel tracking for /migrate.
  2. --
  3. -- Records two event types:
  4. -- migrate_view — fired when /migrate/<source> renders
  5. -- migrate_lead_submitted — fired when POST /v1/migration-leads succeeds
  6. --
  7. -- Source values: convex | supabase | firebase | mongodb | drizzle |
  8. -- prisma | postgres | hasura | nextauth | other | hub (the /migrate
  9. -- index page itself).
  10. --
  11. -- No PII; ip_hash optional for future dedup-by-visitor logic. Customer
  12. -- emails are recorded only in migration_requests (the actual lead).
  13. CREATE TABLE IF NOT EXISTS "marketing_events" (
  14. "id" text PRIMARY KEY NOT NULL,
  15. "event_type" text NOT NULL,
  16. "source" text NOT NULL,
  17. "ip_hash" text,
  18. "user_agent" text,
  19. "created_at" timestamp with time zone DEFAULT now() NOT NULL
  20. );
  21. CREATE INDEX IF NOT EXISTS "marketing_events_lookup_idx"
  22. ON "marketing_events" USING btree ("source", "event_type", "created_at" DESC);