Skip to content

Commit 17cb53b

Browse files
fix: stitched events through redis in pixel
1 parent 0c8251b commit 17cb53b

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

src/v1/sources/shopify/config.js

+3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ const RUDDER_ECOM_MAP = {
4242
orders_create: 'Order Created',
4343
};
4444

45+
const SERVERSIDE_STITCHED_EVENTS = Object.keys(RUDDER_ECOM_MAP);
46+
4547
const contextualFieldMappingJSON = JSON.parse(
4648
fs.readFileSync(path.resolve(__dirname, 'pixelEventsMappings', 'contextualFieldMapping.json')),
4749
);
@@ -95,6 +97,7 @@ module.exports = {
9597
PIXEL_EVENT_TOPICS,
9698
PIXEL_EVENT_MAPPING,
9799
RUDDER_ECOM_MAP,
100+
SERVERSIDE_STITCHED_EVENTS,
98101
contextualFieldMappingJSON,
99102
cartViewedEventMappingJSON,
100103
productListViewedEventMappingJSON,

src/v1/sources/shopify/webhookTransformations/serverSideTransform.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const {
2222
getProductsFromLineItems,
2323
getAnonymousIdFromAttributes,
2424
} = require('./serverSideUtlis');
25-
const { getCartToken } = require('../../../../v0/sources/shopify/util');
25+
const { getCartToken } = require('./serverSideUtlis');
2626

2727
const NO_OPERATION_SUCCESS = {
2828
outputToSource: {

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

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
const { isDefinedAndNotNull } = require('@rudderstack/integrations-lib');
22
const { constructPayload } = require('../../../../v0/util');
3-
const { lineItemsMappingJSON, productMappingJSON } = require('../config');
3+
const {
4+
lineItemsMappingJSON,
5+
productMappingJSON,
6+
SERVERSIDE_STITCHED_EVENTS,
7+
} = require('../config');
48

59
/**
610
* Returns an array of products from the lineItems array received from the webhook event
@@ -54,8 +58,22 @@ const getAnonymousIdFromAttributes = (event) => {
5458
return rudderAnonymousIdObject ? rudderAnonymousIdObject.value : null;
5559
};
5660

61+
/**
62+
* Returns the cart_token from the event message
63+
* @param {Object} message
64+
* @returns {String} cart_token
65+
*/
66+
const getCartToken = (message) => {
67+
const { event, properties, context } = message;
68+
if (SERVERSIDE_STITCHED_EVENTS.includes(event)) {
69+
return context?.cart_token || properties?.cart_token || null;
70+
}
71+
return null;
72+
};
73+
5774
module.exports = {
5875
createPropertiesForEcomEventFromWebhook,
5976
getProductsFromLineItems,
6077
getAnonymousIdFromAttributes,
78+
getCartToken,
6179
};

0 commit comments

Comments
 (0)