feat(web): enrichit invoice_uploaded + ajoute payment_completed (PostHog)
All checks were successful
Build & Deploy Web / build-and-deploy (push) Successful in 27s
All checks were successful
Build & Deploy Web / build-and-deploy (push) Successful in 27s
- invoice_uploaded : un event par draft (avec invoice_id, filename,
batch_id, batch_size) au lieu d'un event groupé { count }. Permet de
lister les uploads individuellement et de cibler une facture précise
dans les insights. Amount pas dispo à ce stade (OCR pas encore validé).
- payment_completed : nouvel event sur mark-paid, avec amount_cents,
amount_eur et payment_method (= 'manual' en V1). Alimente le funnel
facture → paiement et la liste « payeurs » côté PostHog.
- invoice_marked_paid : conservé tel quel pour ne pas casser l'insight
S5hMZkDE (Invoice paid vs relance launched).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
cc44ed8ce8
commit
7919f20a4f
@ -62,8 +62,19 @@ function InvoiceDetailPage() {
|
|||||||
|
|
||||||
const markPaidMutation = useMutation({
|
const markPaidMutation = useMutation({
|
||||||
mutationFn: () => api.post<InvoiceDetail>(`/api/v1/invoices/${id}/mark-paid`),
|
mutationFn: () => api.post<InvoiceDetail>(`/api/v1/invoices/${id}/mark-paid`),
|
||||||
onSuccess: () => {
|
onSuccess: (paidInvoice) => {
|
||||||
|
// invoice_marked_paid : conservé pour les insights existants.
|
||||||
|
// payment_completed : nouvel event enrichi (montant + méthode) pour
|
||||||
|
// alimenter le funnel facture → paiement côté PostHog. En V1 la méthode
|
||||||
|
// est toujours "manual" (validation user) ; passera à "banking" quand
|
||||||
|
// la réconciliation auto Powens sera live.
|
||||||
posthog.capture("invoice_marked_paid", { invoice_id: id });
|
posthog.capture("invoice_marked_paid", { invoice_id: id });
|
||||||
|
posthog.capture("payment_completed", {
|
||||||
|
invoice_id: id,
|
||||||
|
amount_cents: paidInvoice.amountTtcCents,
|
||||||
|
amount_eur: paidInvoice.amountTtcCents / 100,
|
||||||
|
payment_method: "manual",
|
||||||
|
});
|
||||||
void queryClient.invalidateQueries({ queryKey: queryKeys.invoices.all() });
|
void queryClient.invalidateQueries({ queryKey: queryKeys.invoices.all() });
|
||||||
void queryClient.invalidateQueries({ queryKey: queryKeys.dashboard.kpis() });
|
void queryClient.invalidateQueries({ queryKey: queryKeys.dashboard.kpis() });
|
||||||
toast.success("Encaissée. + 1 rubis bien mérité.");
|
toast.success("Encaissée. + 1 rubis bien mérité.");
|
||||||
|
|||||||
@ -22,7 +22,17 @@ function ImportLandingPage() {
|
|||||||
const upload = useMutation({
|
const upload = useMutation({
|
||||||
mutationFn: uploadInvoiceFiles,
|
mutationFn: uploadInvoiceFiles,
|
||||||
onSuccess: (batch) => {
|
onSuccess: (batch) => {
|
||||||
posthog.capture("invoice_uploaded", { count: batch.drafts.length });
|
// Un event par facture pour pouvoir lister les uploads individuellement
|
||||||
|
// dans PostHog. Pas de `amount` ici : l'OCR n'a pas encore extrait les
|
||||||
|
// montants à ce stade — ils seront connus à la validation du brouillon.
|
||||||
|
for (const draft of batch.drafts) {
|
||||||
|
posthog.capture("invoice_uploaded", {
|
||||||
|
invoice_id: draft.id,
|
||||||
|
filename: draft.filename,
|
||||||
|
batch_id: batch.id,
|
||||||
|
batch_size: batch.drafts.length,
|
||||||
|
});
|
||||||
|
}
|
||||||
toast.success(
|
toast.success(
|
||||||
`${batch.drafts.length} facture${batch.drafts.length > 1 ? "s" : ""} extraite${
|
`${batch.drafts.length} facture${batch.drafts.length > 1 ? "s" : ""} extraite${
|
||||||
batch.drafts.length > 1 ? "s" : ""
|
batch.drafts.length > 1 ? "s" : ""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user