From d414064aac1c8d769607346bc48b8db549e7a8dc Mon Sep 17 00:00:00 2001 From: srikanth Date: Thu, 19 Oct 2023 11:24:38 -0500 Subject: [PATCH 1/2] fix: do not send 298 event for aborted ones in ut --- src/services/userTransform.ts | 12 ++-- ...r_transformation_service_filter_input.json | 62 +++++++++++++++++++ ..._transformation_service_filter_output.json | 9 +++ test/__tests__/user_transformation_ts.test.ts | 3 +- 4 files changed, 79 insertions(+), 7 deletions(-) diff --git a/src/services/userTransform.ts b/src/services/userTransform.ts index 5104418f6d..18165615a8 100644 --- a/src/services/userTransform.ts +++ b/src/services/userTransform.ts @@ -96,6 +96,12 @@ export default class UserTransformService { const transformedEventsWithMetadata: ProcessorTransformationResponse[] = []; destTransformedEvents.forEach((ev) => { + // add messageId to output set + if (ev.metadata?.messageId) { + messageIdsInOutputSet.add(ev.metadata.messageId); + } else if (ev.metadata?.messageIds) { + ev.metadata.messageIds.forEach((id) => messageIdsInOutputSet.add(id)); + } if (ev.error) { transformedEventsWithMetadata.push({ statusCode: 400, @@ -114,12 +120,6 @@ export default class UserTransformService { } as ProcessorTransformationResponse); return; } - // add messageId to output set - if (ev.metadata?.messageId) { - messageIdsInOutputSet.add(ev.metadata.messageId); - } else if (ev.metadata?.messageIds) { - ev.metadata.messageIds.forEach((id) => messageIdsInOutputSet.add(id)); - } transformedEventsWithMetadata.push({ output: ev.transformedEvent, metadata: isEmpty(ev.metadata) ? commonMetadata : ev.metadata, diff --git a/test/__tests__/data/user_transformation_service_filter_input.json b/test/__tests__/data/user_transformation_service_filter_input.json index 3b8425562d..966031e7bb 100644 --- a/test/__tests__/data/user_transformation_service_filter_input.json +++ b/test/__tests__/data/user_transformation_service_filter_input.json @@ -181,5 +181,67 @@ } ] } + }, + { + "message": { + "channel": "web", + "context": { + "app": { + "build": "1.0.0", + "name": "RudderLabs JavaScript SDK", + "namespace": "com.rudderlabs.javascript", + "version": "1.0.0" + }, + "traits": { + "email": "test@rudderstack.com", + "anonymousId": "12345" + }, + "library": { + "name": "RudderLabs JavaScript SDK", + "version": "1.0.0" + }, + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36", + "locale": "en-US", + "ip": "0.0.0.0", + "os": { + "name": "", + "version": "" + }, + "screen": { + "density": 2 + } + }, + "type": "non-standard", + "messageId": "ec5481b6-a926-4d2e-b293-0b3a77c4d3be", + "originalTimestamp": "2019-10-14T11:15:18.300Z", + "anonymousId": "00000000000000000000000000", + "userId": "12345", + "event": "test track event GA3", + "properties": { + "user_actual_role": "system_admin, system_user", + "user_actual_id": 12345 + }, + "integrations": { + "All": true + }, + "sentAt": "2019-10-14T11:15:53.296Z" + }, + "metadata": { + "messageId": "ec5481b6-a926-4d2e-b293-0b3a77c4d3be", + "sourceId": "s1", + "destinationId": "d1" + }, + "destination": { + "ID": 2, + "Config": { + "trackingID": "abcd" + }, + "Enabled": true, + "Transformations": [ + { + "VersionID": "24" + } + ] + } } ] diff --git a/test/__tests__/data/user_transformation_service_filter_output.json b/test/__tests__/data/user_transformation_service_filter_output.json index 64d8fd9261..2d2c03349e 100644 --- a/test/__tests__/data/user_transformation_service_filter_output.json +++ b/test/__tests__/data/user_transformation_service_filter_output.json @@ -68,6 +68,15 @@ "destinationId": "d1" }, "statusCode": 200 + }, + { + "error": "Error: non-standard event\n at transformEvent (base transformation:5:56)", + "metadata": { + "destinationId": "d1", + "messageId": "ec5481b6-a926-4d2e-b293-0b3a77c4d3be", + "sourceId": "s1" + }, + "statusCode": 400 } ], "retryStatus": 200 diff --git a/test/__tests__/user_transformation_ts.test.ts b/test/__tests__/user_transformation_ts.test.ts index 954582f212..418c42fe33 100644 --- a/test/__tests__/user_transformation_ts.test.ts +++ b/test/__tests__/user_transformation_ts.test.ts @@ -8,7 +8,7 @@ const name = 'User Transformations'; const randomID = () => Math.random().toString(36).substring(2, 15); describe('User Transform Service', () => { - fit(`Filtering ${name} Test`, async () => { + it(`Filtering ${name} Test`, async () => { const versionId = '24'; // set in input file const inputData = require(`./data/${integration}_filter_input.json`); const expectedData = require(`./data/${integration}_filter_output.json`); @@ -21,6 +21,7 @@ describe('User Transform Service', () => { const eventType = event.type; log(eventType); log(eventType.match(/track/g)); + if(eventType === 'non-standard') throw new Error('non-standard event'); if(eventType && !eventType.match(/track/g)) return; return event; } From 77e910e92649dc3bae4b47b0edadf3c196b7fd13 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Thu, 19 Oct 2023 16:30:23 +0000 Subject: [PATCH 2/2] chore(release): 1.46.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 1a520c5b6f..92d9a8e214 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.2](https://github.com/rudderlabs/rudder-transformer/compare/v1.46.1...v1.46.2) (2023-10-19) + + +### Bug Fixes + +* do not send 298 event for aborted ones in ut ([d414064](https://github.com/rudderlabs/rudder-transformer/commit/d414064aac1c8d769607346bc48b8db549e7a8dc)) + ### [1.46.1](https://github.com/rudderlabs/rudder-transformer/compare/v1.46.0...v1.46.1) (2023-10-19) ### Bug Fixes diff --git a/package-lock.json b/package-lock.json index 322e3dbca0..24872e2233 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rudder-transformer", - "version": "1.46.1", + "version": "1.46.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rudder-transformer", - "version": "1.46.1", + "version": "1.46.2", "license": "ISC", "dependencies": { "@amplitude/ua-parser-js": "^0.7.24", diff --git a/package.json b/package.json index 880acda150..011cd96751 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rudder-transformer", - "version": "1.46.1", + "version": "1.46.2", "description": "", "homepage": "https://github.com/rudderlabs/rudder-transformer#readme", "bugs": {