Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add delivery_category as part of contents, remove flattening custom_data in FB conversions #2812

Merged
merged 5 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/v0/destinations/facebook_conversions/config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { getMappingConfig } = require('../../util');

const ENDPOINT = (datasetId, accessToken) =>
`https://graph.facebook.com/v17.0/${datasetId}/events?access_token=${accessToken}`;
`https://graph.facebook.com/v18.0/${datasetId}/events?access_token=${accessToken}`;

const CONFIG_CATEGORIES = {
USERDATA: {
Expand Down
8 changes: 5 additions & 3 deletions src/v0/destinations/facebook_conversions/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const { EventType } = require('../../../constants');
const {
constructPayload,
extractCustomFields,
flattenJson,
getIntegrationsObj,
getValidDynamicFormConfig,
simpleProcessRouterDest,
Expand Down Expand Up @@ -73,8 +72,11 @@ const responseBuilderSimple = (message, category, destination) => {
commonData.action_source = getActionSource(commonData, actionSource);

let customData = {};
customData = flattenJson(
extractCustomFields(message, customData, ['properties'], FB_CONVERSIONS_DEFAULT_EXCLUSION),
customData = extractCustomFields(
message,
customData,
['properties'],
FB_CONVERSIONS_DEFAULT_EXCLUSION,
);

customData = transformedPayloadData(
Expand Down
8 changes: 7 additions & 1 deletion src/v0/destinations/facebook_conversions/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ const getCategoryFromEvent = (eventName) => {
return category;
};

const populateContentsAndContentIDs = (productPropertiesArray, fallbackQuantity) => {
const populateContentsAndContentIDs = (
productPropertiesArray,
fallbackQuantity,
fallbackDeliveryCategory,
) => {
const contentIds = [];
const contents = [];
if (Array.isArray(productPropertiesArray)) {
Expand All @@ -57,6 +61,7 @@ const populateContentsAndContentIDs = (productPropertiesArray, fallbackQuantity)
id: productId,
quantity: productProps.quantity || fallbackQuantity || 1,
item_price: productProps.price,
delivery_category: productProps.delivery_category || fallbackDeliveryCategory,
});
}
}
Expand Down Expand Up @@ -142,6 +147,7 @@ const populateCustomDataBasedOnCategory = (customData, message, category, catego
const { contentIds, contents } = populateContentsAndContentIDs(
message.properties?.products,
message.properties?.quantity,
message.properties?.delivery_category,
);

const contentCategory = eventTypeCustomData.content_category;
Expand Down
Loading
Loading