Skip to content

feat(capi): add meta capi event dialog, action sources and test events - #1084

Merged
viethung0o0 merged 3 commits into
mainfrom
feat/meta-capi-step-dialog
Sep 3, 2026
Merged

feat(capi): add meta capi event dialog, action sources and test events#1084
viethung0o0 merged 3 commits into
mainfrom
feat/meta-capi-step-dialog

Conversation

@viethung0o0

Copy link
Copy Markdown
Contributor

Summary

  • Rebuilds the Send Meta CAPI event flow step and Trigger action around a single "Meta CAPI" dialog: pick an action source (business_messaging by default, or email, phone_call, chat, physical_store, system_generated, other), an event from the catalog that source allows (Meta's 14 Business Messaging events, or the 17 Pixel standard events plus a custom name for non-messaging sources), optional content type and content IDs, value / currency (required for Purchase, {{variable}} templates accepted), and Content Category / Content Name under an Advanced section. The step shows a compact summary in the node and lives at the top level of the action menu.
  • Sends non-messaging action sources with hashed customer information only (user_data), keeps the messaging identity (page-scoped id / IGSID / wa_id + ctwa_clid) for business_messaging, and forwards content_type / content_ids to Meta. WhatsApp per-day dedup now applies only to business-messaging events; every other channel / action source gets a distinct event_id per fire.
  • A {{variable}} that resolves to a value Meta cannot accept is recorded in the workspace Error Log (with the resolved values) instead of only in worker logs; the step takes its error branch.
  • Adds a Test events card to each channel's CAPI tab: save / clear Meta's test_event_code (while set, every event of that integration is routed to Events Manager → Test events and not counted in reports) and Send test event, which queues a sample Purchase through the real pipeline. A test event is refused without a saved code, the worker re-checks the code right before sending, and WhatsApp tests only use click-to-WhatsApp-attributed contacts.
  • CAPI tab: a provisioned dataset whose Meta scope is missing now stays visible with a "permission needed" state instead of falling back to the connect chooser; "Create Dataset" re-asks Meta and replaces a stale stored id. The "Ads have moved to Tools" notice is removed from the three channel tabs.

Changes

  • packages/utils/src/meta-capi.ts: action-source values/schema, both event catalogs, metaCapiActionSourcePolicy (identity strategy + catalog + custom-name rule), shared defaults.
  • packages/flow-config: metaCapiEventFieldsSchema shared by step, trigger action, dialog and business input; withMetaCapiEventRefinements (Purchase needs value+currency; event must belong to the action source's catalog).
  • packages/database: MetaCapiEvent.actionSource / contentType / contentIds (+ checks), capiTestEventCode on the three integration tables, manualTest event source, contactInboxRepository.findMostRecentByInbox, updateCapiTestEventCode per repository, two migrations with snapshots.
  • packages/business/meta-conversions: enqueueEventInput with content fields, channel-policy.ts (per-channel ctwa_clid / per-day dedup rules), saveCapiTestEventCode, enqueueTestEvent, provisionDatasetNow, adapter contract extended for all three channels.
  • integrations/meta-conversions: discriminated business-messaging vs non-messaging identity, content_type / content_ids in custom_data, optional test_event_code on the request.
  • apps/worker: policy-driven identity in the send handler, test_event_code forwarding with a pre-send re-read for manual tests, Error Log reporting for invalid resolved templates (flow step + trigger executor via one enqueueCapiEvent), channel gate via the shared channel schema.
  • apps/builder: MetaCapiEventDialog / MetaCapiEventFields (one field set for step and trigger), event catalog options, labels and summary helpers, CapiTestEventCard + two channel-generic server actions, CAPI tab states (awaitingScope / missingPermission), FormFieldWrapper gains descriptionHref and hideMessage, top-level action menu entry, i18n keys in all 20 locales, docs/ads-conversion-tracking.md updated.
  • Tests: utils catalogs/policy, flow-config schema and refinements, business service (enqueue, dedup, dataset re-provision, test events, channel policy), integration payloads, worker step handler / trigger executor / send handler (test code, manual-test guard, Error Log), builder dialog, viewer, actions, CAPI status, menu.

Test plan

  • pnpm lint (ultracite + i18n key parity across all 20 locales)
  • check-types for utils, flow-config, database, business, ui, integration-meta-conversions, worker, builder
  • Vitest: utils 268, flow-config 437, database 545, business 1646, integration 23, worker 1937, builder 2391
  • Manual check on a live workspace (Messenger test page): dialog states (Purchase validation, action-source switch, custom event), publish, flow sent from Inbox → MetaCapiEvent sent for business_messaging and email sources; Test events card → event visible in Events Manager → Test events with _valueToSum; content_category / content_name recorded under Sampled activities
  • Manual check after deploy: WhatsApp channel with a click-to-WhatsApp contact (test event and real event)

Deploy

Apply migrations 20260903042613_add_meta_capi_event_action_source_content and 20260903135251_add_capi_test_event_code before rolling out the worker and builder (both add nullable / defaulted columns only). Deploy the worker before (or together with) the builder so manualTest events and test_event_code are handled.

@github-actions github-actions Bot added the feature New feature or request label Sep 3, 2026
@viethung0o0
viethung0o0 marked this pull request as ready for review September 3, 2026 17:32
@viethung0o0
viethung0o0 merged commit a012abd into main Sep 3, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants