Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update order_id in checkout events, messageId in pixel events #3794

Merged
merged 5 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/v1/sources/shopify/pixelTransform.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const NO_OPERATION_SUCCESS = {

function processPixelEvent(inputEvent) {
// eslint-disable-next-line @typescript-eslint/naming-convention
const { name, query_parameters, clientId, data } = inputEvent;
const { name, query_parameters, clientId, data, id } = inputEvent;
const { checkout } = data ?? {};
const { order } = checkout ?? {};
const { customer } = order ?? {};
Expand Down Expand Up @@ -77,6 +77,8 @@ function processPixelEvent(inputEvent) {
version: '2.0.0',
});
message.setProperty('context.topic', name);
message.setProperty('context.shopifyDetails', data);
krishna2020 marked this conversation as resolved.
Show resolved Hide resolved
krishna2020 marked this conversation as resolved.
Show resolved Hide resolved
message.messageId = id;
message = removeUndefinedAndNullValues(message);
return message;
}
Expand Down
2 changes: 1 addition & 1 deletion src/v1/sources/shopify/pixelUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const checkoutEventBuilder = (inputEvent) => {

const properties = {
products,
order_id: inputEvent.id,
order_id: inputEvent.data?.checkout?.order?.id,
checkout_id: inputEvent?.data?.checkout?.token,
total: inputEvent?.data?.checkout?.totalPrice?.amount,
currency: inputEvent?.data?.checkout?.currencyCode,
Expand Down
8 changes: 7 additions & 1 deletion src/v1/sources/shopify/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const process = async (inputEvent) => {
const { event } = inputEvent;
// check on the source Config to identify the event is from the tracker-based (legacy)
// or the pixel-based (latest) implementation.
const { pixelEventLabel: pixelClientEventLabel } = event;
const { pixelEventLabel: pixelClientEventLabel, id } = event;
if (pixelClientEventLabel) {
// this is a event fired from the web pixel loaded on the browser
// by the user interactions with the store.
Expand All @@ -15,6 +15,12 @@ const process = async (inputEvent) => {
}
// this is for common logic for server-side events processing for both pixel and tracker apps.
const response = await processWebhookEvents(event);
// attach everything that is part of webhook event to the context inside a key called shopifyDetails
response.context.shopifyDetails = { ...event };
// set the messageId to the id property if present the event.
if (id) {
response.messageId = id;
}
return response;
};

Expand Down
Loading