STRATCONN-6441 - [Facebook CAPI] - refactor and additional features#3675
Open
joe-ayoub-segment wants to merge 30 commits intomainfrom
Open
STRATCONN-6441 - [Facebook CAPI] - refactor and additional features#3675joe-ayoub-segment wants to merge 30 commits intomainfrom
joe-ayoub-segment wants to merge 30 commits intomainfrom
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3675 +/- ##
=========================================
Coverage 80.82% 80.82%
=========================================
Files 1382 1327 -55
Lines 27507 24924 -2583
Branches 5853 5184 -669
=========================================
- Hits 22233 20146 -2087
+ Misses 4341 3830 -511
- Partials 933 948 +15 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Facebook Conversions API destination to fix state/country hashing during user_data construction (normalizing to 2-letter codes before hashing), while also incorporating a broader refactor that centralizes request-building/validation logic and updates tests accordingly.
Changes:
- Centralized event validation + request construction behind
send()/getUserData()logic and updated actions to call it. - Normalized
stateandcountryto 2-letter codes prior to hashing to match Meta CAPI expectations. - Extended payload/user_data support (e.g.,
ctwa_clid, append-value flows) and updated/expanded unit tests and snapshots.
Reviewed changes
Copilot reviewed 55 out of 55 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/destination-actions/src/destinations/facebook-conversions-api/viewContent2/index.ts | Switched action implementation to shared fields + centralized send() path. |
| packages/destination-actions/src/destinations/facebook-conversions-api/viewContent2/generated-types.ts | Added ctwa_clid to user_data typing. |
| packages/destination-actions/src/destinations/facebook-conversions-api/viewContent/index.ts | Switched action implementation to shared fields + centralized send() path. |
| packages/destination-actions/src/destinations/facebook-conversions-api/viewContent/generated-types.ts | Added ctwa_clid to user_data typing. |
| packages/destination-actions/src/destinations/facebook-conversions-api/utils.ts | Removed legacy API version helper (moved/renamed). |
| packages/destination-actions/src/destinations/facebook-conversions-api/types.ts | Added shared event/request/user_data types for centralized send pipeline. |
| packages/destination-actions/src/destinations/facebook-conversions-api/search2/index.ts | Switched action implementation to shared fields + centralized send() path. |
| packages/destination-actions/src/destinations/facebook-conversions-api/search2/generated-types.ts | Added ctwa_clid to user_data typing. |
| packages/destination-actions/src/destinations/facebook-conversions-api/search/index.ts | Switched action implementation to shared fields + centralized send() path. |
| packages/destination-actions/src/destinations/facebook-conversions-api/search/generated-types.ts | Added ctwa_clid to user_data typing. |
| packages/destination-actions/src/destinations/facebook-conversions-api/purchase2/index.ts | Routed action through centralized send() with explicit EventType.Purchase. |
| packages/destination-actions/src/destinations/facebook-conversions-api/purchase2/generated-types.ts | Added append-event fields, predicted_ltv, order_id, and ctwa_clid. |
| packages/destination-actions/src/destinations/facebook-conversions-api/purchase2/functions.ts | Removed per-action send implementation in favor of shared functions.ts. |
| packages/destination-actions/src/destinations/facebook-conversions-api/purchase2/fields.ts | Removed per-action field definitions in favor of shared fields. |
| packages/destination-actions/src/destinations/facebook-conversions-api/purchase/index.ts | Switched action implementation to shared fields + centralized send() path. |
| packages/destination-actions/src/destinations/facebook-conversions-api/purchase/generated-types.ts | Added append-event fields, predicted_ltv, order_id, and ctwa_clid. |
| packages/destination-actions/src/destinations/facebook-conversions-api/pageView2/index.ts | Switched action implementation to shared fields + centralized send() path. |
| packages/destination-actions/src/destinations/facebook-conversions-api/pageView2/generated-types.ts | Added ctwa_clid to user_data typing. |
| packages/destination-actions/src/destinations/facebook-conversions-api/pageView/index.ts | Switched action implementation to shared fields + centralized send() path. |
| packages/destination-actions/src/destinations/facebook-conversions-api/pageView/generated-types.ts | Added ctwa_clid to user_data typing. |
| packages/destination-actions/src/destinations/facebook-conversions-api/initiateCheckout2/index.ts | Switched action implementation to shared fields + centralized send() path. |
| packages/destination-actions/src/destinations/facebook-conversions-api/initiateCheckout2/generated-types.ts | Added ctwa_clid to user_data typing. |
| packages/destination-actions/src/destinations/facebook-conversions-api/initiateCheckout/index.ts | Switched action implementation to shared fields + centralized send() path. |
| packages/destination-actions/src/destinations/facebook-conversions-api/initiateCheckout/generated-types.ts | Added ctwa_clid to user_data typing. |
| packages/destination-actions/src/destinations/facebook-conversions-api/functions.ts | Added centralized send/validate/event-build + hashing/normalization helpers (incl. state/country normalization). |
| packages/destination-actions/src/destinations/facebook-conversions-api/fb-capi-user-data.ts | Removed legacy user_data field + normalization/hashing implementation. |
| packages/destination-actions/src/destinations/facebook-conversions-api/fb-capi-properties.ts | Removed legacy shared field definitions and helpers. |
| packages/destination-actions/src/destinations/facebook-conversions-api/fb-capi-app-data.ts | Removed legacy app-data generator + field definition. |
| packages/destination-actions/src/destinations/facebook-conversions-api/custom2/index.ts | Switched action implementation to shared fields + centralized send() path. |
| packages/destination-actions/src/destinations/facebook-conversions-api/custom2/generated-types.ts | Added append-event fields and ctwa_clid. |
| packages/destination-actions/src/destinations/facebook-conversions-api/custom/index.ts | Switched action implementation to shared fields + centralized send() path. |
| packages/destination-actions/src/destinations/facebook-conversions-api/custom/generated-types.ts | Added append-event fields and ctwa_clid. |
| packages/destination-actions/src/destinations/facebook-conversions-api/constants.ts | Added FLAGON_NAME + EventType constant used by the refactor. |
| packages/destination-actions/src/destinations/facebook-conversions-api/addToCart2/index.ts | Switched action implementation to shared fields + centralized send() path (includes syncMode guard). |
| packages/destination-actions/src/destinations/facebook-conversions-api/addToCart2/generated-types.ts | Added ctwa_clid to user_data typing. |
| packages/destination-actions/src/destinations/facebook-conversions-api/addToCart/index.ts | Switched action implementation to shared fields + centralized send() path. |
| packages/destination-actions/src/destinations/facebook-conversions-api/addToCart/generated-types.ts | Added ctwa_clid to user_data typing. |
| packages/destination-actions/src/destinations/facebook-conversions-api/tests/viewContent2.test.ts | Updated snapshots for new request shape; added ctwa_clid test. |
| packages/destination-actions/src/destinations/facebook-conversions-api/tests/viewContent.test.ts | Updated snapshots for new request shape; added ctwa_clid test. |
| packages/destination-actions/src/destinations/facebook-conversions-api/tests/utils.test.ts | Updated to use getApiVersion from functions.ts. |
| packages/destination-actions/src/destinations/facebook-conversions-api/tests/search2.test.ts | Updated snapshots for new request shape; added ctwa_clid test. |
| packages/destination-actions/src/destinations/facebook-conversions-api/tests/search.test.ts | Updated snapshots for new request shape; added ctwa_clid test. |
| packages/destination-actions/src/destinations/facebook-conversions-api/tests/purchase2.test.ts | Updated snapshots for new request shape; added ctwa_clid coverage. |
| packages/destination-actions/src/destinations/facebook-conversions-api/tests/pageView2.test.ts | Updated snapshots for new request shape; added ctwa_clid test. |
| packages/destination-actions/src/destinations/facebook-conversions-api/tests/pageView.test.ts | Updated snapshots for new request shape; added ctwa_clid test. |
| packages/destination-actions/src/destinations/facebook-conversions-api/tests/initiateCheckout2.test.ts | Updated snapshots for new request shape; added ctwa_clid test. |
| packages/destination-actions/src/destinations/facebook-conversions-api/tests/initiateCheckout.test.ts | Updated snapshots for new request shape; added ctwa_clid test. |
| packages/destination-actions/src/destinations/facebook-conversions-api/tests/custom2.test.ts | Updated snapshots for new request shape; added ctwa_clid test. |
| packages/destination-actions/src/destinations/facebook-conversions-api/tests/custom.test.ts | Updated snapshots; added extensive append-event/AppendValue behavior tests and ctwa_clid test. |
| packages/destination-actions/src/destinations/facebook-conversions-api/tests/app-data.test.ts | Updated to use centralized generateAppData implementation. |
| packages/destination-actions/src/destinations/facebook-conversions-api/tests/addToCart2.test.ts | Updated snapshots for new request shape; added ctwa_clid test. |
| packages/destination-actions/src/destinations/facebook-conversions-api/tests/addToCart.test.ts | Updated snapshots for new request shape; added ctwa_clid test. |
packages/destination-actions/src/destinations/facebook-conversions-api/shared/types.ts
Show resolved
Hide resolved
packages/destination-actions/src/destinations/facebook-conversions-api/shared/functions.ts
Show resolved
Hide resolved
packages/destination-actions/src/destinations/facebook-conversions-api/shared/functions.ts
Show resolved
Hide resolved
packages/destination-actions/src/destinations/facebook-conversions-api/addToCart2/index.ts
Show resolved
Hide resolved
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
This PR is refactors the Facebook Conversions API destination.
Action Fields are moved to a single file (fields.ts).
Perform logic is moved to a single file (functions.ts).
Original logic is still in place, and the new new code is behind feature flags (one for each Action).
Unit test changes: