From bc76305e3fcc3c9ac69e639e90a37499566d0837 Mon Sep 17 00:00:00 2001 From: Anant Jain <62471433+anantjain45823@users.noreply.github.com> Date: Fri, 20 Oct 2023 08:58:49 +0530 Subject: [PATCH 1/2] fix: deduplication key issue (#2757) --- .../snapchat_conversion/transform.js | 17 +-- test/__tests__/data/snapchat_conversion.json | 122 +++++++++++++++++- 2 files changed, 121 insertions(+), 18 deletions(-) diff --git a/src/v0/destinations/snapchat_conversion/transform.js b/src/v0/destinations/snapchat_conversion/transform.js index c48ab5b3f8..8af5b2dadc 100644 --- a/src/v0/destinations/snapchat_conversion/transform.js +++ b/src/v0/destinations/snapchat_conversion/transform.js @@ -161,19 +161,6 @@ const addSpecificEventDetails = ( } return updatedPayload; }; -const handleDeduplication = (payload, enableDeduplication, deduplicationKey, message) => { - if (enableDeduplication) { - const dedupId = deduplicationKey || 'messageId'; - const clientDedupId = get(message, dedupId); - if (!clientDedupId) { - throw new InstrumentationError( - 'Deduplication enabled but no deduplication key provided in the message', - ); - } - return clientDedupId; - } - return undefined; -}; const getEventConversionType = (message) => { const channel = get(message, 'channel'); let eventConversionType = message?.properties?.eventConversionType; @@ -300,8 +287,6 @@ const trackResponseBuilder = (message, { Config }, mappedEvent) => { snapAppId, appId, ); - payload.client_dedup_id = handleDeduplication(enableDeduplication, deduplicationKey, message); - // adding for deduplication for more than one source if (enableDeduplication) { const dedupId = deduplicationKey || 'messageId'; @@ -412,4 +397,4 @@ const processRouterDest = async (inputs, reqMetadata) => { return [...batchResponseList, ...errorRespList]; }; -module.exports = { process, processRouterDest }; +module.exports = { process, processRouterDest }; \ No newline at end of file diff --git a/test/__tests__/data/snapchat_conversion.json b/test/__tests__/data/snapchat_conversion.json index ad21fb0d55..f4b896d73c 100644 --- a/test/__tests__/data/snapchat_conversion.json +++ b/test/__tests__/data/snapchat_conversion.json @@ -2683,13 +2683,14 @@ ] }, { - "description": "Mapping revenue to price for order completed event", + "description": "Enable deduplication with duplication key as email", "input": { "message": { "messageId": "ec5481b6-a926-4d2e-b293-0b3a77c4d3be", "originalTimestamp": "2022-04-22T10:57:58Z", "channel": "mobile", "anonymousId": "ea5cfab2-3961-4d8a-8187-3d1858c99090", + "request_ip": "127.0.0.1", "context": { "traits": { "email": "test@email.com", @@ -2744,7 +2745,8 @@ "quantity": 3 } ], - "revenue": "100" + "revenue": "100", + "custom_dedup_id": "1234" }, "integrations": { "All": true @@ -2755,6 +2757,8 @@ "Config": { "apiKey": "dummyApiKey", "pixelId": "dummyPixelId", + "deduplicationKey": "properties.custom_dedup_id", + "enableDeduplication": true, "appId": "dhfeih44f", "snapAppId": "hfhdhfd" } @@ -2777,6 +2781,120 @@ "123", "123" ], + "client_dedup_id": "1234", + "hashed_ip_address": "12ca17b49af2289436f303e0166030a21e525d266e209267433801a8fd4071a0", + "price": "100", + "hashed_email": "73062d872926c2a556f17b36f50e328ddf9bff9d403939bd14b6c3b7f5a33fc2", + "hashed_phone_number": "bc77d64d7045fe44795ed926df37231a0cfb6ec6b74588c512790e9f143cc492", + "hashed_mobile_ad_id": "f9779d734aaee50f16ee0011260bae7048f1d9a128c62b6a661077875701edd2", + "hashed_idfv": "54bd0b26a3d39dad90f5149db49b9fd9ba885f8e35d1d94cae69273f5e657b9f", + "user_agent": "mozilla/5.0 (macintosh; intel mac os x 10_15_2) applewebkit/537.36 (khtml, like gecko) chrome/79.0.3945.88 safari/537.36", + "timestamp": "1650625078", + "event_conversion_type": "MOBILE_APP", + "snap_app_id": "hfhdhfd", + "app_id": "dhfeih44f" + }, + "JSON_ARRAY": {}, + "XML": {}, + "FORM": {} + }, + "files": {} + } + }, + { + "description": "Mapping revenue to price for product list viewed event", + "input": { + "message": { + "messageId": "ec5481b6-a926-4d2e-b293-0b3a77c4d3be", + "originalTimestamp": "2022-04-22T10:57:58Z", + "channel": "mobile", + "anonymousId": "ea5cfab2-3961-4d8a-8187-3d1858c99090", + "context": { + "traits": { + "email": "test@email.com", + "phone": "+91 2111111 " + }, + "app": { + "build": "1.0.0", + "name": "RudderLabs JavaScript SDK", + "namespace": "com.rudderlabs.javascript", + "version": "1.0.0" + }, + "device": { + "advertisingId": "T0T0T072-5e28-45a1-9eda-ce22a3e36d1a", + "id": "3f034872-5e28-45a1-9eda-ce22a3e36d1a", + "manufacturer": "Google", + "name": "generic_x86_arm", + "type": "ios", + "attTrackingStatus": 3 + }, + "library": { + "name": "RudderLabs JavaScript SDK", + "version": "1.0.0" + }, + "locale": "en-US", + "os": { + "name": "iOS", + "version": "14.4.1" + }, + "screen": { + "density": 2 + }, + "externalId": [ + { + "type": "ga4AppInstanceId", + "id": "f0dd99v4f979fb997ce453373900f891" + } + ], + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36" + }, + "type": "track", + "event": "Product List Viewed", + "properties": { + "products": [ + { + "product_id": "123", + "price": "14" + }, + { + "product_id": "123", + "price": 14, + "quantity": 3 + } + ], + "revenue": "100" + }, + "integrations": { + "All": true + }, + "sentAt": "2022-04-22T10:57:58Z" + }, + "destination": { + "Config": { + "apiKey": "dummyApiKey", + "pixelId": "dummyPixelId", + "appId": "dhfeih44f", + "snapAppId": "hfhdhfd" + } + } + }, + "output": { + "version": "1", + "type": "REST", + "method": "POST", + "endpoint": "https://tr.snapchat.com/v2/conversion", + "headers": { + "Authorization": "Bearer dummyApiKey", + "Content-Type": "application/json" + }, + "params": {}, + "body": { + "JSON": { + "event_type": "VIEW_CONTENT", + "item_ids": [ + "123", + "123" + ], "price": "100", "hashed_email": "73062d872926c2a556f17b36f50e328ddf9bff9d403939bd14b6c3b7f5a33fc2", "hashed_phone_number": "bc77d64d7045fe44795ed926df37231a0cfb6ec6b74588c512790e9f143cc492", From 626c9220c860f88335ec284b6fcce5e4fc416064 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Fri, 20 Oct 2023 03:33:52 +0000 Subject: [PATCH 2/2] chore(release): 1.46.3 --- CHANGELOG.md | 7 +++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92d9a8e214..b62efe98d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [1.46.3](https://github.com/rudderlabs/rudder-transformer/compare/v1.46.2...v1.46.3) (2023-10-20) + + +### Bug Fixes + +* deduplication key issue ([#2757](https://github.com/rudderlabs/rudder-transformer/issues/2757)) ([bc76305](https://github.com/rudderlabs/rudder-transformer/commit/bc76305e3fcc3c9ac69e639e90a37499566d0837)) + ### [1.46.2](https://github.com/rudderlabs/rudder-transformer/compare/v1.46.1...v1.46.2) (2023-10-19) diff --git a/package-lock.json b/package-lock.json index 24872e2233..f211d74b0f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rudder-transformer", - "version": "1.46.2", + "version": "1.46.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rudder-transformer", - "version": "1.46.2", + "version": "1.46.3", "license": "ISC", "dependencies": { "@amplitude/ua-parser-js": "^0.7.24", diff --git a/package.json b/package.json index 011cd96751..a920837643 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rudder-transformer", - "version": "1.46.2", + "version": "1.46.3", "description": "", "homepage": "https://github.com/rudderlabs/rudder-transformer#readme", "bugs": {