From 2bd91e366127be02e00ae7ebf1290453fc097d38 Mon Sep 17 00:00:00 2001 From: Gauravudia Date: Mon, 1 Apr 2024 12:29:24 +0530 Subject: [PATCH] feat: update movable ink batch size --- src/cdk/v2/destinations/movable_ink/config.js | 3 +- .../movable_ink/procWorkflow.yaml | 1 + .../destinations/movable_ink/rtWorkflow.yaml | 2 +- .../destinations/movable_ink/mocks.ts | 6 ++ .../movable_ink/processor/identify.ts | 2 +- .../movable_ink/processor/track.ts | 6 ++ .../movable_ink/processor/validation.ts | 44 +++++++++++++ .../destinations/movable_ink/router/data.ts | 62 ++++++++++++++++++- 8 files changed, 120 insertions(+), 6 deletions(-) create mode 100644 test/integrations/destinations/movable_ink/mocks.ts diff --git a/src/cdk/v2/destinations/movable_ink/config.js b/src/cdk/v2/destinations/movable_ink/config.js index 673e94620e..9a0200ab44 100644 --- a/src/cdk/v2/destinations/movable_ink/config.js +++ b/src/cdk/v2/destinations/movable_ink/config.js @@ -1,3 +1,4 @@ module.exports = { - MAX_REQUEST_SIZE_IN_BYTES: 13500, + MAX_REQUEST_SIZE_IN_BYTES: 1000000, + MAX_BATCH_SIZE: 1000, }; diff --git a/src/cdk/v2/destinations/movable_ink/procWorkflow.yaml b/src/cdk/v2/destinations/movable_ink/procWorkflow.yaml index 43dbb3cbce..394190049b 100644 --- a/src/cdk/v2/destinations/movable_ink/procWorkflow.yaml +++ b/src/cdk/v2/destinations/movable_ink/procWorkflow.yaml @@ -24,6 +24,7 @@ steps: $.assertConfig(.destination.Config.accessKey, "Access key is not present . Aborting"); $.assertConfig(.destination.Config.accessSecret, "Access Secret is not present. Aborting"); $.assert(.message.timestamp ?? .message.originalTimestamp, "Timestamp is not present. Aborting"); + $.assert(!(messageType === {{$.EventType.TRACK}} && !(.message.event)), "Event name is not present. Aborting"); const userId = .message.().( {{{{$.getGenericPaths("userIdOnly")}}}}; diff --git a/src/cdk/v2/destinations/movable_ink/rtWorkflow.yaml b/src/cdk/v2/destinations/movable_ink/rtWorkflow.yaml index 46afb34d53..3ffa49f15b 100644 --- a/src/cdk/v2/destinations/movable_ink/rtWorkflow.yaml +++ b/src/cdk/v2/destinations/movable_ink/rtWorkflow.yaml @@ -42,7 +42,7 @@ steps: description: Batches the successfulEvents template: | let batches = $.BatchUtils.chunkArrayBySizeAndLength( - $.outputs.successfulEvents, {maxSizeInBytes: $.MAX_REQUEST_SIZE_IN_BYTES}).items; + $.outputs.successfulEvents, {maxSizeInBytes: $.MAX_REQUEST_SIZE_IN_BYTES, maxItems: $.MAX_BATCH_SIZE}).items; batches@batch.({ "batchedRequest": { diff --git a/test/integrations/destinations/movable_ink/mocks.ts b/test/integrations/destinations/movable_ink/mocks.ts new file mode 100644 index 0000000000..2468f51315 --- /dev/null +++ b/test/integrations/destinations/movable_ink/mocks.ts @@ -0,0 +1,6 @@ +import config from '../../../../src/cdk/v2/destinations/movable_ink/config'; + +export const defaultMockFns = () => { + jest.replaceProperty(config, 'MAX_REQUEST_SIZE_IN_BYTES', 5000); + jest.replaceProperty(config, 'MAX_BATCH_SIZE', 2); +}; diff --git a/test/integrations/destinations/movable_ink/processor/identify.ts b/test/integrations/destinations/movable_ink/processor/identify.ts index 27186da05c..e5bbf5a9a7 100644 --- a/test/integrations/destinations/movable_ink/processor/identify.ts +++ b/test/integrations/destinations/movable_ink/processor/identify.ts @@ -1,6 +1,6 @@ import { ProcessorTestData } from '../../../testTypes'; import { generateMetadata, transformResultBuilder } from '../../../testUtils'; -import { destType, channel, destination, traits, headers } from '../common'; +import { destType, destination, traits, headers } from '../common'; export const identify: ProcessorTestData[] = [ { diff --git a/test/integrations/destinations/movable_ink/processor/track.ts b/test/integrations/destinations/movable_ink/processor/track.ts index 5f30a3de83..890de11a0c 100644 --- a/test/integrations/destinations/movable_ink/processor/track.ts +++ b/test/integrations/destinations/movable_ink/processor/track.ts @@ -23,6 +23,7 @@ export const track: ProcessorTestData[] = [ channel, anonymousId: 'anonId123', userId: 'userId123', + event: 'Product Added', properties: trackTestProperties['Product Added'], integrations: { All: true, @@ -49,6 +50,7 @@ export const track: ProcessorTestData[] = [ channel, userId: 'userId123', anonymousId: 'anonId123', + event: 'Product Added', properties: trackTestProperties['Product Added'], integrations: { All: true, @@ -84,6 +86,7 @@ export const track: ProcessorTestData[] = [ channel, anonymousId: 'anonId123', userId: 'userId123', + event: 'Order Completed', properties: trackTestProperties['Order Completed'], integrations: { All: true, @@ -110,6 +113,7 @@ export const track: ProcessorTestData[] = [ channel, userId: 'userId123', anonymousId: 'anonId123', + event: 'Order Completed', properties: trackTestProperties['Order Completed'], integrations: { All: true, @@ -145,6 +149,7 @@ export const track: ProcessorTestData[] = [ channel, anonymousId: 'anonId123', userId: 'userId123', + event: 'Custom Event', properties: trackTestProperties['Custom Event'], integrations: { All: true, @@ -171,6 +176,7 @@ export const track: ProcessorTestData[] = [ channel, userId: 'userId123', anonymousId: 'anonId123', + event: 'Custom Event', properties: trackTestProperties['Custom Event'], integrations: { All: true, diff --git a/test/integrations/destinations/movable_ink/processor/validation.ts b/test/integrations/destinations/movable_ink/processor/validation.ts index ab6b123eb7..6aafb5e2c0 100644 --- a/test/integrations/destinations/movable_ink/processor/validation.ts +++ b/test/integrations/destinations/movable_ink/processor/validation.ts @@ -214,4 +214,48 @@ export const validation: ProcessorTestData[] = [ }, }, }, + { + id: 'MovableInk-validation-test-6', + name: destType, + description: 'Missing event name', + scenario: 'Framework', + successCriteria: 'Instrumentation Error', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: { + type: 'track', + anonymousId: 'anonId123', + userId: 'userId123', + properties: {}, + integrations: { + All: true, + }, + originalTimestamp: '2024-03-04T15:32:56.409Z', + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'Event name is not present. Aborting: Workflow: procWorkflow, Step: validateInput, ChildStep: undefined, OriginalError: Event name is not present. Aborting', + metadata: generateMetadata(1), + statTags: processorInstrumentationErrorStatTags, + statusCode: 400, + }, + ], + }, + }, + }, ]; diff --git a/test/integrations/destinations/movable_ink/router/data.ts b/test/integrations/destinations/movable_ink/router/data.ts index 72df3d7074..5a73d991ae 100644 --- a/test/integrations/destinations/movable_ink/router/data.ts +++ b/test/integrations/destinations/movable_ink/router/data.ts @@ -1,6 +1,7 @@ import { RouterTestData } from '../../../testTypes'; import { RouterTransformationRequest } from '../../../../../src/types'; import { generateMetadata } from '../../../testUtils'; +import { defaultMockFns } from '../mocks'; import { destType, channel, @@ -43,6 +44,7 @@ const routerRequest: RouterTransformationRequest = { channel, anonymousId: 'anonId123', userId: 'userId123', + event: 'Product Added', properties: trackTestProperties['Product Added'], integrations: { All: true, @@ -58,19 +60,35 @@ const routerRequest: RouterTransformationRequest = { channel, anonymousId: 'anonId123', userId: 'userId123', - properties: trackTestProperties['Custom Event'], + event: 'Custom Event', integrations: { All: true, }, + originalTimestamp: '2024-03-04T15:32:56.409Z', }, metadata: generateMetadata(4), destination, }, + { + message: { + type: 'track', + channel, + anonymousId: 'anonId123', + userId: 'userId123', + event: 'Custom Event', + properties: trackTestProperties['Custom Event'], + integrations: { + All: true, + }, + }, + metadata: generateMetadata(5), + destination, + }, ], destType, }; -export const data: RouterTestData[] = [ +export const data = [ { id: 'MovableInk-router-test-1', name: destType, @@ -118,6 +136,7 @@ export const data: RouterTestData[] = [ channel, userId: 'userId123', anonymousId: 'anonId123', + event: 'Product Added', properties: trackTestProperties['Product Added'], integrations: { All: true, @@ -138,6 +157,42 @@ export const data: RouterTestData[] = [ statusCode: 200, destination, }, + { + batchedRequest: { + version: '1', + type: 'REST', + method: 'POST', + endpoint: destination.Config.endpoint, + headers, + params: {}, + body: { + JSON: { + events: [ + { + type: 'track', + channel, + userId: 'userId123', + anonymousId: 'anonId123', + event: 'Custom Event', + integrations: { + All: true, + }, + originalTimestamp: '2024-03-04T15:32:56.409Z', + timestamp: 1709566376409, + }, + ], + }, + JSON_ARRAY: {}, + XML: {}, + FORM: {}, + }, + files: {}, + }, + metadata: [generateMetadata(4)], + batched: true, + statusCode: 200, + destination, + }, { metadata: [generateMetadata(2)], batched: false, @@ -147,7 +202,7 @@ export const data: RouterTestData[] = [ destination, }, { - metadata: [generateMetadata(4)], + metadata: [generateMetadata(5)], batched: false, statusCode: 400, error: 'Timestamp is not present. Aborting', @@ -158,5 +213,6 @@ export const data: RouterTestData[] = [ }, }, }, + mockFns: defaultMockFns, }, ];