Skip to content

Commit

Permalink
fix: excludeMappedFields utility
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauravudia committed Aug 23, 2024
1 parent 7405284 commit 4173c08
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
13 changes: 9 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"@ndhoule/extend": "^2.0.0",
"@pyroscope/nodejs": "^0.2.9",
"@rudderstack/integrations-lib": "^0.2.10",
"@rudderstack/json-template-engine": "^0.17.1",
"@rudderstack/json-template-engine": "^0.18.0",
"@rudderstack/workflow-engine": "^0.8.13",
"@shopify/jest-koa-mocks": "^5.1.1",
"ajv": "^8.12.0",
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/v2/destinations/webhook_v2/rtWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ steps:
"batchedRequest": .,
"batched": false,
"destination": ^[idx].destination,
"metadata": ^[idx].metadata,
"metadata": ^[idx].metadata[],
"statusCode": 200
})[]
Expand Down
7 changes: 5 additions & 2 deletions src/cdk/v2/destinations/webhook_v2/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ const addPathParams = (message, webhookUrl) => webhookUrl;
const excludeMappedFields = (payload, mapping) => {
const rawPayload = { ...payload };
if (mapping) {
mapping.forEach(({ from }) => {
mapping.forEach(({ from, to }) => {
// continue when from === to
if (from === to) return;

// Remove the '$.' prefix and split the remaining string by '.'
const keys = from.replace(/^\$\./, '').split('.');
let current = rawPayload;
Expand Down Expand Up @@ -78,7 +81,7 @@ const getMergedEvents = (batch) => {
return events;
};

const mergeMetadata = (batch) => batch.map((event) => event.metadata);
const mergeMetadata = (batch) => batch.map((event) => event.metadata[0]);

const createHashKey = (endpoint, headers, params) => {
const hash = createHash('md5');
Expand Down

0 comments on commit 4173c08

Please sign in to comment.