@uappi/public-sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +6 -0
- package/.vscode/extensions.json +5 -0
- package/.vscode/settings.json +7 -0
- package/components/Animations/ExpandTransition.ts +89 -0
- package/components/Animations/index.ts +1 -0
- package/components/Themes/CustomTheme.ts +77 -0
- package/components/Themes/index.ts +1 -0
- package/main.ts +16 -0
- package/modules/Api/README.md +469 -0
- package/modules/Api/endpoints/BannerComposable.ts +31 -0
- package/modules/Api/endpoints/BrandComposable.ts +21 -0
- package/modules/Api/endpoints/CartComposable.ts +121 -0
- package/modules/Api/endpoints/CommonComposable.ts +24 -0
- package/modules/Api/endpoints/CouponComposable.ts +18 -0
- package/modules/Api/endpoints/CustomerComposable.ts +255 -0
- package/modules/Api/endpoints/InterestComposable.ts +11 -0
- package/modules/Api/endpoints/LoggoutComposable.ts +8 -0
- package/modules/Api/endpoints/MenuComposable.ts +25 -0
- package/modules/Api/endpoints/PairOfferComposable.ts +14 -0
- package/modules/Api/endpoints/PaymentComposable.ts +14 -0
- package/modules/Api/endpoints/ProductCommentComposable.ts +51 -0
- package/modules/Api/endpoints/ProductQuoteShipment.ts +20 -0
- package/modules/Api/endpoints/PublicComposable.ts +9 -0
- package/modules/Api/endpoints/ReviewComposable.ts +64 -0
- package/modules/Api/endpoints/SearchComposable.ts +27 -0
- package/modules/Api/endpoints/ShowcaseComposable.ts +45 -0
- package/modules/Api/endpoints/TemplateComposable.ts +8 -0
- package/modules/Api/endpoints/ThirdPartyComposable.ts +14 -0
- package/modules/Api/endpoints/UpsellComposable.ts +18 -0
- package/modules/Api/endpoints/UrlComposable.ts +26 -0
- package/modules/Api/endpoints/VariationComposable.ts +36 -0
- package/modules/Api/endpoints/WalletComposable.ts +36 -0
- package/modules/Api/endpoints/ZipcodeComposable.ts +10 -0
- package/modules/Api/index.ts +194 -0
- package/modules/Api/paramsSerializer/encodeWafNormalizer.ts +7 -0
- package/modules/Api/types/context/api-config.types.ts +68 -0
- package/modules/Api/types/context/api-params.types.ts +74 -0
- package/modules/Api/types/endpoints/attribute/attribute.interfaces.ts +42 -0
- package/modules/Api/types/endpoints/banner/banner.interfaces.ts +45 -0
- package/modules/Api/types/endpoints/brand/brand-field.types.ts +3 -0
- package/modules/Api/types/endpoints/brand/brand.interfaces.ts +23 -0
- package/modules/Api/types/endpoints/cart/cart.interfaces.ts +161 -0
- package/modules/Api/types/endpoints/cart/cart.types.ts +27 -0
- package/modules/Api/types/endpoints/common/common.interfaces.ts +21 -0
- package/modules/Api/types/endpoints/context/context.types.ts +1 -0
- package/modules/Api/types/endpoints/country/country.types.ts +7502 -0
- package/modules/Api/types/endpoints/coupon/coupon.interfaces.ts +13 -0
- package/modules/Api/types/endpoints/customer/customer-erros.ts +13 -0
- package/modules/Api/types/endpoints/customer/customer-obsearch.ts +103 -0
- package/modules/Api/types/endpoints/customer/customer.interfaces.ts +448 -0
- package/modules/Api/types/endpoints/customer/customer.types.ts +3 -0
- package/modules/Api/types/endpoints/description/description.interfaces.ts +30 -0
- package/modules/Api/types/endpoints/discounts/discounts.interfaces.ts +9 -0
- package/modules/Api/types/endpoints/discounts/discounts.types.ts +5 -0
- package/modules/Api/types/endpoints/filters/filter.type.ts +1 -0
- package/modules/Api/types/endpoints/filters/filters.interfaces.ts +26 -0
- package/modules/Api/types/endpoints/interest/interest.interfaces.ts +22 -0
- package/modules/Api/types/endpoints/media/media.interfaces.ts +13 -0
- package/modules/Api/types/endpoints/menu/menu.enums.ts +8 -0
- package/modules/Api/types/endpoints/menu/menu.interfaces.ts +26 -0
- package/modules/Api/types/endpoints/order/order.interfaces.ts +63 -0
- package/modules/Api/types/endpoints/page/page.interfaces.ts +15 -0
- package/modules/Api/types/endpoints/pagination/pagination.interfaces.ts +6 -0
- package/modules/Api/types/endpoints/pair-offer/pair-offer.interfaces.ts +19 -0
- package/modules/Api/types/endpoints/payment/payment.interfaces.ts +103 -0
- package/modules/Api/types/endpoints/payment/payment.types.ts +27 -0
- package/modules/Api/types/endpoints/price/price.interfaces.ts +22 -0
- package/modules/Api/types/endpoints/product/product-obsearch.types.ts +63 -0
- package/modules/Api/types/endpoints/product/product.interfaces.ts +109 -0
- package/modules/Api/types/endpoints/product/product.types.ts +3 -0
- package/modules/Api/types/endpoints/product-comment/product-comment-obsearch.types.ts +24 -0
- package/modules/Api/types/endpoints/product-comment/product-comment.interfaces.ts +32 -0
- package/modules/Api/types/endpoints/redirect/redirect.interfaces.ts +7 -0
- package/modules/Api/types/endpoints/review/review-obsearch.types.ts +18 -0
- package/modules/Api/types/endpoints/review/review.interfaces.ts +34 -0
- package/modules/Api/types/endpoints/seal/seal.interfaces.ts +21 -0
- package/modules/Api/types/endpoints/seal/seal.types.ts +3 -0
- package/modules/Api/types/endpoints/search/search.interfaces.ts +11 -0
- package/modules/Api/types/endpoints/seo/seo.interfaces.ts +11 -0
- package/modules/Api/types/endpoints/shipment/shipment.interfaces.ts +137 -0
- package/modules/Api/types/endpoints/showcase/showcase.enums.ts +8 -0
- package/modules/Api/types/endpoints/showcase/showcase.interfaces.ts +10 -0
- package/modules/Api/types/endpoints/simple-product/simple-product.interfaces.ts +15 -0
- package/modules/Api/types/endpoints/storage/storage.interfaces.ts +16 -0
- package/modules/Api/types/endpoints/template/template.interfaces.ts +30 -0
- package/modules/Api/types/endpoints/third-party/oauth.interfaces.ts +6 -0
- package/modules/Api/types/endpoints/upsell/upsell.interfaces.ts +13 -0
- package/modules/Api/types/endpoints/url/url.interfaces.ts +85 -0
- package/modules/Api/types/endpoints/wallet/wallet-obsearch.ts +8 -0
- package/modules/Api/types/endpoints/wallet/wallet.interfaces.ts +57 -0
- package/modules/Api/types/endpoints/zipcode/zipcode.interfaces.ts +23 -0
- package/modules/Api/types/index.ts +459 -0
- package/modules/Api/usePublicApi.ts +68 -0
- package/modules/Tracking/endpoints/BannerComposable.ts +33 -0
- package/modules/Tracking/endpoints/CartComposable.ts +75 -0
- package/modules/Tracking/endpoints/CustomerComposable.ts +68 -0
- package/modules/Tracking/endpoints/ProductQuoteShipment.ts +14 -0
- package/modules/Tracking/endpoints/SearchComposable.ts +32 -0
- package/modules/Tracking/endpoints/ShowcaseComposable.ts +54 -0
- package/modules/Tracking/endpoints/UrlComposable.ts +41 -0
- package/modules/Tracking/endpoints/types.ts +11 -0
- package/modules/Tracking/events/actions/addPaymentInfo.ts +31 -0
- package/modules/Tracking/events/actions/addShippingInfo.ts +27 -0
- package/modules/Tracking/events/actions/addToCart.ts +35 -0
- package/modules/Tracking/events/actions/beginCheckout.ts +28 -0
- package/modules/Tracking/events/actions/customerProfile.ts +36 -0
- package/modules/Tracking/events/actions/generateLead.ts +12 -0
- package/modules/Tracking/events/actions/login.ts +8 -0
- package/modules/Tracking/events/actions/purchase.ts +42 -0
- package/modules/Tracking/events/actions/removeFromCart.ts +52 -0
- package/modules/Tracking/events/actions/search.ts +8 -0
- package/modules/Tracking/events/actions/selectItem.ts +64 -0
- package/modules/Tracking/events/actions/selectPromotion.ts +24 -0
- package/modules/Tracking/events/actions/shippingCalculation.ts +7 -0
- package/modules/Tracking/events/actions/signup.ts +8 -0
- package/modules/Tracking/events/actions/upsertToCart.ts +62 -0
- package/modules/Tracking/events/views/viewCart.ts +28 -0
- package/modules/Tracking/events/views/viewHome.ts +5 -0
- package/modules/Tracking/events/views/viewItem.ts +31 -0
- package/modules/Tracking/events/views/viewItemList.ts +65 -0
- package/modules/Tracking/events/views/viewNotFound.ts +5 -0
- package/modules/Tracking/events/views/viewOther.ts +5 -0
- package/modules/Tracking/events/views/viewPayment.ts +7 -0
- package/modules/Tracking/events/views/viewPromotion.ts +28 -0
- package/modules/Tracking/events/views/viewShipping.ts +7 -0
- package/modules/Tracking/index.ts +84 -0
- package/modules/Tracking/publicApiTracking.ts +36 -0
- package/modules/Tracking/types/actions/add-payment-info.interfaces.ts +12 -0
- package/modules/Tracking/types/actions/add-shipping-info.interfaces.ts +11 -0
- package/modules/Tracking/types/actions/add-to-cart.interfaces.ts +10 -0
- package/modules/Tracking/types/actions/begin-checkout.interfaces.ts +12 -0
- package/modules/Tracking/types/actions/customer-profile.interfaces.ts +19 -0
- package/modules/Tracking/types/actions/file-download.interfaces.ts +4 -0
- package/modules/Tracking/types/actions/generate-lead.interfaces.ts +12 -0
- package/modules/Tracking/types/actions/login.interfaces.ts +4 -0
- package/modules/Tracking/types/actions/purchase.interfaces.ts +18 -0
- package/modules/Tracking/types/actions/remove-from-cart.interfaces.ts +10 -0
- package/modules/Tracking/types/actions/search.interfaces.ts +4 -0
- package/modules/Tracking/types/actions/select-item.interfaces.ts +16 -0
- package/modules/Tracking/types/actions/select-promotion.interfaces.ts +8 -0
- package/modules/Tracking/types/actions/share.interfaces.ts +4 -0
- package/modules/Tracking/types/actions/shipping-calculation.interfaces.ts +3 -0
- package/modules/Tracking/types/actions/signup.interfaces.ts +4 -0
- package/modules/Tracking/types/event.types.ts +54 -0
- package/modules/Tracking/types/index.ts +37 -0
- package/modules/Tracking/types/item.interfaces.ts +30 -0
- package/modules/Tracking/types/views/view-cart.interfaces.ts +11 -0
- package/modules/Tracking/types/views/view-home.interfaces.ts +3 -0
- package/modules/Tracking/types/views/view-item-list.interfaces.ts +11 -0
- package/modules/Tracking/types/views/view-item.interfaces.ts +15 -0
- package/modules/Tracking/types/views/view-not-found.interfaces.ts +3 -0
- package/modules/Tracking/types/views/view-other.interfaces.ts +3 -0
- package/modules/Tracking/types/views/view-payment.interfaces.ts +3 -0
- package/modules/Tracking/types/views/view-promotion.interfaces.ts +8 -0
- package/modules/Tracking/types/views/view-shipping.interfaces.ts +3 -0
- package/modules/Tracking/utils/cart.ts +100 -0
- package/modules/Tracking/utils/pushDatalayer.ts +7 -0
- package/package.json +27 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import publicApi from '../../Api';
|
|
2
|
+
|
|
3
|
+
import type { TrackingProductFields } from './types';
|
|
4
|
+
|
|
5
|
+
import { viewItemList } from '../events/views/viewItemList';
|
|
6
|
+
|
|
7
|
+
import type {
|
|
8
|
+
ApiParams,
|
|
9
|
+
ProductConditionFields,
|
|
10
|
+
ProductFields,
|
|
11
|
+
ProductSortFields,
|
|
12
|
+
} from '../../Api/types';
|
|
13
|
+
|
|
14
|
+
export function getSearch(
|
|
15
|
+
term: string,
|
|
16
|
+
options?: Pick<
|
|
17
|
+
ApiParams<TrackingProductFields, ProductSortFields, ProductConditionFields>,
|
|
18
|
+
'condition' | 'fields' | 'limit' | 'meta' | 'offset' | 'order'
|
|
19
|
+
>,
|
|
20
|
+
) {
|
|
21
|
+
let fields: Array<ProductFields> = ['price', 'brand', 'variation'];
|
|
22
|
+
|
|
23
|
+
if (options?.fields) fields = [...options.fields, ...fields];
|
|
24
|
+
|
|
25
|
+
return publicApi.product
|
|
26
|
+
.getSearch(term, { ...options, fields })
|
|
27
|
+
.then(data => {
|
|
28
|
+
viewItemList(data);
|
|
29
|
+
|
|
30
|
+
return data;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import publicApi from '../../Api';
|
|
2
|
+
|
|
3
|
+
import type { TrackingProductFields } from './types';
|
|
4
|
+
|
|
5
|
+
import { viewItemList } from '../events/views/viewItemList';
|
|
6
|
+
|
|
7
|
+
import type {
|
|
8
|
+
ApiParams,
|
|
9
|
+
ProductFields,
|
|
10
|
+
Showcase,
|
|
11
|
+
} from '../../Api/types';
|
|
12
|
+
|
|
13
|
+
export function listShowcase(
|
|
14
|
+
codes: string,
|
|
15
|
+
options?: Pick<
|
|
16
|
+
ApiParams<TrackingProductFields>,
|
|
17
|
+
'condition' | 'fields' | 'meta' | 'order'
|
|
18
|
+
>,
|
|
19
|
+
): Promise<Showcase>;
|
|
20
|
+
|
|
21
|
+
export function listShowcase(
|
|
22
|
+
codes: Array<string>,
|
|
23
|
+
options?: Pick<
|
|
24
|
+
ApiParams<TrackingProductFields>,
|
|
25
|
+
'condition' | 'fields' | 'meta' | 'order'
|
|
26
|
+
>,
|
|
27
|
+
): Promise<Array<Showcase>>;
|
|
28
|
+
|
|
29
|
+
export function listShowcase(
|
|
30
|
+
codes: Array<string> | string,
|
|
31
|
+
options?: Pick<
|
|
32
|
+
ApiParams<TrackingProductFields>,
|
|
33
|
+
'condition' | 'fields' | 'meta' | 'order'
|
|
34
|
+
>,
|
|
35
|
+
) {
|
|
36
|
+
let fields: Array<ProductFields> = ['price', 'brand', 'variation'];
|
|
37
|
+
|
|
38
|
+
if (options?.fields) fields = [...options.fields, ...fields];
|
|
39
|
+
|
|
40
|
+
if (Array.isArray(codes))
|
|
41
|
+
return publicApi.customization
|
|
42
|
+
.listShowcase(codes, { ...options, fields })
|
|
43
|
+
.then(data => {
|
|
44
|
+
viewItemList(data);
|
|
45
|
+
return data;
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return publicApi.customization
|
|
49
|
+
.listShowcase(codes, { ...options, fields })
|
|
50
|
+
.then(data => {
|
|
51
|
+
viewItemList([data]);
|
|
52
|
+
return data;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import publicApi from '../../Api';
|
|
2
|
+
|
|
3
|
+
import type { TrackingProductFields } from './types';
|
|
4
|
+
|
|
5
|
+
import { viewItem } from '../events/views/viewItem';
|
|
6
|
+
import { viewItemList } from '../events/views/viewItemList';
|
|
7
|
+
|
|
8
|
+
import type {
|
|
9
|
+
ApiParams,
|
|
10
|
+
ProductConditionFields,
|
|
11
|
+
ProductFields,
|
|
12
|
+
ProductSortFields,
|
|
13
|
+
UrlBrand,
|
|
14
|
+
UrlListing,
|
|
15
|
+
UrlPage,
|
|
16
|
+
UrlProduct,
|
|
17
|
+
} from '../../Api/types';
|
|
18
|
+
|
|
19
|
+
export function getUrl<UrlType>(
|
|
20
|
+
path: string,
|
|
21
|
+
options?: Pick<
|
|
22
|
+
ApiParams<TrackingProductFields, ProductSortFields, ProductConditionFields>,
|
|
23
|
+
'condition' | 'fields' | 'limit' | 'offset' | 'meta' | 'order'
|
|
24
|
+
>,
|
|
25
|
+
) {
|
|
26
|
+
let fields: Array<ProductFields> = ['price', 'brand', 'variation'];
|
|
27
|
+
|
|
28
|
+
if (options?.fields) fields = [...options.fields, ...fields];
|
|
29
|
+
|
|
30
|
+
return publicApi.product
|
|
31
|
+
.getUrl<UrlType>(path, { ...options, fields })
|
|
32
|
+
.then(data => {
|
|
33
|
+
const pageData = data as UrlProduct | UrlPage | UrlBrand | UrlListing;
|
|
34
|
+
|
|
35
|
+
if (pageData.type === 'product') viewItem(pageData.content);
|
|
36
|
+
if (pageData.type === 'brand' || pageData.type === 'category')
|
|
37
|
+
viewItemList(pageData);
|
|
38
|
+
|
|
39
|
+
return data;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CustomerFields, ProductFields } from '../../Api/types';
|
|
2
|
+
|
|
3
|
+
export type TrackingCustomerFields = Exclude<
|
|
4
|
+
CustomerFields,
|
|
5
|
+
'addresses' | 'documents'
|
|
6
|
+
>;
|
|
7
|
+
|
|
8
|
+
export type TrackingProductFields = Exclude<
|
|
9
|
+
ProductFields,
|
|
10
|
+
'price' | 'variation' | 'mainCategory' | 'brand'
|
|
11
|
+
>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { getAddedCartItems, getVariant, totalValue } from '../../utils/cart';
|
|
2
|
+
import { pushDatalayer } from '../../utils/pushDatalayer';
|
|
3
|
+
|
|
4
|
+
import type { CartResponse } from '../../api/types';
|
|
5
|
+
|
|
6
|
+
export function addPaymentInfoAction(
|
|
7
|
+
paymentMethod: string,
|
|
8
|
+
cartPayload: CartResponse,
|
|
9
|
+
) {
|
|
10
|
+
pushDatalayer({
|
|
11
|
+
event: 'add_payment_info',
|
|
12
|
+
ecommerce: {
|
|
13
|
+
currency: 'BRL',
|
|
14
|
+
value: totalValue(cartPayload),
|
|
15
|
+
coupon: cartPayload.discountMap.coupon?.discountMainCode || '',
|
|
16
|
+
payment_type: paymentMethod,
|
|
17
|
+
items: getAddedCartItems(cartPayload).map(item => {
|
|
18
|
+
return {
|
|
19
|
+
item_category: '',
|
|
20
|
+
coupon: cartPayload.discountMap.coupon?.discountMainCode || '',
|
|
21
|
+
item_brand: `${item.product.brandId}`,
|
|
22
|
+
item_id: item.product.productId,
|
|
23
|
+
item_name: item.product.name,
|
|
24
|
+
item_variant: getVariant(item),
|
|
25
|
+
price: item.unitValue,
|
|
26
|
+
quantity: item.quantity,
|
|
27
|
+
};
|
|
28
|
+
}),
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { getAddedCartItems, getVariant, totalValue } from '../../utils/cart';
|
|
2
|
+
import { pushDatalayer } from '../../utils/pushDatalayer';
|
|
3
|
+
|
|
4
|
+
import type { CartResponse } from '../../api/types';
|
|
5
|
+
|
|
6
|
+
export function addShippingInfoAction(cartPayload: CartResponse) {
|
|
7
|
+
pushDatalayer({
|
|
8
|
+
event: 'add_shipping_info',
|
|
9
|
+
ecommerce: {
|
|
10
|
+
currency: 'BRL',
|
|
11
|
+
value: totalValue(cartPayload),
|
|
12
|
+
coupon: cartPayload.discountMap.coupon?.discountMainCode || '',
|
|
13
|
+
items: getAddedCartItems(cartPayload).map(item => {
|
|
14
|
+
return {
|
|
15
|
+
item_category: '',
|
|
16
|
+
coupon: cartPayload.discountMap.coupon?.discountMainCode || '',
|
|
17
|
+
item_brand: `${item.product.brandId}`,
|
|
18
|
+
item_id: item.product.productId,
|
|
19
|
+
item_name: item.product.name,
|
|
20
|
+
item_variant: getVariant(item),
|
|
21
|
+
price: item.unitValue,
|
|
22
|
+
quantity: item.quantity,
|
|
23
|
+
};
|
|
24
|
+
}),
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { getAddedCartItems, getVariant, totalValue } from '../../utils/cart';
|
|
2
|
+
import { pushDatalayer } from '../../utils/pushDatalayer';
|
|
3
|
+
|
|
4
|
+
import type { UpsertTrackingCartRequest } from '../../types';
|
|
5
|
+
import type { CartResponse } from '../../api/types';
|
|
6
|
+
|
|
7
|
+
export function addToCartAction(
|
|
8
|
+
upsertPayload: UpsertTrackingCartRequest,
|
|
9
|
+
cartPayload: CartResponse,
|
|
10
|
+
) {
|
|
11
|
+
if (!getAddedCartItems(cartPayload, upsertPayload).length) return;
|
|
12
|
+
|
|
13
|
+
pushDatalayer({
|
|
14
|
+
event: 'add_to_cart',
|
|
15
|
+
ecommerce: {
|
|
16
|
+
currency: 'BRL',
|
|
17
|
+
value: totalValue(cartPayload, upsertPayload),
|
|
18
|
+
items: getAddedCartItems(cartPayload, upsertPayload).map(item => {
|
|
19
|
+
return {
|
|
20
|
+
item_category: '',
|
|
21
|
+
coupon: cartPayload.discountMap.coupon?.discountMainCode || '',
|
|
22
|
+
item_brand: `${item.product.brandId}`,
|
|
23
|
+
item_id: item.product.productId,
|
|
24
|
+
item_name: item.product.name,
|
|
25
|
+
item_variant: getVariant(item),
|
|
26
|
+
price: item.unitValue,
|
|
27
|
+
quantity:
|
|
28
|
+
item.quantity > item.oldQuantity!
|
|
29
|
+
? item.quantity - item.oldQuantity!
|
|
30
|
+
: item.oldQuantity! - item.quantity,
|
|
31
|
+
};
|
|
32
|
+
}),
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { getAddedCartItems, getVariant, totalValue } from '../../utils/cart';
|
|
2
|
+
import { pushDatalayer } from '../../utils/pushDatalayer';
|
|
3
|
+
|
|
4
|
+
import type { CartResponse } from '../../api/types';
|
|
5
|
+
|
|
6
|
+
export function beginCheckoutAction(cartPayload: CartResponse) {
|
|
7
|
+
pushDatalayer({
|
|
8
|
+
event: 'begin_checkout',
|
|
9
|
+
ecommerce: {
|
|
10
|
+
currency: 'BRL',
|
|
11
|
+
value: totalValue(cartPayload),
|
|
12
|
+
shipping_tier: 'Ground',
|
|
13
|
+
coupon: cartPayload.discountMap.coupon?.discountMainCode || '',
|
|
14
|
+
items: getAddedCartItems(cartPayload).map(item => {
|
|
15
|
+
return {
|
|
16
|
+
item_category: '',
|
|
17
|
+
coupon: cartPayload.discountMap.coupon?.discountMainCode || '',
|
|
18
|
+
item_brand: `${item.product.brandId}`,
|
|
19
|
+
item_id: item.product.productId,
|
|
20
|
+
item_name: item.product.name,
|
|
21
|
+
item_variant: getVariant(item),
|
|
22
|
+
price: item.unitValue,
|
|
23
|
+
quantity: item.quantity,
|
|
24
|
+
};
|
|
25
|
+
}),
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { pushDatalayer } from '../../utils/pushDatalayer';
|
|
2
|
+
|
|
3
|
+
import type { CustomerResponse } from '../../api/types';
|
|
4
|
+
|
|
5
|
+
export function customerProfileAction(payload?: CustomerResponse) {
|
|
6
|
+
if (!payload) {
|
|
7
|
+
pushDatalayer({
|
|
8
|
+
event: 'customer_profile',
|
|
9
|
+
customer: {
|
|
10
|
+
id: 0,
|
|
11
|
+
birthdate: '',
|
|
12
|
+
email: '',
|
|
13
|
+
name: 'Visitante',
|
|
14
|
+
gender: 'undefined',
|
|
15
|
+
flags: null,
|
|
16
|
+
address: null,
|
|
17
|
+
loginStatus: false,
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
pushDatalayer({
|
|
24
|
+
event: 'customer_profile',
|
|
25
|
+
customer: {
|
|
26
|
+
id: payload.id,
|
|
27
|
+
birthdate: payload.birthdate,
|
|
28
|
+
email: payload.email,
|
|
29
|
+
name: payload.nameCorporateName,
|
|
30
|
+
gender: payload.gender,
|
|
31
|
+
flags: payload.flags,
|
|
32
|
+
address: payload.addresses,
|
|
33
|
+
loginStatus: true,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { pushDatalayer } from '../../utils/pushDatalayer';
|
|
2
|
+
|
|
3
|
+
import type { CustomerLead } from '../../types';
|
|
4
|
+
|
|
5
|
+
export function generateLead(customer: CustomerLead) {
|
|
6
|
+
pushDatalayer({
|
|
7
|
+
event: 'generate_lead',
|
|
8
|
+
name: customer.name,
|
|
9
|
+
email: customer.email,
|
|
10
|
+
phone: customer.phone,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { getAddedCartItems, getVariant, totalValue } from '../../utils/cart';
|
|
2
|
+
import { pushDatalayer } from '../../utils/pushDatalayer';
|
|
3
|
+
|
|
4
|
+
import type { CartResponse } from '../../api/types';
|
|
5
|
+
|
|
6
|
+
export function purchaseAction(
|
|
7
|
+
paymentMethod: string,
|
|
8
|
+
cartPayload: CartResponse,
|
|
9
|
+
) {
|
|
10
|
+
pushDatalayer({
|
|
11
|
+
event: 'purchase',
|
|
12
|
+
ecommerce: {
|
|
13
|
+
currency: 'BRL',
|
|
14
|
+
affiliation: 'Loja Virtual',
|
|
15
|
+
|
|
16
|
+
payment_status: 'em aberto',
|
|
17
|
+
payment_type: paymentMethod,
|
|
18
|
+
|
|
19
|
+
shipping: cartPayload.shippingValue,
|
|
20
|
+
shipping_tier: cartPayload.orders[0].shippingOptions.find(
|
|
21
|
+
shippingOption => shippingOption.selected,
|
|
22
|
+
)!.label,
|
|
23
|
+
tax: 0,
|
|
24
|
+
transaction_id: '',
|
|
25
|
+
|
|
26
|
+
value: totalValue(cartPayload),
|
|
27
|
+
coupon: cartPayload.discountMap.coupon?.discountMainCode || '',
|
|
28
|
+
items: getAddedCartItems(cartPayload).map(item => {
|
|
29
|
+
return {
|
|
30
|
+
item_category: '',
|
|
31
|
+
coupon: cartPayload.discountMap.coupon?.discountMainCode || '',
|
|
32
|
+
item_brand: `${item.product.brandId}`,
|
|
33
|
+
item_id: item.product.productId,
|
|
34
|
+
item_name: item.product.name,
|
|
35
|
+
item_variant: getVariant(item),
|
|
36
|
+
price: item.unitValue,
|
|
37
|
+
quantity: item.quantity,
|
|
38
|
+
};
|
|
39
|
+
}),
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { getAddedCartItems, getVariant, totalValue } from '../../utils/cart';
|
|
2
|
+
import { pushDatalayer } from '../../utils/pushDatalayer';
|
|
3
|
+
|
|
4
|
+
import type { CartResponse, DeleteCartRequest } from '../../api/types';
|
|
5
|
+
|
|
6
|
+
export function removeFromCartAction(
|
|
7
|
+
deletePayload: DeleteCartRequest,
|
|
8
|
+
cartPayload: CartResponse,
|
|
9
|
+
oldCartResponse?: CartResponse,
|
|
10
|
+
) {
|
|
11
|
+
if (!cartPayload.orders.length) {
|
|
12
|
+
pushDatalayer({
|
|
13
|
+
event: 'remove_from_cart',
|
|
14
|
+
ecommerce: {
|
|
15
|
+
currency: 'BRL',
|
|
16
|
+
value: 0,
|
|
17
|
+
items: [
|
|
18
|
+
{
|
|
19
|
+
coupon: cartPayload.discountMap.coupon?.discountMainCode || '',
|
|
20
|
+
item_category: '',
|
|
21
|
+
item_brand: `${oldCartResponse!.orders[0].items[0].product.brandId}`,
|
|
22
|
+
item_id: oldCartResponse!.orders[0].items[0].product.productId,
|
|
23
|
+
item_name: oldCartResponse!.orders[0].items[0].product.name,
|
|
24
|
+
item_variant: getVariant(oldCartResponse!.orders[0].items[0]),
|
|
25
|
+
price: oldCartResponse!.orders[0].items[0].unitValue,
|
|
26
|
+
quantity: 1,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
pushDatalayer({
|
|
34
|
+
event: 'remove_from_cart',
|
|
35
|
+
ecommerce: {
|
|
36
|
+
currency: 'BRL',
|
|
37
|
+
value: totalValue(cartPayload, deletePayload),
|
|
38
|
+
items: getAddedCartItems(cartPayload, deletePayload).map(item => {
|
|
39
|
+
return {
|
|
40
|
+
coupon: cartPayload.discountMap.coupon?.discountMainCode || '',
|
|
41
|
+
item_category: '',
|
|
42
|
+
item_brand: `${item.product.brandId}`,
|
|
43
|
+
item_id: item.product.productId,
|
|
44
|
+
item_name: item.product.name,
|
|
45
|
+
item_variant: getVariant(item),
|
|
46
|
+
price: item.unitValue,
|
|
47
|
+
quantity: item.quantity,
|
|
48
|
+
};
|
|
49
|
+
}),
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { getVariant } from '../../utils/cart';
|
|
2
|
+
import { pushDatalayer } from '../../utils/pushDatalayer';
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
Search,
|
|
6
|
+
Showcase,
|
|
7
|
+
UrlBrand,
|
|
8
|
+
UrlListing,
|
|
9
|
+
} from '../../api/types';
|
|
10
|
+
|
|
11
|
+
export function selectItemAction(
|
|
12
|
+
page: UrlBrand | UrlListing | Showcase | Search,
|
|
13
|
+
productIndex: number,
|
|
14
|
+
) {
|
|
15
|
+
if ('type' in page) {
|
|
16
|
+
const product = page.content.registers[productIndex];
|
|
17
|
+
pushDatalayer({
|
|
18
|
+
event: 'select_item',
|
|
19
|
+
ecommerce: {
|
|
20
|
+
item_list_id: page.type === 'search' ? 'Search' : page.entity.name,
|
|
21
|
+
item_list_name: page.type === 'search' ? 'Search' : page.entity.name,
|
|
22
|
+
currency: 'BRL',
|
|
23
|
+
items: [
|
|
24
|
+
{
|
|
25
|
+
item_id: product.id,
|
|
26
|
+
item_name: product.name,
|
|
27
|
+
item_list_id: page.type === 'search' ? 'Search' : page.entity.name,
|
|
28
|
+
item_list_name:
|
|
29
|
+
page.type === 'search' ? 'Search' : page.entity.name,
|
|
30
|
+
item_brand: product.brand?.name || '',
|
|
31
|
+
item_variant: getVariant(product),
|
|
32
|
+
item_category: product.mainCategory?.name || '',
|
|
33
|
+
price: product.price?.salePrice || 0,
|
|
34
|
+
index: productIndex + 1,
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const product = page.products[productIndex];
|
|
43
|
+
pushDatalayer({
|
|
44
|
+
event: 'select_item',
|
|
45
|
+
ecommerce: {
|
|
46
|
+
item_list_id: page.name,
|
|
47
|
+
item_list_name: page.name,
|
|
48
|
+
currency: 'BRL',
|
|
49
|
+
items: [
|
|
50
|
+
{
|
|
51
|
+
item_id: product.id,
|
|
52
|
+
item_name: product.name,
|
|
53
|
+
item_list_id: page.name,
|
|
54
|
+
item_list_name: page.name,
|
|
55
|
+
item_brand: product.brand?.name || '',
|
|
56
|
+
item_variant: getVariant(product),
|
|
57
|
+
item_category: product.mainCategory?.name || '',
|
|
58
|
+
price: product.price?.salePrice || 0,
|
|
59
|
+
index: productIndex + 1,
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { pushDatalayer } from '../../utils/pushDatalayer';
|
|
2
|
+
|
|
3
|
+
import type { BannerItem } from '../../types';
|
|
4
|
+
import type { Banner } from '../../api/types';
|
|
5
|
+
|
|
6
|
+
export function selectPromotionAction<AdditionalParameters>(
|
|
7
|
+
banner: Banner<AdditionalParameters>,
|
|
8
|
+
index: number,
|
|
9
|
+
) {
|
|
10
|
+
pushDatalayer({
|
|
11
|
+
event: 'select_promotion',
|
|
12
|
+
ecommerce: {
|
|
13
|
+
items: [
|
|
14
|
+
{
|
|
15
|
+
promotion_id: banner.id,
|
|
16
|
+
promotion_name: 'Banners' as BannerItem['promotion_name'],
|
|
17
|
+
creative_name: `${banner.scheduling?.startDate.slice(0, 10)}-${banner.name.replaceAll(' ', '-')}`,
|
|
18
|
+
creative_slot: index + 1,
|
|
19
|
+
index: index + 1,
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { getAddedCartItems, getVariant, totalValue } from '../../utils/cart';
|
|
2
|
+
import { pushDatalayer } from '../../utils/pushDatalayer';
|
|
3
|
+
|
|
4
|
+
import type { UpsertTrackingCartRequest } from '../../types';
|
|
5
|
+
import type { CartResponse } from '../../api/types';
|
|
6
|
+
|
|
7
|
+
export function upsertToCartAction(
|
|
8
|
+
upsertPayload: UpsertTrackingCartRequest,
|
|
9
|
+
cartPayload: CartResponse,
|
|
10
|
+
) {
|
|
11
|
+
if (!getAddedCartItems(cartPayload, upsertPayload).length) return;
|
|
12
|
+
|
|
13
|
+
if (
|
|
14
|
+
upsertPayload.items.some(item => (item.oldQuantity || 0) > item.quantity!)
|
|
15
|
+
) {
|
|
16
|
+
pushDatalayer({
|
|
17
|
+
event: 'remove_from_cart',
|
|
18
|
+
ecommerce: {
|
|
19
|
+
currency: 'BRL',
|
|
20
|
+
value: totalValue(cartPayload, upsertPayload),
|
|
21
|
+
items: getAddedCartItems(cartPayload, upsertPayload).map(item => {
|
|
22
|
+
return {
|
|
23
|
+
item_category: '',
|
|
24
|
+
item_list_name: '',
|
|
25
|
+
item_brand: `${item.product.brandId}`,
|
|
26
|
+
item_id: item.product.productId,
|
|
27
|
+
coupon: cartPayload.discountMap.coupon?.discountMainCode || '',
|
|
28
|
+
item_name: item.product.name,
|
|
29
|
+
item_variant: getVariant(item),
|
|
30
|
+
price: item.unitValue,
|
|
31
|
+
quantity: item.oldQuantity! - item.quantity,
|
|
32
|
+
};
|
|
33
|
+
}),
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
pushDatalayer({
|
|
41
|
+
event: 'add_to_cart',
|
|
42
|
+
ecommerce: {
|
|
43
|
+
currency: 'BRL',
|
|
44
|
+
value: totalValue(cartPayload, upsertPayload),
|
|
45
|
+
items: getAddedCartItems(cartPayload, upsertPayload).map(item => {
|
|
46
|
+
return {
|
|
47
|
+
item_category: '',
|
|
48
|
+
item_list_name: '',
|
|
49
|
+
item_brand: `${item.product.brandId}`,
|
|
50
|
+
item_id: item.product.productId,
|
|
51
|
+
coupon: cartPayload.discountMap.coupon?.discountMainCode || '',
|
|
52
|
+
item_name: item.product.name,
|
|
53
|
+
item_variant: getVariant(item),
|
|
54
|
+
price: item.unitValue,
|
|
55
|
+
quantity: item.oldQuantity
|
|
56
|
+
? item.quantity - item.oldQuantity
|
|
57
|
+
: item.quantity,
|
|
58
|
+
};
|
|
59
|
+
}),
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { getAddedCartItems, getVariant, totalValue } from '../../utils/cart';
|
|
2
|
+
import { pushDatalayer } from '../../utils/pushDatalayer';
|
|
3
|
+
|
|
4
|
+
import type { CartResponse } from '../../api/types';
|
|
5
|
+
|
|
6
|
+
export function viewCart(cartPayload: CartResponse) {
|
|
7
|
+
pushDatalayer({
|
|
8
|
+
event: 'view_cart',
|
|
9
|
+
ecommerce: {
|
|
10
|
+
currency: 'BRL',
|
|
11
|
+
value: totalValue(cartPayload),
|
|
12
|
+
coupon: cartPayload.discountMap.coupon?.discountMainCode || '',
|
|
13
|
+
items: getAddedCartItems(cartPayload).map(item => {
|
|
14
|
+
return {
|
|
15
|
+
coupon: cartPayload.discountMap.coupon?.discountMainCode || '',
|
|
16
|
+
item_category: '',
|
|
17
|
+
item_list_name: '',
|
|
18
|
+
item_brand: `${item.product.brandId}`,
|
|
19
|
+
item_id: item.product.productId,
|
|
20
|
+
item_name: item.product.name,
|
|
21
|
+
item_variant: getVariant(item),
|
|
22
|
+
price: item.unitValue,
|
|
23
|
+
quantity: item.quantity,
|
|
24
|
+
};
|
|
25
|
+
}),
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { getVariant } from '../../utils/cart';
|
|
2
|
+
import { pushDatalayer } from '../../utils/pushDatalayer';
|
|
3
|
+
|
|
4
|
+
import type { Product } from '../../api/types';
|
|
5
|
+
|
|
6
|
+
export function viewItem(product: Product) {
|
|
7
|
+
pushDatalayer({
|
|
8
|
+
event: 'view_item',
|
|
9
|
+
google_tag_params: {
|
|
10
|
+
ecomm_category: '',
|
|
11
|
+
ecomm_prodid: product.id,
|
|
12
|
+
ecomm_pagetype: 'product',
|
|
13
|
+
ecomm_totalvalue: product.price?.salePrice || 0,
|
|
14
|
+
},
|
|
15
|
+
ecommerce: {
|
|
16
|
+
currency: 'BRL',
|
|
17
|
+
items: [
|
|
18
|
+
{
|
|
19
|
+
coupon: '',
|
|
20
|
+
item_brand: product.brand?.name || '',
|
|
21
|
+
item_category: product.mainCategory?.name || '',
|
|
22
|
+
item_id: product.id,
|
|
23
|
+
item_name: product.name,
|
|
24
|
+
item_variant: getVariant(product),
|
|
25
|
+
price: product.price?.salePrice || 0,
|
|
26
|
+
quantity: 1,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
}
|