feat(flow): compra aprovada vira evento purchase.approved no catálogo (CRM-316) - #124
Merged
Merged
Conversation
…eira classe (CRM-316) A compra aprovada captada pelo webhook de compra do CRM chegava ao evo-flow escondida em campaign.triggered. Com nome e esquema próprios (categoria purchase), uma jornada pode começar em "comprou o produto X" e um segmento pode filtrar "gastou mais de Y" — o EventTrigger e o filtro de propriedades já cobrem por herança. O CRM emite; este é o lado que aceita. Ordem de deploy: evo-flow antes do CRM, senão o worker do CRM recebe 400 e descarta o evento. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JxYjUwr2vV69kYddiXJHRo
… de eventos (CRM-316) O campo amount do purchase.approved declara a unidade (maior da moeda, nunca centavos), para os produtores convergirem. Nenhuma lane rodava src/modules/events: a events-contract passa a rodar o catálogo e o pipe de validação quando o módulo muda. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JxYjUwr2vV69kYddiXJHRo
Contributor
Reviewer's GuideIntroduces the typed Sequence diagram for approved purchase event ingestionsequenceDiagram
participant CRM as CRM purchase webhook
participant API as POST /events/track
participant Pipe as EventSchemaValidationPipe
participant Catalog as Event catalog
participant Store as contact_events
CRM->>API: Submit purchase.approved
API->>Pipe: transform(payload)
Pipe->>Catalog: getEvent(purchase.approved)
Catalog-->>Pipe: purchase schema
alt valid CRM payload
Pipe-->>API: Accept numeric amount and required IDs
API->>Store: Persist purchase.approved
else missing purchase_id or string amount
Pipe-->>API: BadRequestException
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've reviewed your changes and they look great!
Sourcery assessment
Needs a human reviewer. This changes runtime schema acceptance and makes purchase.approved available to downstream journey and segment processing. If the catalog or field contract is wrong, events could be rejected or trigger downstream processing with incorrect data; reverting restores the prior validation behavior, but events or automated actions that occurred while it was live cannot be recovered by the revert alone.
Cabeçalho da lane e o bloco do catálogo estavam acima do orçamento da casa (~4 linhas em cabeçalho, ~2 inline) e carregavam narrativa que é da PR.
gomessguii
approved these changes
Sep 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
purchase.approved(categoriapurchase) no enumEVENT_NAMESe no catálogo do manifesto: uma compra aprovada numa plataforma de pagamento, capturada como lead pelo webhook de compras do CRM.provider,purchase_id,pipeline_id,pipeline_item_id,sourceobrigatórios;product,amount(número, unidade maior da moeda, nunca centavos),currency,platform_event,outcome,new_contact,contact_id, funil/etapa opcionais.custom_fieldsdocampaign.triggered.events-contract: rodasrc/modules/events(catálogo + pipe de validação) quando o módulo muda. Nenhuma lane cobria esse contrato.Security
POST /events/trackjá existente, com a mesma validação de schema.Test plan
npx jest --runInBand src/modules/events(64/64)npx tsc --noEmitpurchase.approvedno ClickHouse (contact_events) com produto, valor numérico e contato resolvido, nos dois desfechos (createdealready_in_pipeline).Ordem de deploy
evo-flow antes do CRM. Se o CRM emitir primeiro, o pipe responde 400 (evento desconhecido) e o job do CRM retenta até o Dead Set.
Changed Files
src/modules/events/event-names.enum.tssrc/modules/events/manifest/event-schema.types.tssrc/modules/events/manifest/event-catalog.tssrc/modules/events/manifest/event-catalog.spec.tssrc/modules/events/pipes/event-schema-validation.pipe.spec.ts.github/workflows/events-contract.ymlRelated PRs
Linked Issue
🤖 Generated with Claude Code
https://claude.ai/code/session_01JxYjUwr2vV69kYddiXJHRo
Summary by Sourcery
Expose approved purchases as a first-class, schema-validated event for journeys and segmentation.
New Features:
purchase.approvedtrack event to the events catalog, including purchase-specific categorization and a typed schema for CRM-captured approved purchases.Enhancements:
CI:
Tests:
purchase.approvedpayloads.