From 39c81c1d9bc0476fc38cdcca28e7100ae6416975 Mon Sep 17 00:00:00 2001 From: Yashasvi Bajpai <33063622+yashasvibajpai@users.noreply.github.com> Date: Sun, 1 Sep 2024 23:56:51 +0530 Subject: [PATCH] fix: add customer id check --- src/v1/sources/shopify/transform.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/v1/sources/shopify/transform.js b/src/v1/sources/shopify/transform.js index 62b3bebe72..b0785bacc4 100644 --- a/src/v1/sources/shopify/transform.js +++ b/src/v1/sources/shopify/transform.js @@ -429,6 +429,9 @@ const processIdentifierEvent = async (event, metricMetadata) => { function processPixelEvent(inputEvent) { const { name, query_parameters, clientId, data } = inputEvent; + const { checkout } = data; + const { order } = checkout; + const { customer } = order; let message; switch (name) { case PIXEL_EVENT_TOPICS.PAGE_VIEWED: @@ -449,14 +452,14 @@ function processPixelEvent(inputEvent) { break; case PIXEL_EVENT_TOPICS.CHECKOUT_STARTED: case PIXEL_EVENT_TOPICS.CHECKOUT_COMPLETED: - message.userId = data?.checkout?.order?.customer?.id || ''; + if (customer.id) message.userId = customer.id || ''; message = checkoutEventBuilder(inputEvent); break; case PIXEL_EVENT_TOPICS.CHECKOUT_ADDRESS_INFO_SUBMITTED: case PIXEL_EVENT_TOPICS.CHECKOUT_CONTACT_INFO_SUBMITTED: case PIXEL_EVENT_TOPICS.CHECKOUT_SHIPPING_INFO_SUBMITTED: case PIXEL_EVENT_TOPICS.PAYMENT_INFO_SUBMITTED: - message.userId = data?.checkout?.order?.customer?.id || ''; + if (customer.id) message.userId = customer.id || ''; message = checkoutStepEventBuilder(inputEvent); break; case PIXEL_EVENT_TOPICS.SEARCH_SUBMITTED: