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: don't flatten content_ids and contents before setting in custom_data #2790

Closed
wants to merge 1 commit into from
Closed
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: 2 additions & 0 deletions src/v0/destinations/facebook_pixel/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ const OTHER_STANDARD_EVENTS = [
];

const FB_PIXEL_DEFAULT_EXCLUSION = ['opt_out', 'event_id', 'action_source'];
const FB_PIXEL_CUSTOM_DATA_EXCLUDE_FLATTENING = ['content_ids', 'contents'];
const STANDARD_ECOMM_EVENTS_TYPE = [
CONFIG_CATEGORIES.PRODUCT_LIST_VIEWED.type,
CONFIG_CATEGORIES.PRODUCT_VIEWED.type,
Expand All @@ -109,6 +110,7 @@ module.exports = {
MAPPING_CONFIG,
ACTION_SOURCES_VALUES,
FB_PIXEL_DEFAULT_EXCLUSION,
FB_PIXEL_CUSTOM_DATA_EXCLUDE_FLATTENING,
STANDARD_ECOMM_EVENTS_TYPE,
OTHER_STANDARD_EVENTS,
DESTINATION: 'FACEBOOK_PIXEL',
Expand Down
13 changes: 12 additions & 1 deletion src/v0/destinations/facebook_pixel/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
CONFIG_CATEGORIES,
MAPPING_CONFIG,
FB_PIXEL_DEFAULT_EXCLUSION,
FB_PIXEL_CUSTOM_DATA_EXCLUDE_FLATTENING,
STANDARD_ECOMM_EVENTS_TYPE,
} = require('./config');
const { EventType } = require('../../../constants');
Expand Down Expand Up @@ -85,7 +86,12 @@

if (category.type !== 'identify') {
customData = flattenJson(
extractCustomFields(message, customData, ['properties'], FB_PIXEL_DEFAULT_EXCLUSION),
extractCustomFields(
message,
customData,
['properties'],
[...FB_PIXEL_DEFAULT_EXCLUSION, ...FB_PIXEL_CUSTOM_DATA_EXCLUDE_FLATTENING],
),
);
if (standardPageCall && category.type === 'page') {
category.standard = true;
Expand Down Expand Up @@ -124,6 +130,11 @@
}
if (type === 'simple track') {
customData.value = message.properties?.revenue;
FB_PIXEL_CUSTOM_DATA_EXCLUDE_FLATTENING.forEach((customDataParameter) => {
if (message.properties?.[customDataParameter]) {
customData[customDataParameter] = message.properties[customDataParameter];

Check warning on line 135 in src/v0/destinations/facebook_pixel/transform.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/facebook_pixel/transform.js#L135

Added line #L135 was not covered by tests
}
});
delete customData.revenue;
}
}
Expand Down
Loading