Skip to content

Commit

Permalink
feat: dont flatten content_ids and contents before setting in custom_…
Browse files Browse the repository at this point in the history
…data
  • Loading branch information
sandeepdsvs committed Nov 2, 2023
1 parent c147906 commit 9fe0504
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
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 @@ const {
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 @@ const responseBuilderSimple = (message, category, destination) => {

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 @@ const responseBuilderSimple = (message, category, destination) => {
}
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

0 comments on commit 9fe0504

Please sign in to comment.