# Tasks: 004-onboard-funnel-events

## Phase A — Ops API

- [ ] T001 `GET /api/v1/onboard/funnel` — agregação por fase (48h)
- [ ] T002 `GET /api/v1/onboard/sessions/{session_id}/timeline`
- [ ] T003 Enriquecer `GET /api/v1/desk/tickets/{id}` com `timeline`
- [ ] T004 Actualizar `webhook_onboard`: `onboarding.completed` → nota ticket; `onboarding.failed` → ticket
- [ ] T005 Ajustar `TICKET_EVENTS_BY_SOURCE` para incluir `onboarding.failed`

## Phase B — Portal VM112

- [ ] T006 `validate-domain`: emit `onboarding.started` (1x) + `domain.validated`
- [ ] T007 `apply_cloudflare_dns`: emit `dns.applied` — ver [cloudflare-zone-provision.md](./cloudflare-zone-provision.md)
- [ ] T008 `create_account`: emit `infra.synced` + `onboarding.completed`
- [ ] T009 `create_account` except: emit `onboarding.failed`
- [ ] T010 Sync código para `/opt/ibytera-mail-portal/` VM112 + restart

## Phase C — UI Desk

- [ ] T011 Dashboard widget funil (contadores + sessões activas)
- [ ] T012 Ticket detail — secção timeline vertical
- [ ] T013 CSS funil (barras/progresso por fase)

## Phase D — Validação & Deploy

- [ ] T014 Script `scripts/verify-funnel-webhook.sh`
- [ ] T015 Deploy VM122 `/opt/ligbox-ops-platform/`
- [ ] T016 Teste E2E wizard domínio staging
- [ ] T017 Actualizar quickstart / README feature 004

## Dependencies

- T006-T009 dependem de T001-T004 (receptor pronto para novos eventos)
- T011-T013 dependem de T001-T002
- T014-T016 dependem de todas anteriores
