Skip to content

Commit

Permalink
adds support for deprecated addEcommerceItem method
Browse files Browse the repository at this point in the history
  • Loading branch information
lysy-vlc committed Jan 24, 2024
1 parent d13a076 commit e09e1c7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion example/src/pages/ECommercePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const ECommercePage: FunctionComponent = () => {

const handlelAddToCart = (product: Product) => {
enqueueSnackbar(`eCommerce.addEcommerceItem()`, { variant: 'success' })
eCommerce.addEcommerceItem([
eCommerce.ecommerceAddToCart([
{
...product,
quantity: 1
Expand Down
5 changes: 3 additions & 2 deletions src/constants/track-event.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ export enum TRACK_EVENT {
CUSTOM_EVENT = 'trackEvent',
GOAL = 'trackGoal',
SEARCH = 'trackSiteSearch',
ADD_ECOMMERCE_ITEM = 'ecommerceAddToCart',
ECOMMERCE_ADD_TO_CART = 'ecommerceAddToCart',
ADD_ECOMMERCE_ITEM = 'addEcommerceItem',
REMOVE_ECOMMERCE_ITEM = 'ecommerceAddToCart',
ECOMMERCE_PRODUCT_DETAIL_VIEW = 'ecommerceProductDetailView',
UPDATE_ECOMMERCE_CART = 'ecommerceCartUpdate',
Expand Down Expand Up @@ -67,5 +68,5 @@ export enum TRACK_EVENT {
SET_REQUEST_CONTENT_TYPE = 'setRequestContentType',
ENABLE_JS_ERROR_TRACKING = 'enableJSErrorTracking',
ERROR = 'trackError',
SET_TRACKING_SOURCE = 'setTrackingSource',
SET_TRACKING_SOURCE = 'setTrackingSource'
}
23 changes: 21 additions & 2 deletions src/services/e-commerce/e-commerce.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,28 @@ import { TRACK_EVENT } from '../../constants/track-event.constant'
import { PaqService } from '../paqService/paq.service'
import { Product } from '../../interfaces/product'
import { PaymentInformation } from '../../interfaces/payment'
/**
* @deprecated since version 1.3.1. Please use the newMethod instead.
*/
export function addEcommerceItem(
productSKU: string,
productName: string,
productCategory: string | string[],
productPrice: number,
productQuantity: number
) {
PaqService.push([
TRACK_EVENT.ADD_ECOMMERCE_ITEM,
productSKU,
productName,
productCategory,
productPrice,
productQuantity
])
}

export function addEcommerceItem(products: Product[]) {
PaqService.push([TRACK_EVENT.ADD_ECOMMERCE_ITEM, products])
export function ecommerceAddToCart(products: Product[]) {
PaqService.push([TRACK_EVENT.ECOMMERCE_ADD_TO_CART, products])
}

export function removeEcommerceItem(products: Product[]) {
Expand Down

0 comments on commit e09e1c7

Please sign in to comment.