Skip to content

Commit

Permalink
chore: remove value from updation webhook events
Browse files Browse the repository at this point in the history
  • Loading branch information
yashasvibajpai committed Dec 25, 2024
1 parent 2bfb88c commit b48828f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const ecomPayloadBuilder = (event, shopifyTopic) => {
message.setEventType(EventType.TRACK);
message.setEventName(RUDDER_ECOM_MAP[shopifyTopic]);

const properties = createPropertiesForEcomEventFromWebhook(event);
const properties = createPropertiesForEcomEventFromWebhook(event, shopifyTopic);
message.properties = removeUndefinedAndNullValues(properties);
// Map Customer details if present
const customerDetails = get(event, 'customer');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ const getProductsFromLineItems = (lineItems, mapping) => {
* @param {Object} message
* @returns {Object} properties
*/
const createPropertiesForEcomEventFromWebhook = (message) => {
const createPropertiesForEcomEventFromWebhook = (message, shopifyTopic) => {
const { line_items: lineItems } = message;
if (!lineItems || lineItems.length === 0) {
return [];
}
const mappedPayload = constructPayload(message, productMappingJSON);
if (shopifyTopic === 'orders_updated' || shopifyTopic === 'checkouts_update') {
delete mappedPayload.value;

Check warning on line 35 in src/v1/sources/shopify/webhookTransformations/serverSideUtlis.js

View check run for this annotation

Codecov / codecov/patch

src/v1/sources/shopify/webhookTransformations/serverSideUtlis.js#L35

Added line #L35 was not covered by tests
}
mappedPayload.products = getProductsFromLineItems(lineItems, lineItemsMappingJSON);
return mappedPayload;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,6 @@ export const checkoutEventsTestScenarios = [
},
],
tax: 0,
value: '736.85',
},
timestamp: '2024-09-17T07:29:02.000Z',
traits: {
Expand Down Expand Up @@ -1208,7 +1207,6 @@ export const checkoutEventsTestScenarios = [
event: 'Order Updated',
properties: {
order_id: '5778367414385',
value: '600.00',
tax: 0,
currency: 'USD',
products: [
Expand Down

0 comments on commit b48828f

Please sign in to comment.