-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: onboard shopify to v1, initial commit * chore: refactor, add pixel transformation definitions * feat: add support for all pixel events in v1 shopify source * fix: add customer id check * chore: fix checks * fix: add configs for new webhook topics and events from pixel app * chore: update webhook event topic in mapping * chore: refactor * chore: update cart viewed logic * chore: refactor pixel code logic and tests * fix: library version for old and new serverside events * chore: address comments, refactorx1 * chore: add test * chore: add testsx2 * chore: update version naming from config * chore: keep old v0 logic intact, refactor * chore: sonarcloud reliability check fix * chore: update util file names * chore: move webhook specific logic for v2 pixel, address comments * chore: more refactoring, update userId and anonymousid from customer object * chore: update library name for pixel and webhook events in pixel app flow * chore: refactor pixel tests to seperate directory, remove reduntant test data --------- Co-authored-by: Krishna Chaitanya <[email protected]>
- Loading branch information
1 parent
ede31ef
commit d40e772
Showing
20 changed files
with
4,771 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
const PIXEL_EVENT_TOPICS = { | ||
CART_VIEWED: 'cart_viewed', | ||
PRODUCT_ADDED_TO_CART: 'product_added_to_cart', | ||
PRODUCT_REMOVED_FROM_CART: 'product_removed_from_cart', | ||
PAGE_VIEWED: 'page_viewed', | ||
PRODUCT_VIEWED: 'product_viewed', | ||
COLLECTION_VIEWED: 'collection_viewed', | ||
CHECKOUT_STARTED: 'checkout_started', | ||
CHECKOUT_COMPLETED: 'checkout_completed', | ||
CHECKOUT_ADDRESS_INFO_SUBMITTED: 'checkout_address_info_submitted', | ||
CHECKOUT_CONTACT_INFO_SUBMITTED: 'checkout_contact_info_submitted', | ||
CHECKOUT_SHIPPING_INFO_SUBMITTED: 'checkout_shipping_info_submitted', | ||
PAYMENT_INFO_SUBMITTED: 'payment_info_submitted', | ||
SEARCH_SUBMITTED: 'search_submitted', | ||
}; | ||
|
||
const PIXEL_EVENT_MAPPING = { | ||
cart_viewed: 'Cart Viewed', | ||
product_added_to_cart: 'Product Added', | ||
product_removed_from_cart: 'Product Removed', | ||
page_viewed: 'Page Viewed', | ||
product_viewed: 'Product Viewed', | ||
collection_viewed: 'Collection Viewed', | ||
checkout_started: 'Checkout Started', | ||
checkout_completed: 'Checkout Completed', | ||
checkout_address_info_submitted: 'Checkout Address Info Submitted', | ||
checkout_contact_info_submitted: 'Checkout Contact Info Submitted', | ||
checkout_shipping_info_submitted: 'Checkout Shipping Info Submitted', | ||
payment_info_submitted: 'Payment Info Submitted', | ||
search_submitted: 'Search Submitted', | ||
}; | ||
|
||
const contextualFieldMappingJSON = JSON.parse( | ||
fs.readFileSync(path.resolve(__dirname, 'pixelEventsMappings', 'contextualFieldMapping.json')), | ||
); | ||
|
||
const cartViewedEventMappingJSON = JSON.parse( | ||
fs.readFileSync(path.resolve(__dirname, 'pixelEventsMappings', 'cartViewedEventMapping.json')), | ||
); | ||
|
||
const productListViewedEventMappingJSON = JSON.parse( | ||
fs.readFileSync( | ||
path.resolve(__dirname, 'pixelEventsMappings', 'productListViewedEventMapping.json'), | ||
), | ||
); | ||
|
||
const productViewedEventMappingJSON = JSON.parse( | ||
fs.readFileSync(path.resolve(__dirname, 'pixelEventsMappings', 'productViewedEventMapping.json')), | ||
); | ||
|
||
const productToCartEventMappingJSON = JSON.parse( | ||
fs.readFileSync(path.resolve(__dirname, 'pixelEventsMappings', 'productToCartEventMapping.json')), | ||
); | ||
|
||
const checkoutStartedCompletedEventMappingJSON = JSON.parse( | ||
fs.readFileSync( | ||
path.resolve(__dirname, 'pixelEventsMappings', 'checkoutStartedCompletedEventMapping.json'), | ||
), | ||
); | ||
|
||
const INTEGERATION = 'SHOPIFY'; | ||
|
||
module.exports = { | ||
INTEGERATION, | ||
PIXEL_EVENT_TOPICS, | ||
PIXEL_EVENT_MAPPING, | ||
contextualFieldMappingJSON, | ||
cartViewedEventMappingJSON, | ||
productListViewedEventMappingJSON, | ||
productViewedEventMappingJSON, | ||
productToCartEventMappingJSON, | ||
checkoutStartedCompletedEventMappingJSON, | ||
}; |
42 changes: 42 additions & 0 deletions
42
src/v1/sources/shopify/pixelEventsMappings/cartViewedEventMapping.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
[ | ||
{ | ||
"sourceKeys": "merchandise.product.id", | ||
"destKeys": "product_id" | ||
}, | ||
{ | ||
"sourceKeys": "merchandise.product.title", | ||
"destKeys": "variant" | ||
}, | ||
{ | ||
"sourceKeys": "merchandise.image.src", | ||
"destKeys": "image_url" | ||
}, | ||
{ | ||
"sourceKeys": "merchandise.price.amount", | ||
"destKeys": "price" | ||
}, | ||
{ | ||
"sourceKeys": "merchandise.product.type", | ||
"destKeys": "category" | ||
}, | ||
{ | ||
"sourceKeys": "merchandise.product.url", | ||
"destKeys": "url" | ||
}, | ||
{ | ||
"sourceKeys": "merchandise.product.vendor", | ||
"destKeys": "brand" | ||
}, | ||
{ | ||
"sourceKeys": "merchandise.sku", | ||
"destKeys": "sku" | ||
}, | ||
{ | ||
"sourceKeys": "merchandise.title", | ||
"destKeys": "name" | ||
}, | ||
{ | ||
"sourceKeys": "quantity", | ||
"destKeys": "quantity" | ||
} | ||
] |
42 changes: 42 additions & 0 deletions
42
src/v1/sources/shopify/pixelEventsMappings/checkoutStartedCompletedEventMapping.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
[ | ||
{ | ||
"sourceKeys": "quantity", | ||
"destKeys": "quantity" | ||
}, | ||
{ | ||
"sourceKeys": "title", | ||
"destKeys": "name" | ||
}, | ||
{ | ||
"sourceKeys": "variant.image.src", | ||
"destKeys": "image_url" | ||
}, | ||
{ | ||
"sourceKeys": "variant.price.amount", | ||
"destKeys": "price" | ||
}, | ||
{ | ||
"sourceKeys": "variant.sku", | ||
"destKeys": "sku" | ||
}, | ||
{ | ||
"sourceKeys": "variant.product.id", | ||
"destKeys": "product_id" | ||
}, | ||
{ | ||
"sourceKeys": "variant.product.title", | ||
"destKeys": "variant" | ||
}, | ||
{ | ||
"sourceKeys": "variant.product.type", | ||
"destKeys": "category" | ||
}, | ||
{ | ||
"sourceKeys": "variant.product.url", | ||
"destKeys": "url" | ||
}, | ||
{ | ||
"sourceKeys": "variant.product.vendor", | ||
"destKeys": "brand" | ||
} | ||
] |
34 changes: 34 additions & 0 deletions
34
src/v1/sources/shopify/pixelEventsMappings/contextualFieldMapping.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[ | ||
{ | ||
"sourceKeys": "context.document.referrer", | ||
"destKeys": "page.referrer" | ||
}, | ||
{ | ||
"sourceKeys": "document.title", | ||
"destKeys": "page.title" | ||
}, | ||
{ | ||
"sourceKeys": "navigator.userAgent", | ||
"destKeys": "userAgent" | ||
}, | ||
{ | ||
"sourceKeys": "window.location.href", | ||
"destKeys": "page.url" | ||
}, | ||
{ | ||
"sourceKeys": "window.location.pathname", | ||
"destKeys": "page.path" | ||
}, | ||
{ | ||
"sourceKeys": "window.location.search", | ||
"destKeys": "page.search" | ||
}, | ||
{ | ||
"sourceKeys": "window.screen.height", | ||
"destKeys": "screen.height" | ||
}, | ||
{ | ||
"sourceKeys": "window.screen.width", | ||
"destKeys": "screen.width" | ||
} | ||
] |
38 changes: 38 additions & 0 deletions
38
src/v1/sources/shopify/pixelEventsMappings/productListViewedEventMapping.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
[ | ||
{ | ||
"sourceKeys": "image.src", | ||
"destKeys": "image_url" | ||
}, | ||
{ | ||
"sourceKeys": "price.amount", | ||
"destKeys": "price" | ||
}, | ||
{ | ||
"sourceKeys": "product.id", | ||
"destKeys": "product_id" | ||
}, | ||
{ | ||
"sourceKeys": "product.title", | ||
"destKeys": "variant" | ||
}, | ||
{ | ||
"sourceKeys": "product.type", | ||
"destKeys": "category" | ||
}, | ||
{ | ||
"sourceKeys": "product.url", | ||
"destKeys": "url" | ||
}, | ||
{ | ||
"sourceKeys": "product.vendor", | ||
"destKeys": "brand" | ||
}, | ||
{ | ||
"sourceKeys": "sku", | ||
"destKeys": "sku" | ||
}, | ||
{ | ||
"sourceKeys": "title", | ||
"destKeys": "name" | ||
} | ||
] |
42 changes: 42 additions & 0 deletions
42
src/v1/sources/shopify/pixelEventsMappings/productToCartEventMapping.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
[ | ||
{ | ||
"sourceKeys": "cartLine.merchandise.image.src", | ||
"destKeys": "image_url" | ||
}, | ||
{ | ||
"sourceKeys": "cartLine.merchandise.price.amount", | ||
"destKeys": "price" | ||
}, | ||
{ | ||
"sourceKeys": "cartLine.merchandise.product.id", | ||
"destKeys": "product_id" | ||
}, | ||
{ | ||
"sourceKeys": "cartLine.merchandise.product.title", | ||
"destKeys": "variant" | ||
}, | ||
{ | ||
"sourceKeys": "cartLine.merchandise.product.type", | ||
"destKeys": "category" | ||
}, | ||
{ | ||
"sourceKeys": "cartLine.merchandise.product.vendor", | ||
"destKeys": "brand" | ||
}, | ||
{ | ||
"sourceKeys": "cartLine.merchandise.product.url", | ||
"destKeys": "url" | ||
}, | ||
{ | ||
"sourceKeys": "cartLine.merchandise.sku", | ||
"destKeys": "sku" | ||
}, | ||
{ | ||
"sourceKeys": "cartLine.merchandise.title", | ||
"destKeys": "name" | ||
}, | ||
{ | ||
"sourceKeys": "cartLine.quantity", | ||
"destKeys": "quantity" | ||
} | ||
] |
Oops, something went wrong.