From f0493dccfd47bfe1897ebcec27141e2df31393c0 Mon Sep 17 00:00:00 2001 From: srikanth Date: Tue, 17 Oct 2023 17:05:48 -0500 Subject: [PATCH 1/4] fix: add event metadata to 298 status code responses --- src/services/userTransform.ts | 14 +++++++++++--- src/types/index.ts | 5 +++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/services/userTransform.ts b/src/services/userTransform.ts index d54c105b02..5104418f6d 100644 --- a/src/services/userTransform.ts +++ b/src/services/userTransform.ts @@ -7,6 +7,7 @@ import { ProcessorTransformationResponse, UserTransformationResponse, UserTransformationServiceResponse, + MessageIdMetadataMap, } from '../types/index'; import { RespStatusError, @@ -49,8 +50,15 @@ export default class UserTransformService { const eventsToProcess = destEvents as ProcessorTransformationRequest[]; const transformationVersionId = eventsToProcess[0]?.destination?.Transformations[0]?.VersionID; - const messageIds = eventsToProcess.map((ev) => ev.metadata?.messageId); - const messageIdsSet = new Set(messageIds); + const messageIds: string[] = []; + const messageIdsSet = new Set(); + const messageIdMetadataMap: MessageIdMetadataMap = {}; + eventsToProcess.forEach((ev) => { + messageIds.push(ev.metadata?.messageId); + messageIdsSet.add(ev.metadata?.messageId); + messageIdMetadataMap[ev.metadata?.messageId] = ev.metadata; + }); + const messageIdsInOutputSet = new Set(); const commonMetadata = { @@ -125,7 +133,7 @@ export default class UserTransformService { const droppedEvents = messageIdsNotInOutput.map((id) => ({ statusCode: HTTP_CUSTOM_STATUS_CODES.FILTERED, metadata: { - ...commonMetadata, + ...(isEmpty(messageIdMetadataMap[id]) ? commonMetadata : messageIdMetadataMap[id]), messageId: id, messageIds: null, }, diff --git a/src/types/index.ts b/src/types/index.ts index ff0c1f88b9..75b30a987a 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -52,6 +52,10 @@ type Metadata = { transformationId: string; }; +type MessageIdMetadataMap { + [key: string]: Metadata; +} + type UserTransformationInput = { VersionID: string; ID: string; @@ -223,6 +227,7 @@ type ComparatorInput = { export { Metadata, + MessageIdMetadataMap, UserTransformationLibrary, ProcessorTransformationRequest, ProcessorTransformationResponse, From e58127c7654952e28a78f73e79ca97b808bb3a9b Mon Sep 17 00:00:00 2001 From: srikanth Date: Tue, 17 Oct 2023 17:17:01 -0500 Subject: [PATCH 2/4] chore(release): 1.45.2 --- 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 e78e5a6a0a..4156e90228 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.45.2](https://github.com/rudderlabs/rudder-transformer/compare/v1.45.1...v1.45.2) (2023-10-17) + + +### Bug Fixes + +* add event metadata to 298 status code responses ([f0493dc](https://github.com/rudderlabs/rudder-transformer/commit/f0493dccfd47bfe1897ebcec27141e2df31393c0)) + ### [1.45.1](https://github.com/rudderlabs/rudder-transformer/compare/v1.45.0...v1.45.1) (2023-10-17) diff --git a/package-lock.json b/package-lock.json index 750791d676..1f53db2cc6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rudder-transformer", - "version": "1.45.1", + "version": "1.45.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rudder-transformer", - "version": "1.45.1", + "version": "1.45.2", "license": "ISC", "dependencies": { "@amplitude/ua-parser-js": "^0.7.24", diff --git a/package.json b/package.json index 8b8a4cec5a..8c74e88b1c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rudder-transformer", - "version": "1.45.1", + "version": "1.45.2", "description": "", "homepage": "https://github.com/rudderlabs/rudder-transformer#readme", "bugs": { From c8d3882baccc57d7b892c55ff9811c951afb5ec6 Mon Sep 17 00:00:00 2001 From: srikanth Date: Tue, 17 Oct 2023 18:01:54 -0500 Subject: [PATCH 3/4] fix: ut metadata map ts type --- src/types/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/types/index.ts b/src/types/index.ts index 75b30a987a..5a35b697d6 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -52,9 +52,9 @@ type Metadata = { transformationId: string; }; -type MessageIdMetadataMap { +type MessageIdMetadataMap = { [key: string]: Metadata; -} +}; type UserTransformationInput = { VersionID: string; From 351401b55e45fbb5fcfd2e5021647ad030eba9dc Mon Sep 17 00:00:00 2001 From: srikanth Date: Tue, 17 Oct 2023 18:04:26 -0500 Subject: [PATCH 4/4] chore(release): 1.45.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 4156e90228..4ffec3a8d6 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.45.3](https://github.com/rudderlabs/rudder-transformer/compare/v1.45.2...v1.45.3) (2023-10-17) + + +### Bug Fixes + +* ut metadata map ts type ([c8d3882](https://github.com/rudderlabs/rudder-transformer/commit/c8d3882baccc57d7b892c55ff9811c951afb5ec6)) + ### [1.45.2](https://github.com/rudderlabs/rudder-transformer/compare/v1.45.1...v1.45.2) (2023-10-17) diff --git a/package-lock.json b/package-lock.json index 1f53db2cc6..b3d5eb7885 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rudder-transformer", - "version": "1.45.2", + "version": "1.45.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rudder-transformer", - "version": "1.45.2", + "version": "1.45.3", "license": "ISC", "dependencies": { "@amplitude/ua-parser-js": "^0.7.24", diff --git a/package.json b/package.json index 8c74e88b1c..1d45524515 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rudder-transformer", - "version": "1.45.2", + "version": "1.45.3", "description": "", "homepage": "https://github.com/rudderlabs/rudder-transformer#readme", "bugs": {