diff --git a/test/controllerUtility/ctrl-utility.test.ts b/test/controllerUtility/ctrl-utility.test.ts index bf9eef1846..6cff7edf6b 100644 --- a/test/controllerUtility/ctrl-utility.test.ts +++ b/test/controllerUtility/ctrl-utility.test.ts @@ -1,5 +1,11 @@ -import { ProcessorTransformationRequest, RouterTransformationRequestData } from '../../src/types'; +import { + Destination, + Metadata, + ProcessorTransformationRequest, + RouterTransformationRequestData, +} from '../../src/types'; import { ControllerUtility } from '../../src/controllers/util'; +import lodash from 'lodash'; type timestampTestCases = { caseName: string; @@ -7,135 +13,102 @@ type timestampTestCases = { inputEvents: Array; }; +const metadata: Metadata = { + sourceId: '27O0bmEEx3GgfmEhZHUcPwJQVWC', + workspaceId: '27O0bhB6p5ehfOWeeZlOSsSDTLg', + namespace: '', + instanceId: '1', + sourceType: 'HTTP', + sourceCategory: '', + trackingPlanId: '', + trackingPlanVersion: 0, + sourceTpConfig: {}, + mergedTpConfig: {}, + destinationId: '2JH9GMQf2YFJFaTw7rz1pxHAJPx', + jobRunId: '', + jobId: 1, + sourceBatchId: '', + sourceJobId: '', + sourceJobRunId: '', + sourceTaskId: '', + sourceTaskRunId: '', + recordId: {}, + destinationType: 'WEBHOOK', + messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', + oauthAccessToken: '', + messageIds: [], + rudderId: '<<>>2073230<<>>2564871', + receivedAt: '2022-12-23T00:29:10.189+05:30', + eventName: 'Test', + eventType: 'track', + sourceDefinitionId: '1b6gJdqOPOCadT3cddw8eidV591', + destinationDefinitionId: '', + transformationId: '', +}; + +const destination: Destination = { + ID: 'string', + Name: 'string', + DestinationDefinition: { + ID: 'defid1', + Name: 'INTERCOM', + DisplayName: 'intercom', + Config: {}, + }, + Config: {}, + Enabled: true, + WorkspaceID: 'wspId', + Transformations: [], +}; + +const message = { + anonymousId: '2073230', + event: 'Test', + messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', + originalTimestamp: '2022-12-23T00:29:12.117+05:30', + channel: 'sources', + properties: { + timestamp: '2023-01-23T00:29:12.117+05:30', + }, + sentAt: '2022-12-23T00:29:12.117+05:30', + timestamp: '2023-01-23T00:29:12.117+05:30', + type: 'track', + userId: '2564871', +}; + +function getMetadata(overrides: Metadata): Metadata { + return lodash.merge({}, metadata, overrides); +} + +function getDestination(overrides: Destination): Destination { + return lodash.merge({}, destination, overrides); +} + +function getMessage(overrides: object): object { + return lodash.merge({}, message, overrides); +} + +function getMessageWithShallowMerge(overrides: object): object { + return lodash.assign({}, message, overrides); +} + const timestampEventsCases: timestampTestCases[] = [ { caseName: 'when events(all track), timestamp should be taken from properties.timestamp', expectedOutputEvents: [ { - message: { - anonymousId: '2073230', - event: 'Test', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - originalTimestamp: '2022-12-23T00:29:12.117+05:30', - channel: 'sources', - properties: { - timestamp: '2023-01-23T00:29:12.117+05:30', - }, - sentAt: '2022-12-23T00:29:12.117+05:30', - timestamp: '2023-01-23T00:29:12.117+05:30', - type: 'track', - userId: '2564871', - }, - metadata: { - sourceId: '27O0bmEEx3GgfmEhZHUcPwJQVWC', - workspaceId: '27O0bhB6p5ehfOWeeZlOSsSDTLg', - namespace: '', - instanceId: '1', - sourceType: 'HTTP', - sourceCategory: '', - trackingPlanId: '', - trackingPlanVersion: 0, - sourceTpConfig: {}, - mergedTpConfig: {}, - destinationId: '2JH9GMQf2YFJFaTw7rz1pxHAJPx', - jobRunId: '', - jobId: 1, - sourceBatchId: '', - sourceJobId: '', - sourceJobRunId: '', - sourceTaskId: '', - sourceTaskRunId: '', - recordId: {}, - destinationType: 'WEBHOOK', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - oauthAccessToken: '', - messageIds: [], - rudderId: '<<>>2073230<<>>2564871', - receivedAt: '2022-12-23T00:29:10.189+05:30', - eventName: 'Test', - eventType: 'track', - sourceDefinitionId: '1b6gJdqOPOCadT3cddw8eidV591', - destinationDefinitionId: '', - transformationId: '', - }, - destination: { - ID: 'string', - Name: 'string', - DestinationDefinition: { - ID: 'defid1', - Name: 'INTERCOM', - DisplayName: 'intercom', - Config: {}, - }, - Config: {}, - Enabled: true, - WorkspaceID: 'wspId', - Transformations: [], - }, + message: message, + metadata: metadata, + destination: destination, }, ], inputEvents: [ { - message: { - anonymousId: '2073230', - event: 'Test', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - originalTimestamp: '2022-12-23T00:29:12.117+05:30', - channel: 'sources', - properties: { - timestamp: '2023-01-23T00:29:12.117+05:30', - }, - sentAt: '2022-12-23T00:29:12.117+05:30', + message: getMessage({ timestamp: '2022-12-23T00:29:10.188+05:30', - type: 'track', - userId: '2564871', - }, - metadata: { - sourceId: '27O0bmEEx3GgfmEhZHUcPwJQVWC', - workspaceId: '27O0bhB6p5ehfOWeeZlOSsSDTLg', - namespace: '', - instanceId: '1', - sourceType: 'HTTP', - sourceCategory: '', - trackingPlanId: '', - trackingPlanVersion: 0, - sourceTpConfig: {}, - mergedTpConfig: {}, - destinationId: '2JH9GMQf2YFJFaTw7rz1pxHAJPx', - jobRunId: '', - jobId: 1, - sourceBatchId: '', - sourceJobId: '', - sourceJobRunId: '', - sourceTaskId: '', - sourceTaskRunId: '', - recordId: {}, - destinationType: 'WEBHOOK', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - oauthAccessToken: '', - messageIds: [], - rudderId: '<<>>2073230<<>>2564871', - receivedAt: '2022-12-23T00:29:10.189+05:30', - eventName: 'Test', - eventType: 'track', - sourceDefinitionId: '1b6gJdqOPOCadT3cddw8eidV591', - destinationDefinitionId: '', - transformationId: '', - }, - destination: { - ID: 'string', - Name: 'string', - DestinationDefinition: { - ID: 'defid1', - Name: 'INTERCOM', - DisplayName: 'intercom', - Config: {}, - }, - Config: {}, - Enabled: true, - WorkspaceID: 'wspId', - Transformations: [], - }, + }), + metadata: metadata, + destination: destination, }, ], }, @@ -144,130 +117,26 @@ const timestampEventsCases: timestampTestCases[] = [ 'when events(all track) without properties.timestamp, timestamp should be taken from timestamp', expectedOutputEvents: [ { - message: { - anonymousId: '2073230', - event: 'Test', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - originalTimestamp: '2022-12-23T00:29:12.117+05:30', - channel: 'sources', + message: getMessageWithShallowMerge({ properties: { someTime: '2023-01-23T00:29:12.117+05:30', }, - sentAt: '2022-12-23T00:29:12.117+05:30', timestamp: '2022-11-22T00:29:10.188+05:30', - type: 'track', - userId: '2564871', - }, - metadata: { - sourceId: '27O0bmEEx3GgfmEhZHUcPwJQVWC', - workspaceId: '27O0bhB6p5ehfOWeeZlOSsSDTLg', - namespace: '', - instanceId: '1', - sourceType: 'HTTP', - sourceCategory: '', - trackingPlanId: '', - trackingPlanVersion: 0, - sourceTpConfig: {}, - mergedTpConfig: {}, - destinationId: '2JH9GMQf2YFJFaTw7rz1pxHAJPx', - jobRunId: '', - jobId: 1, - sourceBatchId: '', - sourceJobId: '', - sourceJobRunId: '', - sourceTaskId: '', - sourceTaskRunId: '', - recordId: {}, - destinationType: 'WEBHOOK', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - oauthAccessToken: '', - messageIds: [], - rudderId: '<<>>2073230<<>>2564871', - receivedAt: '2022-12-23T00:29:10.189+05:30', - eventName: 'Test', - eventType: 'track', - sourceDefinitionId: '1b6gJdqOPOCadT3cddw8eidV591', - destinationDefinitionId: '', - transformationId: '', - }, - destination: { - ID: 'string', - Name: 'string', - DestinationDefinition: { - ID: 'defid1', - Name: 'INTERCOM', - DisplayName: 'intercom', - Config: {}, - }, - Config: {}, - Enabled: true, - WorkspaceID: 'wspId', - Transformations: [], - }, + }), + metadata: metadata, + destination: destination, }, ], inputEvents: [ { - message: { - anonymousId: '2073230', - event: 'Test', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - originalTimestamp: '2022-12-23T00:29:12.117+05:30', - channel: 'sources', + message: getMessageWithShallowMerge({ properties: { someTime: '2023-01-23T00:29:12.117+05:30', }, - sentAt: '2022-12-23T00:29:12.117+05:30', timestamp: '2022-11-22T00:29:10.188+05:30', - type: 'track', - userId: '2564871', - }, - metadata: { - sourceId: '27O0bmEEx3GgfmEhZHUcPwJQVWC', - workspaceId: '27O0bhB6p5ehfOWeeZlOSsSDTLg', - namespace: '', - instanceId: '1', - sourceType: 'HTTP', - sourceCategory: '', - trackingPlanId: '', - trackingPlanVersion: 0, - sourceTpConfig: {}, - mergedTpConfig: {}, - destinationId: '2JH9GMQf2YFJFaTw7rz1pxHAJPx', - jobRunId: '', - jobId: 1, - sourceBatchId: '', - sourceJobId: '', - sourceJobRunId: '', - sourceTaskId: '', - sourceTaskRunId: '', - recordId: {}, - destinationType: 'WEBHOOK', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - oauthAccessToken: '', - messageIds: [], - rudderId: '<<>>2073230<<>>2564871', - receivedAt: '2022-12-23T00:29:10.189+05:30', - eventName: 'Test', - eventType: 'track', - sourceDefinitionId: '1b6gJdqOPOCadT3cddw8eidV591', - destinationDefinitionId: '', - transformationId: '', - }, - destination: { - ID: 'string', - Name: 'string', - DestinationDefinition: { - ID: 'defid1', - Name: 'INTERCOM', - DisplayName: 'intercom', - Config: {}, - }, - Config: {}, - Enabled: true, - WorkspaceID: 'wspId', - Transformations: [], - }, + }), + metadata: metadata, + destination: destination, }, ], }, @@ -276,130 +145,28 @@ const timestampEventsCases: timestampTestCases[] = [ 'when events(all identify) without context.timestamp, timestamp should be taken from timestamp', expectedOutputEvents: [ { - message: { - anonymousId: '2073230', - event: 'Test', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - originalTimestamp: '2022-12-23T00:29:12.117+05:30', - channel: 'sources', + message: getMessage({ context: { timestamp: '2023-01-12T00:29:12.117+05:30', }, - sentAt: '2022-12-23T00:29:12.117+05:30', timestamp: '2023-01-12T00:29:12.117+05:30', type: 'identify', - userId: '2564871', - }, - metadata: { - sourceId: '27O0bmEEx3GgfmEhZHUcPwJQVWC', - workspaceId: '27O0bhB6p5ehfOWeeZlOSsSDTLg', - namespace: '', - instanceId: '1', - sourceType: 'HTTP', - sourceCategory: '', - trackingPlanId: '', - trackingPlanVersion: 0, - sourceTpConfig: {}, - mergedTpConfig: {}, - destinationId: '2JH9GMQf2YFJFaTw7rz1pxHAJPx', - jobRunId: '', - jobId: 1, - sourceBatchId: '', - sourceJobId: '', - sourceJobRunId: '', - sourceTaskId: '', - sourceTaskRunId: '', - recordId: {}, - destinationType: 'WEBHOOK', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - oauthAccessToken: '', - messageIds: [], - rudderId: '<<>>2073230<<>>2564871', - receivedAt: '2022-12-23T00:29:10.189+05:30', - eventName: 'Test', - eventType: 'track', - sourceDefinitionId: '1b6gJdqOPOCadT3cddw8eidV591', - destinationDefinitionId: '', - transformationId: '', - }, - destination: { - ID: 'string', - Name: 'string', - DestinationDefinition: { - ID: 'defid1', - Name: 'INTERCOM', - DisplayName: 'intercom', - Config: {}, - }, - Config: {}, - Enabled: true, - WorkspaceID: 'wspId', - Transformations: [], - }, + }), + metadata: metadata, + destination: destination, }, ], inputEvents: [ { - message: { - anonymousId: '2073230', - event: 'Test', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - originalTimestamp: '2022-12-23T00:29:12.117+05:30', - channel: 'sources', + message: getMessage({ context: { timestamp: '2023-01-12T00:29:12.117+05:30', }, - sentAt: '2022-12-23T00:29:12.117+05:30', timestamp: '2022-11-22T00:29:10.188+05:30', type: 'identify', - userId: '2564871', - }, - metadata: { - sourceId: '27O0bmEEx3GgfmEhZHUcPwJQVWC', - workspaceId: '27O0bhB6p5ehfOWeeZlOSsSDTLg', - namespace: '', - instanceId: '1', - sourceType: 'HTTP', - sourceCategory: '', - trackingPlanId: '', - trackingPlanVersion: 0, - sourceTpConfig: {}, - mergedTpConfig: {}, - destinationId: '2JH9GMQf2YFJFaTw7rz1pxHAJPx', - jobRunId: '', - jobId: 1, - sourceBatchId: '', - sourceJobId: '', - sourceJobRunId: '', - sourceTaskId: '', - sourceTaskRunId: '', - recordId: {}, - destinationType: 'WEBHOOK', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - oauthAccessToken: '', - messageIds: [], - rudderId: '<<>>2073230<<>>2564871', - receivedAt: '2022-12-23T00:29:10.189+05:30', - eventName: 'Test', - eventType: 'track', - sourceDefinitionId: '1b6gJdqOPOCadT3cddw8eidV591', - destinationDefinitionId: '', - transformationId: '', - }, - destination: { - ID: 'string', - Name: 'string', - DestinationDefinition: { - ID: 'defid1', - Name: 'INTERCOM', - DisplayName: 'intercom', - Config: {}, - }, - Config: {}, - Enabled: true, - WorkspaceID: 'wspId', - Transformations: [], - }, + }), + metadata: metadata, + destination: destination, }, ], }, @@ -408,506 +175,102 @@ const timestampEventsCases: timestampTestCases[] = [ 'when proc events(identify, track, group) are mixed, timestamp should be taken from relevant places for identify & track, skipped for group', expectedOutputEvents: [ { - message: { - anonymousId: '2073230', - event: 'Test', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - originalTimestamp: '2022-12-23T00:29:12.117+05:30', - channel: 'sources', + message: getMessage({ context: { traits: { timestamp: '2023-01-22T00:29:12.117+05:30', }, }, - sentAt: '2022-12-23T00:29:12.117+05:30', timestamp: '2023-01-22T00:29:12.117+05:30', type: 'identify', - userId: '2564871', - }, - metadata: { - sourceId: '27O0bmEEx3GgfmEhZHUcPwJQVWC', - workspaceId: '27O0bhB6p5ehfOWeeZlOSsSDTLg', - namespace: '', - instanceId: '1', - sourceType: 'HTTP', - sourceCategory: '', - trackingPlanId: '', - trackingPlanVersion: 0, - sourceTpConfig: {}, - mergedTpConfig: {}, - destinationId: '2JH9GMQf2YFJFaTw7rz1pxHAJPx', - jobRunId: '', - jobId: 1, - sourceBatchId: '', - sourceJobId: '', - sourceJobRunId: '', - sourceTaskId: '', - sourceTaskRunId: '', - recordId: {}, - destinationType: 'WEBHOOK', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - oauthAccessToken: '', - messageIds: [], - rudderId: '<<>>2073230<<>>2564871', - receivedAt: '2022-12-23T00:29:10.189+05:30', - eventName: 'Test', - eventType: 'track', - sourceDefinitionId: '1b6gJdqOPOCadT3cddw8eidV591', - destinationDefinitionId: '', - transformationId: '', - }, - destination: { - ID: 'string', - Name: 'string', - DestinationDefinition: { - ID: 'defid1', - Name: 'INTERCOM', - DisplayName: 'intercom', - Config: {}, - }, - Config: {}, - Enabled: true, - WorkspaceID: 'wspId', - Transformations: [], - }, + }), + metadata: metadata, + destination: destination, }, { - message: { + message: getMessage({ anonymousId: '2073231', - event: 'Test', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - originalTimestamp: '2022-12-23T00:29:12.117+05:30', - channel: 'sources', traits: { timestamp: '2023-01-11T00:29:12.117+05:30', }, - sentAt: '2022-12-23T00:29:12.117+05:30', timestamp: '2023-01-11T00:29:12.117+05:30', type: 'identify', - userId: '2564871', - }, - metadata: { - sourceId: '27O0bmEEx3GgfmEhZHUcPwJQVWC', - workspaceId: '27O0bhB6p5ehfOWeeZlOSsSDTLg', - namespace: '', - instanceId: '1', - sourceType: 'HTTP', - sourceCategory: '', - trackingPlanId: '', - trackingPlanVersion: 0, - sourceTpConfig: {}, - mergedTpConfig: {}, - destinationId: '2JH9GMQf2YFJFaTw7rz1pxHAJPx', - jobRunId: '', - jobId: 1, - sourceBatchId: '', - sourceJobId: '', - sourceJobRunId: '', - sourceTaskId: '', - sourceTaskRunId: '', - recordId: {}, - destinationType: 'WEBHOOK', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - oauthAccessToken: '', - messageIds: [], - rudderId: '<<>>2073230<<>>2564871', - receivedAt: '2022-12-23T00:29:10.189+05:30', - eventName: 'Test', - eventType: 'track', - sourceDefinitionId: '1b6gJdqOPOCadT3cddw8eidV591', - destinationDefinitionId: '', - transformationId: '', - }, - destination: { - ID: 'string', - Name: 'string', - DestinationDefinition: { - ID: 'defid1', - Name: 'INTERCOM', - DisplayName: 'intercom', - Config: {}, - }, - Config: {}, - Enabled: true, - WorkspaceID: 'wspId', - Transformations: [], - }, + }), + metadata: metadata, + destination: destination, }, { - message: { + message: getMessage({ anonymousId: '2073232', - event: 'Test', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - originalTimestamp: '2022-12-23T00:29:12.117+05:30', - channel: 'sources', properties: { timestamp: '2023-01-13T00:29:12.117+05:30', }, - sentAt: '2022-12-23T00:29:12.117+05:30', timestamp: '2023-01-13T00:29:12.117+05:30', - type: 'track', - userId: '2564871', - }, - metadata: { - sourceId: '27O0bmEEx3GgfmEhZHUcPwJQVWC', - workspaceId: '27O0bhB6p5ehfOWeeZlOSsSDTLg', - namespace: '', - instanceId: '1', - sourceType: 'HTTP', - sourceCategory: '', - trackingPlanId: '', - trackingPlanVersion: 0, - sourceTpConfig: {}, - mergedTpConfig: {}, - destinationId: '2JH9GMQf2YFJFaTw7rz1pxHAJPx', - jobRunId: '', - jobId: 1, - sourceBatchId: '', - sourceJobId: '', - sourceJobRunId: '', - sourceTaskId: '', - sourceTaskRunId: '', - recordId: {}, - destinationType: 'WEBHOOK', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - oauthAccessToken: '', - messageIds: [], - rudderId: '<<>>2073230<<>>2564871', - receivedAt: '2022-12-23T00:29:10.189+05:30', - eventName: 'Test', - eventType: 'track', - sourceDefinitionId: '1b6gJdqOPOCadT3cddw8eidV591', - destinationDefinitionId: '', - transformationId: '', - }, - destination: { - ID: 'string', - Name: 'string', - DestinationDefinition: { - ID: 'defid1', - Name: 'INTERCOM', - DisplayName: 'intercom', - Config: {}, - }, - Config: {}, - Enabled: true, - WorkspaceID: 'wspId', - Transformations: [], - }, + }), + metadata: metadata, + destination: destination, }, { - message: { + message: getMessage({ anonymousId: '2073232', - event: 'Test', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - originalTimestamp: '2022-12-23T00:29:12.117+05:30', - channel: 'sources', properties: { timestamp: '2023-01-13T00:29:12.117+05:30', }, - sentAt: '2022-12-23T00:29:12.117+05:30', timestamp: '2022-11-22T00:29:10.188+05:30', type: 'group', - userId: '2564871', - }, - metadata: { - sourceId: '27O0bmEEx3GgfmEhZHUcPwJQVWC', - workspaceId: '27O0bhB6p5ehfOWeeZlOSsSDTLg', - namespace: '', - instanceId: '1', - sourceType: 'HTTP', - sourceCategory: '', - trackingPlanId: '', - trackingPlanVersion: 0, - sourceTpConfig: {}, - mergedTpConfig: {}, - destinationId: '2JH9GMQf2YFJFaTw7rz1pxHAJPx', - jobRunId: '', - jobId: 1, - sourceBatchId: '', - sourceJobId: '', - sourceJobRunId: '', - sourceTaskId: '', - sourceTaskRunId: '', - recordId: {}, - destinationType: 'WEBHOOK', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - oauthAccessToken: '', - messageIds: [], - rudderId: '<<>>2073230<<>>2564871', - receivedAt: '2022-12-23T00:29:10.189+05:30', - eventName: 'Test', - eventType: 'track', - sourceDefinitionId: '1b6gJdqOPOCadT3cddw8eidV591', - destinationDefinitionId: '', - transformationId: '', - }, - destination: { - ID: 'string', - Name: 'string', - DestinationDefinition: { - ID: 'defid1', - Name: 'INTERCOM', - DisplayName: 'intercom', - Config: {}, - }, - Config: {}, - Enabled: true, - WorkspaceID: 'wspId', - Transformations: [], - }, + }), + metadata: metadata, + destination: destination, }, ], inputEvents: [ { - message: { - anonymousId: '2073230', - event: 'Test', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - originalTimestamp: '2022-12-23T00:29:12.117+05:30', - channel: 'sources', + message: getMessage({ context: { traits: { timestamp: '2023-01-22T00:29:12.117+05:30', }, }, - sentAt: '2022-12-23T00:29:12.117+05:30', timestamp: '2022-11-22T00:29:10.188+05:30', type: 'identify', - userId: '2564871', - }, - metadata: { - sourceId: '27O0bmEEx3GgfmEhZHUcPwJQVWC', - workspaceId: '27O0bhB6p5ehfOWeeZlOSsSDTLg', - namespace: '', - instanceId: '1', - sourceType: 'HTTP', - sourceCategory: '', - trackingPlanId: '', - trackingPlanVersion: 0, - sourceTpConfig: {}, - mergedTpConfig: {}, - destinationId: '2JH9GMQf2YFJFaTw7rz1pxHAJPx', - jobRunId: '', - jobId: 1, - sourceBatchId: '', - sourceJobId: '', - sourceJobRunId: '', - sourceTaskId: '', - sourceTaskRunId: '', - recordId: {}, - destinationType: 'WEBHOOK', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - oauthAccessToken: '', - messageIds: [], - rudderId: '<<>>2073230<<>>2564871', - receivedAt: '2022-12-23T00:29:10.189+05:30', - eventName: 'Test', - eventType: 'track', - sourceDefinitionId: '1b6gJdqOPOCadT3cddw8eidV591', - destinationDefinitionId: '', - transformationId: '', - }, - destination: { - ID: 'string', - Name: 'string', - DestinationDefinition: { - ID: 'defid1', - Name: 'INTERCOM', - DisplayName: 'intercom', - Config: {}, - }, - Config: {}, - Enabled: true, - WorkspaceID: 'wspId', - Transformations: [], - }, + }), + metadata: metadata, + destination: destination, }, { - message: { + message: getMessage({ anonymousId: '2073231', - event: 'Test', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - originalTimestamp: '2022-12-23T00:29:12.117+05:30', - channel: 'sources', traits: { timestamp: '2023-01-11T00:29:12.117+05:30', }, - sentAt: '2022-12-23T00:29:12.117+05:30', timestamp: '2022-11-22T00:29:10.188+05:30', type: 'identify', - userId: '2564871', - }, - metadata: { - sourceId: '27O0bmEEx3GgfmEhZHUcPwJQVWC', - workspaceId: '27O0bhB6p5ehfOWeeZlOSsSDTLg', - namespace: '', - instanceId: '1', - sourceType: 'HTTP', - sourceCategory: '', - trackingPlanId: '', - trackingPlanVersion: 0, - sourceTpConfig: {}, - mergedTpConfig: {}, - destinationId: '2JH9GMQf2YFJFaTw7rz1pxHAJPx', - jobRunId: '', - jobId: 1, - sourceBatchId: '', - sourceJobId: '', - sourceJobRunId: '', - sourceTaskId: '', - sourceTaskRunId: '', - recordId: {}, - destinationType: 'WEBHOOK', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - oauthAccessToken: '', - messageIds: [], - rudderId: '<<>>2073230<<>>2564871', - receivedAt: '2022-12-23T00:29:10.189+05:30', - eventName: 'Test', - eventType: 'track', - sourceDefinitionId: '1b6gJdqOPOCadT3cddw8eidV591', - destinationDefinitionId: '', - transformationId: '', - }, - destination: { - ID: 'string', - Name: 'string', - DestinationDefinition: { - ID: 'defid1', - Name: 'INTERCOM', - DisplayName: 'intercom', - Config: {}, - }, - Config: {}, - Enabled: true, - WorkspaceID: 'wspId', - Transformations: [], - }, + }), + metadata: metadata, + destination: destination, }, { - message: { + message: getMessage({ anonymousId: '2073232', - event: 'Test', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - originalTimestamp: '2022-12-23T00:29:12.117+05:30', - channel: 'sources', properties: { timestamp: '2023-01-13T00:29:12.117+05:30', }, - sentAt: '2022-12-23T00:29:12.117+05:30', timestamp: '2022-11-22T00:29:10.188+05:30', - type: 'track', - userId: '2564871', - }, - metadata: { - sourceId: '27O0bmEEx3GgfmEhZHUcPwJQVWC', - workspaceId: '27O0bhB6p5ehfOWeeZlOSsSDTLg', - namespace: '', - instanceId: '1', - sourceType: 'HTTP', - sourceCategory: '', - trackingPlanId: '', - trackingPlanVersion: 0, - sourceTpConfig: {}, - mergedTpConfig: {}, - destinationId: '2JH9GMQf2YFJFaTw7rz1pxHAJPx', - jobRunId: '', - jobId: 1, - sourceBatchId: '', - sourceJobId: '', - sourceJobRunId: '', - sourceTaskId: '', - sourceTaskRunId: '', - recordId: {}, - destinationType: 'WEBHOOK', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - oauthAccessToken: '', - messageIds: [], - rudderId: '<<>>2073230<<>>2564871', - receivedAt: '2022-12-23T00:29:10.189+05:30', - eventName: 'Test', - eventType: 'track', - sourceDefinitionId: '1b6gJdqOPOCadT3cddw8eidV591', - destinationDefinitionId: '', - transformationId: '', - }, - destination: { - ID: 'string', - Name: 'string', - DestinationDefinition: { - ID: 'defid1', - Name: 'INTERCOM', - DisplayName: 'intercom', - Config: {}, - }, - Config: {}, - Enabled: true, - WorkspaceID: 'wspId', - Transformations: [], - }, + }), + metadata: metadata, + destination: destination, }, { - message: { + message: getMessage({ anonymousId: '2073232', - event: 'Test', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - originalTimestamp: '2022-12-23T00:29:12.117+05:30', - channel: 'sources', properties: { timestamp: '2023-01-13T00:29:12.117+05:30', }, - sentAt: '2022-12-23T00:29:12.117+05:30', timestamp: '2022-11-22T00:29:10.188+05:30', type: 'group', - userId: '2564871', - }, - metadata: { - sourceId: '27O0bmEEx3GgfmEhZHUcPwJQVWC', - workspaceId: '27O0bhB6p5ehfOWeeZlOSsSDTLg', - namespace: '', - instanceId: '1', - sourceType: 'HTTP', - sourceCategory: '', - trackingPlanId: '', - trackingPlanVersion: 0, - sourceTpConfig: {}, - mergedTpConfig: {}, - destinationId: '2JH9GMQf2YFJFaTw7rz1pxHAJPx', - jobRunId: '', - jobId: 1, - sourceBatchId: '', - sourceJobId: '', - sourceJobRunId: '', - sourceTaskId: '', - sourceTaskRunId: '', - recordId: {}, - destinationType: 'WEBHOOK', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - oauthAccessToken: '', - messageIds: [], - rudderId: '<<>>2073230<<>>2564871', - receivedAt: '2022-12-23T00:29:10.189+05:30', - eventName: 'Test', - eventType: 'track', - sourceDefinitionId: '1b6gJdqOPOCadT3cddw8eidV591', - destinationDefinitionId: '', - transformationId: '', - }, - destination: { - ID: 'string', - Name: 'string', - DestinationDefinition: { - ID: 'defid1', - Name: 'INTERCOM', - DisplayName: 'intercom', - Config: {}, - }, - Config: {}, - Enabled: true, - WorkspaceID: 'wspId', - Transformations: [], - }, + }), + metadata: metadata, + destination: destination, }, ], }, @@ -916,520 +279,124 @@ const timestampEventsCases: timestampTestCases[] = [ 'when a mix of VDM enabled & non-VDM destinations are available, the timestamp will be applied to only non-VDM destination', expectedOutputEvents: [ { - message: { - anonymousId: '2073230', - event: 'Test', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - originalTimestamp: '2022-12-23T00:29:12.117+05:30', - channel: 'sources', + message: getMessage({ context: { traits: { timestamp: '2023-01-22T00:29:12.117+05:30', }, mappedToDestination: true, }, - sentAt: '2022-12-23T00:29:12.117+05:30', timestamp: '2022-11-22T00:29:10.188+05:30', type: 'identify', - userId: '2564871', - }, - metadata: { - sourceId: '27O0bmEEx3GgfmEhZHUcPwJQVWC', - workspaceId: '27O0bhB6p5ehfOWeeZlOSsSDTLg', - namespace: '', - instanceId: '1', - sourceType: 'HTTP', - sourceCategory: '', - trackingPlanId: '', - trackingPlanVersion: 0, - sourceTpConfig: {}, - mergedTpConfig: {}, - destinationId: '2JH9GMQf2YFJFaTw7rz1pxHAJPx', - jobRunId: '', - jobId: 1, - sourceBatchId: '', - sourceJobId: '', - sourceJobRunId: '', - sourceTaskId: '', - sourceTaskRunId: '', - recordId: {}, - destinationType: 'WEBHOOK', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - oauthAccessToken: '', - messageIds: [], - rudderId: '<<>>2073230<<>>2564871', - receivedAt: '2022-12-23T00:29:10.189+05:30', - eventName: 'Test', - eventType: 'track', - sourceDefinitionId: '1b6gJdqOPOCadT3cddw8eidV591', - destinationDefinitionId: '', - transformationId: '', - }, - destination: { - ID: 'string', - Name: 'string', - DestinationDefinition: { - ID: 'defid1', - Name: 'INTERCOM', - DisplayName: 'intercom', - Config: {}, - }, - Config: {}, - Enabled: true, - WorkspaceID: 'wspId', - Transformations: [], - }, + }), + metadata: metadata, + destination: destination, }, { - message: { + message: getMessage({ anonymousId: '2073231', - event: 'Test', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - originalTimestamp: '2022-12-23T00:29:12.117+05:30', - channel: 'sources', traits: { timestamp: '2023-01-11T00:29:12.117+05:30', }, - sentAt: '2022-12-23T00:29:12.117+05:30', timestamp: '2023-01-11T00:29:12.117+05:30', type: 'identify', - userId: '2564871', - }, - metadata: { - sourceId: '27O0bmEEx3GgfmEhZHUcPwJQVWC', - workspaceId: '27O0bhB6p5ehfOWeeZlOSsSDTLg', - namespace: '', - instanceId: '1', - sourceType: 'HTTP', - sourceCategory: '', - trackingPlanId: '', - trackingPlanVersion: 0, - sourceTpConfig: {}, - mergedTpConfig: {}, + }), + metadata: getMetadata({ destinationId: '2JH9GMQf2YFJFaTw7rz1pxHAJPy', - jobRunId: '', - jobId: 1, - sourceBatchId: '', - sourceJobId: '', - sourceJobRunId: '', - sourceTaskId: '', - sourceTaskRunId: '', - recordId: {}, - destinationType: 'WEBHOOK', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - oauthAccessToken: '', - messageIds: [], - rudderId: '<<>>2073230<<>>2564871', - receivedAt: '2022-12-23T00:29:10.189+05:30', - eventName: 'Test', - eventType: 'track', - sourceDefinitionId: '1b6gJdqOPOCadT3cddw8eidV591', - destinationDefinitionId: '', - transformationId: '', - }, - destination: { + } as any), + destination: getDestination({ ID: 'string-2', - Name: 'string', - DestinationDefinition: { - ID: 'defid1', - Name: 'INTERCOM', - DisplayName: 'intercom', - Config: {}, - }, - Config: {}, - Enabled: true, - WorkspaceID: 'wspId', - Transformations: [], - }, + } as any), }, { - message: { + message: getMessage({ anonymousId: '2073232', - event: 'Test', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - originalTimestamp: '2022-12-23T00:29:12.117+05:30', - channel: 'sources', context: { mappedToDestination: true, }, properties: { timestamp: '2023-01-13T00:29:12.117+05:30', }, - sentAt: '2022-12-23T00:29:12.117+05:30', timestamp: '2022-11-22T00:29:10.188+05:30', - type: 'track', - userId: '2564871', - }, - metadata: { - sourceId: '27O0bmEEx3GgfmEhZHUcPwJQVWC', - workspaceId: '27O0bhB6p5ehfOWeeZlOSsSDTLg', - namespace: '', - instanceId: '1', - sourceType: 'HTTP', - sourceCategory: '', - trackingPlanId: '', - trackingPlanVersion: 0, - sourceTpConfig: {}, - mergedTpConfig: {}, - destinationId: '2JH9GMQf2YFJFaTw7rz1pxHAJPx', - jobRunId: '', - jobId: 1, - sourceBatchId: '', - sourceJobId: '', - sourceJobRunId: '', - sourceTaskId: '', - sourceTaskRunId: '', - recordId: {}, - destinationType: 'WEBHOOK', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - oauthAccessToken: '', - messageIds: [], - rudderId: '<<>>2073230<<>>2564871', - receivedAt: '2022-12-23T00:29:10.189+05:30', - eventName: 'Test', - eventType: 'track', - sourceDefinitionId: '1b6gJdqOPOCadT3cddw8eidV591', - destinationDefinitionId: '', - transformationId: '', - }, - destination: { - ID: 'string', - Name: 'string', - DestinationDefinition: { - ID: 'defid1', - Name: 'INTERCOM', - DisplayName: 'intercom', - Config: {}, - }, - Config: {}, - Enabled: true, - WorkspaceID: 'wspId', - Transformations: [], - }, + }), + metadata: metadata, + destination: destination, }, { - message: { + message: getMessage({ anonymousId: '2073232', - event: 'Test', context: { mappedToDestination: true, }, - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - originalTimestamp: '2022-12-23T00:29:12.117+05:30', - channel: 'sources', properties: { timestamp: '2023-01-13T00:29:12.117+05:30', }, - sentAt: '2022-12-23T00:29:12.117+05:30', timestamp: '2022-11-22T00:29:10.188+05:30', type: 'group', - userId: '2564871', - }, - metadata: { - sourceId: '27O0bmEEx3GgfmEhZHUcPwJQVWC', - workspaceId: '27O0bhB6p5ehfOWeeZlOSsSDTLg', - namespace: '', - instanceId: '1', - sourceType: 'HTTP', - sourceCategory: '', - trackingPlanId: '', - trackingPlanVersion: 0, - sourceTpConfig: {}, - mergedTpConfig: {}, - destinationId: '2JH9GMQf2YFJFaTw7rz1pxHAJPx', - jobRunId: '', - jobId: 1, - sourceBatchId: '', - sourceJobId: '', - sourceJobRunId: '', - sourceTaskId: '', - sourceTaskRunId: '', - recordId: {}, - destinationType: 'WEBHOOK', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - oauthAccessToken: '', - messageIds: [], - rudderId: '<<>>2073230<<>>2564871', - receivedAt: '2022-12-23T00:29:10.189+05:30', - eventName: 'Test', - eventType: 'track', - sourceDefinitionId: '1b6gJdqOPOCadT3cddw8eidV591', - destinationDefinitionId: '', - transformationId: '', - }, - destination: { - ID: 'string', - Name: 'string', - DestinationDefinition: { - ID: 'defid1', - Name: 'INTERCOM', - DisplayName: 'intercom', - Config: {}, - }, - Config: {}, - Enabled: true, - WorkspaceID: 'wspId', - Transformations: [], - }, + }), + metadata: metadata, + destination: destination, }, ], inputEvents: [ { - message: { - anonymousId: '2073230', - event: 'Test', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - originalTimestamp: '2022-12-23T00:29:12.117+05:30', - channel: 'sources', + message: getMessage({ context: { traits: { timestamp: '2023-01-22T00:29:12.117+05:30', }, mappedToDestination: true, }, - sentAt: '2022-12-23T00:29:12.117+05:30', timestamp: '2022-11-22T00:29:10.188+05:30', type: 'identify', - userId: '2564871', - }, - metadata: { - sourceId: '27O0bmEEx3GgfmEhZHUcPwJQVWC', - workspaceId: '27O0bhB6p5ehfOWeeZlOSsSDTLg', - namespace: '', - instanceId: '1', - sourceType: 'HTTP', - sourceCategory: '', - trackingPlanId: '', - trackingPlanVersion: 0, - sourceTpConfig: {}, - mergedTpConfig: {}, - destinationId: '2JH9GMQf2YFJFaTw7rz1pxHAJPx', - jobRunId: '', - jobId: 1, - sourceBatchId: '', - sourceJobId: '', - sourceJobRunId: '', - sourceTaskId: '', - sourceTaskRunId: '', - recordId: {}, - destinationType: 'WEBHOOK', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - oauthAccessToken: '', - messageIds: [], - rudderId: '<<>>2073230<<>>2564871', - receivedAt: '2022-12-23T00:29:10.189+05:30', - eventName: 'Test', - eventType: 'track', - sourceDefinitionId: '1b6gJdqOPOCadT3cddw8eidV591', - destinationDefinitionId: '', - transformationId: '', - }, - destination: { - ID: 'string', - Name: 'string', - DestinationDefinition: { - ID: 'defid1', - Name: 'INTERCOM', - DisplayName: 'intercom', - Config: {}, - }, - Config: {}, - Enabled: true, - WorkspaceID: 'wspId', - Transformations: [], - }, + }), + metadata: metadata, + destination: destination, }, { - message: { + message: getMessage({ anonymousId: '2073231', - event: 'Test', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - originalTimestamp: '2022-12-23T00:29:12.117+05:30', - channel: 'sources', traits: { timestamp: '2023-01-11T00:29:12.117+05:30', }, - sentAt: '2022-12-23T00:29:12.117+05:30', timestamp: '2022-11-22T00:29:10.188+05:30', type: 'identify', - userId: '2564871', - }, - metadata: { - sourceId: '27O0bmEEx3GgfmEhZHUcPwJQVWC', - workspaceId: '27O0bhB6p5ehfOWeeZlOSsSDTLg', - namespace: '', - instanceId: '1', - sourceType: 'HTTP', - sourceCategory: '', - trackingPlanId: '', - trackingPlanVersion: 0, - sourceTpConfig: {}, - mergedTpConfig: {}, + }), + metadata: getMetadata({ destinationId: '2JH9GMQf2YFJFaTw7rz1pxHAJPy', - jobRunId: '', - jobId: 1, - sourceBatchId: '', - sourceJobId: '', - sourceJobRunId: '', - sourceTaskId: '', - sourceTaskRunId: '', - recordId: {}, - destinationType: 'WEBHOOK', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - oauthAccessToken: '', - messageIds: [], - rudderId: '<<>>2073230<<>>2564871', - receivedAt: '2022-12-23T00:29:10.189+05:30', - eventName: 'Test', - eventType: 'track', - sourceDefinitionId: '1b6gJdqOPOCadT3cddw8eidV591', - destinationDefinitionId: '', - transformationId: '', - }, - destination: { + } as any), + destination: getDestination({ ID: 'string-2', - Name: 'string', - DestinationDefinition: { - ID: 'defid1', - Name: 'INTERCOM', - DisplayName: 'intercom', - Config: {}, - }, - Config: {}, - Enabled: true, - WorkspaceID: 'wspId', - Transformations: [], - }, + } as any), }, { - message: { + message: getMessage({ anonymousId: '2073232', - event: 'Test', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - originalTimestamp: '2022-12-23T00:29:12.117+05:30', - channel: 'sources', context: { mappedToDestination: true, }, properties: { timestamp: '2023-01-13T00:29:12.117+05:30', }, - sentAt: '2022-12-23T00:29:12.117+05:30', timestamp: '2022-11-22T00:29:10.188+05:30', - type: 'track', - userId: '2564871', - }, - metadata: { - sourceId: '27O0bmEEx3GgfmEhZHUcPwJQVWC', - workspaceId: '27O0bhB6p5ehfOWeeZlOSsSDTLg', - namespace: '', - instanceId: '1', - sourceType: 'HTTP', - sourceCategory: '', - trackingPlanId: '', - trackingPlanVersion: 0, - sourceTpConfig: {}, - mergedTpConfig: {}, - destinationId: '2JH9GMQf2YFJFaTw7rz1pxHAJPx', - jobRunId: '', - jobId: 1, - sourceBatchId: '', - sourceJobId: '', - sourceJobRunId: '', - sourceTaskId: '', - sourceTaskRunId: '', - recordId: {}, - destinationType: 'WEBHOOK', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - oauthAccessToken: '', - messageIds: [], - rudderId: '<<>>2073230<<>>2564871', - receivedAt: '2022-12-23T00:29:10.189+05:30', - eventName: 'Test', - eventType: 'track', - sourceDefinitionId: '1b6gJdqOPOCadT3cddw8eidV591', - destinationDefinitionId: '', - transformationId: '', - }, - destination: { - ID: 'string', - Name: 'string', - DestinationDefinition: { - ID: 'defid1', - Name: 'INTERCOM', - DisplayName: 'intercom', - Config: {}, - }, - Config: {}, - Enabled: true, - WorkspaceID: 'wspId', - Transformations: [], - }, + }), + metadata: metadata, + destination: destination, }, { - message: { + message: getMessage({ anonymousId: '2073232', - event: 'Test', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - originalTimestamp: '2022-12-23T00:29:12.117+05:30', - channel: 'sources', context: { mappedToDestination: true, }, properties: { timestamp: '2023-01-13T00:29:12.117+05:30', }, - sentAt: '2022-12-23T00:29:12.117+05:30', timestamp: '2022-11-22T00:29:10.188+05:30', type: 'group', - userId: '2564871', - }, - metadata: { - sourceId: '27O0bmEEx3GgfmEhZHUcPwJQVWC', - workspaceId: '27O0bhB6p5ehfOWeeZlOSsSDTLg', - namespace: '', - instanceId: '1', - sourceType: 'HTTP', - sourceCategory: '', - trackingPlanId: '', - trackingPlanVersion: 0, - sourceTpConfig: {}, - mergedTpConfig: {}, - destinationId: '2JH9GMQf2YFJFaTw7rz1pxHAJPx', - jobRunId: '', - jobId: 1, - sourceBatchId: '', - sourceJobId: '', - sourceJobRunId: '', - sourceTaskId: '', - sourceTaskRunId: '', - recordId: {}, - destinationType: 'WEBHOOK', - messageId: 'e3a51e9a-6313-4389-ae73-07e487c8d9d0', - oauthAccessToken: '', - messageIds: [], - rudderId: '<<>>2073230<<>>2564871', - receivedAt: '2022-12-23T00:29:10.189+05:30', - eventName: 'Test', - eventType: 'track', - sourceDefinitionId: '1b6gJdqOPOCadT3cddw8eidV591', - destinationDefinitionId: '', - transformationId: '', - }, - destination: { - ID: 'string', - Name: 'string', - DestinationDefinition: { - ID: 'defid1', - Name: 'INTERCOM', - DisplayName: 'intercom', - Config: {}, - }, - Config: {}, - Enabled: true, - WorkspaceID: 'wspId', - Transformations: [], - }, + }), + metadata: metadata, + destination: destination, }, ], },