Skip to content

Commit

Permalink
feat: update movable ink batch size
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauravudia committed Apr 1, 2024
1 parent 81290e8 commit 2bd91e3
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/cdk/v2/destinations/movable_ink/config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
module.exports = {
MAX_REQUEST_SIZE_IN_BYTES: 13500,
MAX_REQUEST_SIZE_IN_BYTES: 1000000,
MAX_BATCH_SIZE: 1000,
};
1 change: 1 addition & 0 deletions src/cdk/v2/destinations/movable_ink/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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")}}}};
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/v2/destinations/movable_ink/rtWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
6 changes: 6 additions & 0 deletions test/integrations/destinations/movable_ink/mocks.ts
Original file line number Diff line number Diff line change
@@ -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);
};
Original file line number Diff line number Diff line change
@@ -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[] = [
{
Expand Down
6 changes: 6 additions & 0 deletions test/integrations/destinations/movable_ink/processor/track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const track: ProcessorTestData[] = [
channel,
anonymousId: 'anonId123',
userId: 'userId123',
event: 'Product Added',
properties: trackTestProperties['Product Added'],
integrations: {
All: true,
Expand All @@ -49,6 +50,7 @@ export const track: ProcessorTestData[] = [
channel,
userId: 'userId123',
anonymousId: 'anonId123',
event: 'Product Added',
properties: trackTestProperties['Product Added'],
integrations: {
All: true,
Expand Down Expand Up @@ -84,6 +86,7 @@ export const track: ProcessorTestData[] = [
channel,
anonymousId: 'anonId123',
userId: 'userId123',
event: 'Order Completed',
properties: trackTestProperties['Order Completed'],
integrations: {
All: true,
Expand All @@ -110,6 +113,7 @@ export const track: ProcessorTestData[] = [
channel,
userId: 'userId123',
anonymousId: 'anonId123',
event: 'Order Completed',
properties: trackTestProperties['Order Completed'],
integrations: {
All: true,
Expand Down Expand Up @@ -145,6 +149,7 @@ export const track: ProcessorTestData[] = [
channel,
anonymousId: 'anonId123',
userId: 'userId123',
event: 'Custom Event',
properties: trackTestProperties['Custom Event'],
integrations: {
All: true,
Expand All @@ -171,6 +176,7 @@ export const track: ProcessorTestData[] = [
channel,
userId: 'userId123',
anonymousId: 'anonId123',
event: 'Custom Event',
properties: trackTestProperties['Custom Event'],
integrations: {
All: true,
Expand Down
44 changes: 44 additions & 0 deletions test/integrations/destinations/movable_ink/processor/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
],
},
},
},
];
62 changes: 59 additions & 3 deletions test/integrations/destinations/movable_ink/router/data.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { RouterTestData } from '../../../testTypes';
import { RouterTransformationRequest } from '../../../../../src/types';
import { generateMetadata } from '../../../testUtils';
import { defaultMockFns } from '../mocks';
import {
destType,
channel,
Expand Down Expand Up @@ -43,6 +44,7 @@ const routerRequest: RouterTransformationRequest = {
channel,
anonymousId: 'anonId123',
userId: 'userId123',
event: 'Product Added',
properties: trackTestProperties['Product Added'],
integrations: {
All: true,
Expand All @@ -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,
Expand Down Expand Up @@ -118,6 +136,7 @@ export const data: RouterTestData[] = [
channel,
userId: 'userId123',
anonymousId: 'anonId123',
event: 'Product Added',
properties: trackTestProperties['Product Added'],
integrations: {
All: true,
Expand All @@ -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,
Expand All @@ -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',
Expand All @@ -158,5 +213,6 @@ export const data: RouterTestData[] = [
},
},
},
mockFns: defaultMockFns,
},
];

0 comments on commit 2bd91e3

Please sign in to comment.