From b31ac7ac9b1338b1da648c19db5cfe3d6c3c307d Mon Sep 17 00:00:00 2001 From: sandeepdigumarty Date: Wed, 11 Oct 2023 16:55:09 +0530 Subject: [PATCH] feat: added event type mapping json for all standard events --- src/v0/destinations/facebook_pixel/config.js | 12 +- .../FBPIXELCheckoutStartedCustomData.json | 48 +++++ .../data/FBPIXELOrderCompletedCustomData.json | 52 +++++ .../data/FBPIXELProductAddedCustomData.json | 48 +++++ .../FBPIXELProductListViewedCustomData.json | 35 +++ .../FBPIXELProductSearchedCustomData.json | 39 ++++ .../data/FBPIXELProductViewedCustomData.json | 56 +++++ .../destinations/facebook_pixel/transform.js | 10 +- .../facebook_pixel/transform.test.js | 201 ------------------ src/v0/destinations/facebook_pixel/utils.js | 166 +++++---------- 10 files changed, 339 insertions(+), 328 deletions(-) create mode 100644 src/v0/destinations/facebook_pixel/data/FBPIXELCheckoutStartedCustomData.json create mode 100644 src/v0/destinations/facebook_pixel/data/FBPIXELOrderCompletedCustomData.json create mode 100644 src/v0/destinations/facebook_pixel/data/FBPIXELProductAddedCustomData.json create mode 100644 src/v0/destinations/facebook_pixel/data/FBPIXELProductListViewedCustomData.json create mode 100644 src/v0/destinations/facebook_pixel/data/FBPIXELProductSearchedCustomData.json create mode 100644 src/v0/destinations/facebook_pixel/data/FBPIXELProductViewedCustomData.json delete mode 100644 src/v0/destinations/facebook_pixel/transform.test.js diff --git a/src/v0/destinations/facebook_pixel/config.js b/src/v0/destinations/facebook_pixel/config.js index 99c3c70b2d..e3c20d291c 100644 --- a/src/v0/destinations/facebook_pixel/config.js +++ b/src/v0/destinations/facebook_pixel/config.js @@ -16,37 +16,37 @@ const CONFIG_CATEGORIES = { standard: true, type: 'product list viewed', eventName: 'ViewContent', - name: 'FBPIXELPSimpleCustomConfig', + name: 'FBPIXELProductListViewedCustomData', }, PRODUCT_VIEWED: { standard: true, type: 'product viewed', eventName: 'ViewContent', - name: 'FBPIXELPSimpleCustomConfig', + name: 'FBPIXELProductViewedCustomData', }, PRODUCT_ADDED: { standard: true, type: 'product added', eventName: 'AddToCart', - name: 'FBPIXELPSimpleCustomConfig', + name: 'FBPIXELProductAddedCustomData', }, ORDER_COMPLETED: { standard: true, type: 'order completed', eventName: 'Purchase', - name: 'FBPIXELPSimpleCustomConfig', + name: 'FBPIXELOrderCompletedCustomData', }, PRODUCTS_SEARCHED: { standard: true, type: 'products searched', eventName: 'Search', - name: 'FBPIXELPSimpleCustomConfig', + name: 'FBPIXELProductSearchedCustomData', }, CHECKOUT_STARTED: { standard: true, type: 'checkout started', eventName: 'InitiateCheckout', - name: 'FBPIXELPSimpleCustomConfig', + name: 'FBPIXELCheckoutStartedCustomData', }, OTHER_STANDARD: { standard: true, diff --git a/src/v0/destinations/facebook_pixel/data/FBPIXELCheckoutStartedCustomData.json b/src/v0/destinations/facebook_pixel/data/FBPIXELCheckoutStartedCustomData.json new file mode 100644 index 0000000000..47938912b4 --- /dev/null +++ b/src/v0/destinations/facebook_pixel/data/FBPIXELCheckoutStartedCustomData.json @@ -0,0 +1,48 @@ +[ + { + "destKey": "content_category", + "sourceKeys": "properties.category" + }, + { + "destKey": "content_ids", + "sourceKeys": "", + "metadata": { + "defaultValue": [] + } + }, + { + "destKey": "content_type", + "sourceKeys": "", + "metadata": { + "defaultValue": "product" + } + }, + { + "destKey": "currency", + "sourceKeys": "properties.currency", + "metadata": { + "defaultValue": "USD" + } + }, + { + "destKey": "value", + "sourceKeys": "properties.revenue", + "metadata": { + "type": "numberForRevenue" + } + }, + { + "destKey": "contents", + "sourceKeys": "", + "metadata": { + "defaultValue": [] + } + }, + { + "destKey": "num_items", + "sourceKeys": "", + "metadata": { + "defaultValue": 0 + } + } +] diff --git a/src/v0/destinations/facebook_pixel/data/FBPIXELOrderCompletedCustomData.json b/src/v0/destinations/facebook_pixel/data/FBPIXELOrderCompletedCustomData.json new file mode 100644 index 0000000000..a95315008b --- /dev/null +++ b/src/v0/destinations/facebook_pixel/data/FBPIXELOrderCompletedCustomData.json @@ -0,0 +1,52 @@ +[ + { + "destKey": "content_category", + "sourceKeys": "properties.category" + }, + { + "destKey": "content_ids", + "sourceKeys": "", + "metadata": { + "defaultValue": [] + } + }, + { + "destKey": "content_type", + "sourceKeys": "", + "metadata": { + "defaultValue": "product" + } + }, + { + "destKey": "currency", + "sourceKeys": "properties.currency", + "metadata": { + "defaultValue": "USD" + } + }, + { + "destKey": "value", + "sourceKeys": "properties.revenue", + "metadata": { + "type": "numberForRevenue" + } + }, + { + "destKey": "contents", + "sourceKeys": "", + "metadata": { + "defaultValue": [] + } + }, + { + "destKey": "num_items", + "sourceKeys": "", + "metadata": { + "defaultValue": 0 + } + }, + { + "destKey": "content_name", + "sourceKeys": "properties.contentName" + } +] diff --git a/src/v0/destinations/facebook_pixel/data/FBPIXELProductAddedCustomData.json b/src/v0/destinations/facebook_pixel/data/FBPIXELProductAddedCustomData.json new file mode 100644 index 0000000000..786cb58e62 --- /dev/null +++ b/src/v0/destinations/facebook_pixel/data/FBPIXELProductAddedCustomData.json @@ -0,0 +1,48 @@ +[ + { + "destKey": "content_ids", + "sourceKeys": ["properties.product_id", "properties.sku", "properties.id"] + }, + { + "destKey": "content_type", + "sourceKeys": "", + "metadata": { + "defaultValue": "product" + } + }, + { + "destKey": "content_name", + "sourceKeys": ["properties.product_name", "properties.name"], + "metadata": { + "defaultValue": "" + } + }, + { + "destKey": "content_category", + "sourceKeys": "properties.category", + "metadata": { + "defaultValue": "" + } + }, + { + "destKey": "currency", + "sourceKeys": "properties.currency", + "metadata": { + "defaultValue": "USD" + } + }, + { + "destKey": "value", + "sourceKeys": "properties.value", + "metadata": { + "type": "numberForRevenue" + } + }, + { + "destKey": "contents", + "sourceKeys": "", + "metadata": { + "defaultValue": [] + } + } +] diff --git a/src/v0/destinations/facebook_pixel/data/FBPIXELProductListViewedCustomData.json b/src/v0/destinations/facebook_pixel/data/FBPIXELProductListViewedCustomData.json new file mode 100644 index 0000000000..d2658f33e7 --- /dev/null +++ b/src/v0/destinations/facebook_pixel/data/FBPIXELProductListViewedCustomData.json @@ -0,0 +1,35 @@ +[ + { + "destKey": "content_ids", + "sourceKeys": "", + "metadata": { + "defaultValue": [] + } + }, + { + "destKey": "content_type", + "sourceKeys": "" + }, + { + "destKey": "contents", + "sourceKeys": "", + "metadata": { + "defaultValue": [] + } + }, + { + "destKey": "content_category", + "sourceKeys": "properties.category" + }, + { + "destKey": "content_name", + "sourceKeys": "properties.contentName" + }, + { + "destKey": "value", + "sourceKeys": "properties.value", + "metadata": { + "type": "numberForRevenue" + } + } +] diff --git a/src/v0/destinations/facebook_pixel/data/FBPIXELProductSearchedCustomData.json b/src/v0/destinations/facebook_pixel/data/FBPIXELProductSearchedCustomData.json new file mode 100644 index 0000000000..15635b7cf3 --- /dev/null +++ b/src/v0/destinations/facebook_pixel/data/FBPIXELProductSearchedCustomData.json @@ -0,0 +1,39 @@ +[ + { + "destKey": "content_ids", + "sourceKeys": ["properties.product_id", "properties.sku", "properties.id"] + }, + { + "destKey": "content_category", + "sourceKeys": "properties.category", + "metadata": { + "defaultValue": "" + } + }, + { + "destKey": "value", + "sourceKeys": "properties.value", + "metadata": { + "type": "numberForRevenue" + } + }, + { + "destKey": "contents.0.id", + "sourceKeys": ["properties.product_id", "properties.sku", "properties.id"] + }, + { + "destKey": "contents.0.quantity", + "sourceKeys": "properties.quantity", + "metadata": { + "defaultValue": 1 + } + }, + { + "destKey": "contents.0.item_price", + "sourceKeys": "properties.price" + }, + { + "destKey": "search_string", + "sourceKeys": "properties.query" + } +] diff --git a/src/v0/destinations/facebook_pixel/data/FBPIXELProductViewedCustomData.json b/src/v0/destinations/facebook_pixel/data/FBPIXELProductViewedCustomData.json new file mode 100644 index 0000000000..e233641b8a --- /dev/null +++ b/src/v0/destinations/facebook_pixel/data/FBPIXELProductViewedCustomData.json @@ -0,0 +1,56 @@ +[ + { + "destKey": "content_ids", + "sourceKeys": ["properties.product_id", "properties.sku", "properties.id"] + }, + { + "destKey": "content_type", + "sourceKeys": "", + "metadata": { + "defaultValue": "product" + } + }, + { + "destKey": "content_name", + "sourceKeys": ["properties.product_name", "properties.name"], + "metadata": { + "defaultValue": "" + } + }, + { + "destKey": "content_category", + "sourceKeys": "properties.category", + "metadata": { + "defaultValue": "" + } + }, + { + "destKey": "currency", + "sourceKeys": "properties.currency", + "metadata": { + "defaultValue": "USD" + } + }, + { + "destKey": "value", + "sourceKeys": "properties.value", + "metadata": { + "type": "numberForRevenue" + } + }, + { + "destKey": "contents.0.id", + "sourceKeys": ["properties.product_id", "properties.sku", "properties.id"] + }, + { + "destKey": "contents.0.quantity", + "sourceKeys": "properties.quantity", + "metadata": { + "defaultValue": 1 + } + }, + { + "destKey": "contents.0.item_price", + "sourceKeys": "properties.price" + } +] diff --git a/src/v0/destinations/facebook_pixel/transform.js b/src/v0/destinations/facebook_pixel/transform.js index 4a4c79af9e..798b3157d9 100644 --- a/src/v0/destinations/facebook_pixel/transform.js +++ b/src/v0/destinations/facebook_pixel/transform.js @@ -24,10 +24,6 @@ const { transformedPayloadData, getActionSource, fetchUserData, - handleProduct, - handleSearch, - handleProductListViewed, - handleOrder, formingFinalResponse, populateCustomDataBasedOnCategory, getCategoryFromEvent, @@ -227,9 +223,5 @@ const processRouterDest = async (inputs, reqMetadata) => { module.exports = { process, - processRouterDest, - handleSearch, - handleProductListViewed, - handleProduct, - handleOrder, + processRouterDest }; diff --git a/src/v0/destinations/facebook_pixel/transform.test.js b/src/v0/destinations/facebook_pixel/transform.test.js deleted file mode 100644 index 25332d770c..0000000000 --- a/src/v0/destinations/facebook_pixel/transform.test.js +++ /dev/null @@ -1,201 +0,0 @@ -const { - handleSearch, - handleProductListViewed, - handleProduct, - handleOrder, -} = require('../../../../src/v0/destinations/facebook_pixel/transform'); - -const getTestMessage = () => { - let message = { - properties: { - currency: 'CAD', - quantity: 1, - price: 24.75, - value: 30, - name: 'my product 1', - category: 'clothing', - sku: 'p-298', - testDimension: true, - testMetric: true, - position: 4.5, - query: 'HDMI Cable', - }, - }; - return message; -}; - -const getTestCategoryToContent = () => { - let categoryToContent = [ - { - from: 'spin_result', - to: 'Schedule', - }, - ]; - return categoryToContent; -}; - -describe('Unit test cases for facebook_pixel handle search', () => { - it('should return content with all fields not null', async () => { - const expectedOutput = { - content_ids: ['p-298'], - content_category: 'clothing', - value: 30, - search_string: 'HDMI Cable', - contents: [ - { - id: 'p-298', - quantity: 1, - item_price: 24.75, - }, - ], - }; - expect(handleSearch(getTestMessage())).toEqual(expectedOutput); - }); - - it("mapping 'product_id' with contentId", async () => { - let message = getTestMessage(); - message.properties.product_id = 'prd-123'; - - const expectedOutput = { - content_ids: ['prd-123'], - content_category: 'clothing', - value: 30, - search_string: 'HDMI Cable', - contents: [ - { - id: 'prd-123', - quantity: 1, - item_price: 24.75, - }, - ], - }; - expect(handleSearch(message)).toEqual(expectedOutput); - }); - - it("null/undefined 'properties'", async () => { - let message = getTestMessage(); - message.properties = null; - - const expectedOutput = { - content_category: '', - content_ids: [], - contents: [], - search_string: undefined, - value: 0, - }; - expect(handleSearch(message)).toEqual(expectedOutput); - }); -}); - -describe('Unit test cases for facebook_pixel handleProductListViewed', () => { - it('without product array', () => { - let expectedOutput = { - content_category: 'clothing', - content_ids: ['clothing'], - content_name: undefined, - content_type: 'product_group', - contents: [{ id: 'clothing', quantity: 1 }], - value: 30, - }; - expect(handleProductListViewed(getTestMessage(), getTestCategoryToContent())).toEqual( - expectedOutput, - ); - }); - - it('with product array', () => { - let fittingPayload = { ...getTestMessage() }; - fittingPayload.properties.products = [{ id: 'clothing', quantity: 2 }]; - let expectedOutput = { - content_category: 'clothing', - content_ids: ['clothing'], - content_name: undefined, - content_type: 'product', - contents: [{ id: 'clothing', item_price: undefined, quantity: 2 }], - value: 30, - }; - expect(handleProductListViewed(fittingPayload, getTestCategoryToContent())).toEqual( - expectedOutput, - ); - }); -}); - -describe('Unit test cases for facebook_pixel handleProduct', () => { - it('with valueFieldIdentifier properties.value', () => { - let expectedOutput = { - content_category: 'clothing', - content_ids: ['p-298'], - content_name: 'my product 1', - content_type: 'product', - contents: [{ id: 'p-298', item_price: 24.75, quantity: 1 }], - currency: 'CAD', - value: 30, - }; - expect(handleProduct(getTestMessage(), getTestCategoryToContent(), 'properties.value')).toEqual( - expectedOutput, - ); - }); - - it('with valueFieldIdentifier properties.price', () => { - let expectedOutput = { - content_category: 'clothing', - content_ids: ['p-298'], - content_name: 'my product 1', - content_type: 'product', - contents: [{ id: 'p-298', item_price: 24.75, quantity: 1 }], - currency: 'CAD', - value: 24.75, - }; - expect(handleProduct(getTestMessage(), getTestCategoryToContent(), 'properties.price')).toEqual( - expectedOutput, - ); - }); -}); - -describe('Unit test cases for facebook_pixel handleOrder', () => { - it('without product array', () => { - let expectedOutput = { - content_category: 'clothing', - content_ids: [], - content_name: undefined, - content_type: 'product', - contents: [], - currency: 'CAD', - num_items: 0, - value: 0, - }; - expect(handleOrder(getTestMessage(), getTestCategoryToContent())).toEqual(expectedOutput); - }); - - it('with product array without revenue', () => { - let fittingPayload = { ...getTestMessage() }; - fittingPayload.properties.products = [{ id: 'clothing', quantity: 2 }]; - let expectedOutput = { - content_category: 'clothing', - content_ids: ['clothing'], - content_name: undefined, - content_type: 'product', - contents: [{ id: 'clothing', item_price: 24.75, quantity: 2 }], - currency: 'CAD', - num_items: 1, - value: 0, - }; - expect(handleOrder(fittingPayload, getTestCategoryToContent())).toEqual(expectedOutput); - }); - - it('with product array with revenue', () => { - let fittingPayload = { ...getTestMessage() }; - fittingPayload.properties.products = [{ id: 'clothing', quantity: 2 }]; - fittingPayload.properties.revenue = 124; - let expectedOutput = { - content_category: 'clothing', - content_ids: ['clothing'], - content_name: undefined, - content_type: 'product', - contents: [{ id: 'clothing', item_price: 24.75, quantity: 2 }], - currency: 'CAD', - num_items: 1, - value: 124, - }; - expect(handleOrder(fittingPayload, getTestCategoryToContent())).toEqual(expectedOutput); - }); -}); diff --git a/src/v0/destinations/facebook_pixel/utils.js b/src/v0/destinations/facebook_pixel/utils.js index 3b8baba2d7..bf7585fd7b 100644 --- a/src/v0/destinations/facebook_pixel/utils.js +++ b/src/v0/destinations/facebook_pixel/utils.js @@ -300,21 +300,11 @@ const fetchUserData = (message, Config) => { return userData; }; -/** - * - * @param {*} message Rudder element - * @param {*} categoryToContent [ { from: 'clothing', to: 'product' } ] - * - * Handles order completed and checkout started types of specific events - */ -const handleOrder = (message, categoryToContent) => { - const { products, revenue } = message.properties; - const value = formatRevenue(revenue); - - const contentType = getContentType(message, 'product', categoryToContent); +const updateCustomDataForOrderCompletedAndCheckoutStarted = (customData, message, categoryToContent) => { + const { products } = message.properties; const contentIds = []; const contents = []; - const { category, quantity, price, currency, contentName } = message.properties; + const { quantity, price} = message.properties; if (products) { if (products.length > 0 && Array.isArray(products)) { products.forEach((singleProduct) => { @@ -336,30 +326,20 @@ const handleOrder = (message, categoryToContent) => { } } - return { - content_category: getContentCategory(category), - content_ids: contentIds, - content_type: contentType, - currency: currency || 'USD', - value, - contents, - num_items: contentIds.length, - content_name: contentName, - }; + const updatedCustomData = { ...customData } + updatedCustomData.content_category = getContentCategory(customData.content_category); + updatedCustomData.content_ids = contentIds; + updatedCustomData.content_type = getContentType(message, customData.content_type, categoryToContent); + updatedCustomData.contents = contents; + updatedCustomData.num_items = contentIds.length; + + return updatedCustomData; }; -/** - * - * @param {*} message Rudder element - * @param {*} categoryToContent [ { from: 'clothing', to: 'product' } ] - * - * Handles product list viewed - */ -const handleProductListViewed = (message, categoryToContent) => { - let contentType; +const updateCustomDataForProductListViewed = (customData, message, categoryToContent) => { const contentIds = []; const contents = []; - const { products, category, quantity, value, contentName } = message.properties; + const { products, quantity } = message.properties; if (products && products.length > 0 && Array.isArray(products)) { products.forEach((product, index) => { if (isObject(product)) { @@ -378,6 +358,8 @@ const handleProductListViewed = (message, categoryToContent) => { }); } + let contentType; + const category = customData.content_category; if (contentIds.length > 0) { contentType = 'product'; // for viewContent event content_ids and content arrays are not mandatory @@ -390,35 +372,19 @@ const handleProductListViewed = (message, categoryToContent) => { contentType = 'product_group'; } - return { - content_ids: contentIds, - content_type: getContentType(message, contentType, categoryToContent), - contents, - content_category: getContentCategory(category), - content_name: contentName, - value: formatRevenue(value), - }; + const updatedCustomData = { ...customData } + updatedCustomData.content_ids = contentIds; + updatedCustomData.content_type = getContentType(message, contentType, categoryToContent); + updatedCustomData.contents = contents; + updatedCustomData.content_category = getContentCategory(category); + + return updatedCustomData; }; -/** - * - * @param {*} message Rudder Payload - * @param {*} categoryToContent Example: [ { from: 'clothing', to: 'product' } ] - * @param {*} valueFieldIdentifier it can be either value or price which will be matched from properties and assigned to value for fb payload - */ -const handleProduct = (message, categoryToContent, valueFieldIdentifier) => { +const updateCustomDataForProductAddedAndProductViewed = (customData, message, categoryToContent, valueFieldIdentifier) => { const contentIds = []; const contents = []; - const useValue = valueFieldIdentifier === 'properties.value'; - const contentId = - message.properties?.product_id || message.properties?.sku || message.properties?.id; - const contentType = getContentType(message, 'product', categoryToContent); - const contentName = message.properties.product_name || message.properties.name || ''; - const contentCategory = message.properties.category || ''; - const currency = message.properties.currency || 'USD'; - const value = useValue - ? formatRevenue(message.properties.value) - : formatRevenue(message.properties.price); + const contentId = customData.content_ids; if (contentId) { contentIds.push(contentId); contents.push({ @@ -427,19 +393,22 @@ const handleProduct = (message, categoryToContent, valueFieldIdentifier) => { item_price: message.properties.price, }); } - return { - content_ids: contentIds, - content_type: contentType, - content_name: contentName, - content_category: getContentCategory(contentCategory), - currency, - value, - contents, - }; + + const updatedCustomData = { ...customData } + updatedCustomData.content_ids = contentIds; + updatedCustomData.content_type = getContentType(message, customData.content_type, categoryToContent); + updatedCustomData.content_category = getContentCategory(customData.content_category); + const useValue = valueFieldIdentifier === 'properties.value'; + if (!useValue) { + updatedCustomData.value = formatRevenue(message?.properties?.price); + } + updatedCustomData.contents = contents; + + return updatedCustomData; }; -const handleSearch = (message) => { - const query = message?.properties?.query; +const updateCustomDataForProductSearched = (customData, message) => { + const query = customData.search_string; /** * Facebook Pixel states "search_string" a string type * ref: https://developers.facebook.com/docs/meta-pixel/reference#:~:text=an%20exact%20value.-,search_string,-String @@ -453,10 +422,7 @@ const handleSearch = (message) => { const contentIds = []; const contents = []; - const contentId = - message.properties?.product_id || message.properties?.sku || message.properties?.id; - const contentCategory = message?.properties?.category || ''; - const value = message?.properties?.value; + const contentId = customData.content_ids; if (contentId) { contentIds.push(contentId); contents.push({ @@ -465,13 +431,13 @@ const handleSearch = (message) => { item_price: message?.properties?.price, }); } - return { - content_ids: contentIds, - content_category: getContentCategory(contentCategory), - value: formatRevenue(value), - contents, - search_string: query, - }; + + const updatedCustomData = { ...customData } + updatedCustomData.content_ids = contentIds; + updatedCustomData.content_category = getContentCategory(customData.content_category); + updatedCustomData.contents = contents; + + return updatedCustomData; }; const populateCustomDataBasedOnCategory = ( @@ -481,52 +447,32 @@ const populateCustomDataBasedOnCategory = ( categoryToContent, valueFieldIdentifier, ) => { - let updatedCustomData; + let eventTypeCustomData = constructPayload(message, category.name); switch (category.type) { case 'product list viewed': - updatedCustomData = { - ...customData, - ...handleProductListViewed(message, categoryToContent), - }; + eventTypeCustomData = updateCustomDataForProductListViewed(eventTypeCustomData, message, categoryToContent); break; case 'product viewed': case 'product added': - updatedCustomData = { - ...customData, - ...handleProduct(message, categoryToContent, valueFieldIdentifier), - }; + eventTypeCustomData = updateCustomDataForProductAddedAndProductViewed(eventTypeCustomData, message, categoryToContent, valueFieldIdentifier); break; case 'order completed': - updatedCustomData = { - ...customData, - ...handleOrder(message, categoryToContent), - }; + case 'checkout started': + eventTypeCustomData = updateCustomDataForOrderCompletedAndCheckoutStarted(eventTypeCustomData, message, categoryToContent); break; case 'products searched': { - updatedCustomData = { - ...customData, - ...handleSearch(message), - }; - break; - } - case 'checkout started': { - const orderPayload = handleOrder(message, categoryToContent); - delete orderPayload.content_name; - updatedCustomData = { - ...customData, - ...orderPayload, - }; + eventTypeCustomData = updateCustomDataForProductSearched(eventTypeCustomData, message); break; } case 'page_view': // executed when sending track calls but with standard type PageView case 'page': // executed when page call is done with standard PageView turned on case 'otherStandard': - updatedCustomData = { ...customData }; + eventTypeCustomData = { ...eventTypeCustomData }; break; default: throw new InstrumentationError(`${category.standard} type of standard event does not exist`); } - return updatedCustomData; + return { ...customData, ...eventTypeCustomData }; }; const getCategoryFromEvent = (eventName) => { @@ -611,10 +557,6 @@ module.exports = { transformedPayloadData, getActionSource, fetchUserData, - handleProduct, - handleSearch, - handleProductListViewed, - handleOrder, formingFinalResponse, populateCustomDataBasedOnCategory, getCategoryFromEvent,