-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #384 from reactioncommerce/feature-willopez-core-o…
…rdering-tracking-checkout Add tracking to checkout flow
- Loading branch information
Showing
8 changed files
with
201 additions
and
15 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
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 |
---|---|---|
@@ -1,6 +1,12 @@ | ||
export default { | ||
CART_VIEWED: "Cart Viewed", | ||
PRODUCT_VIEWED: "Product Viewed", | ||
CHECKOUT_STARTED: "Checkout Started", | ||
CHECKOUT_STEP_VIEWED: "Checkout Step Viewed", | ||
CHECKOUT_STEP_COMPLETED: "Checkout Step Completed", | ||
ORDER_COMPLETED: "Order Completed", | ||
ORDER_UPDATED: "Order Updated", | ||
PAYMENT_INFO_ENTERED: "Payment Info Entered", | ||
PRODUCT_ADDED: "Product Added", | ||
PRODUCT_REMOVED: "Product Removed" | ||
PRODUCT_REMOVED: "Product Removed", | ||
PRODUCT_VIEWED: "Product Viewed" | ||
}; |
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,30 @@ | ||
import track from "./track"; | ||
import getCartItemTrackingData from "./utils/getCartItemTrackingData"; | ||
|
||
/** | ||
* trackCheckout HOC tracks the "Checkout Started" event | ||
* @name trackCheckout | ||
* @param {Object} options options to supply to tracking HOC | ||
* @returns {React.Component} - component | ||
*/ | ||
export default (options) => | ||
// eslint-disable-next-line no-unused-vars | ||
track(({ router }, state, functionArgs) => { | ||
const { cart, action } = (functionArgs && functionArgs[0]) || []; | ||
const { checkout: { summary }, items, shop } = cart; | ||
const products = []; | ||
|
||
items.forEach((item) => { | ||
products.push(getCartItemTrackingData(item)); | ||
}); | ||
|
||
return { | ||
action, | ||
value: summary.itemTotal.amount, | ||
revenue: summary.itemTotal.amount, | ||
shipping: summary.fulfillmentTotal, | ||
tax: summary.taxTotal, | ||
currency: shop.currency.code, | ||
products | ||
}; | ||
}, options); |
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,26 @@ | ||
import track from "./track"; | ||
|
||
/** | ||
* trackCheckoutStep HOC tracks the "Checkout Step Viewed | Completed" events | ||
* @name trackCheckoutStep | ||
* @param {Object} options options to supply to tracking HOC | ||
* @returns {React.Component} - component | ||
*/ | ||
export default (options) => | ||
// eslint-disable-next-line no-unused-vars | ||
track(({ router }, state, functionArgs) => { | ||
const { | ||
action, | ||
payment_method, // eslint-disable-line camelcase | ||
shipping_method, // eslint-disable-line camelcase | ||
step | ||
} = (functionArgs && functionArgs[0]) || []; | ||
|
||
return { | ||
action, | ||
payment_method, // eslint-disable-line camelcase | ||
shipping_method, // eslint-disable-line camelcase | ||
step | ||
|
||
}; | ||
}, options); |
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