@lookiero/checkout 0.8.23 → 0.8.25

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.
Files changed (36) hide show
  1. package/dist/infrastructure/ui/components/layouts/tabs/Tabs.js +5 -5
  2. package/dist/infrastructure/ui/views/checkout/Checkout.js +2 -2
  3. package/dist/infrastructure/ui/views/feedback/Feedback.js +2 -2
  4. package/dist/infrastructure/ui/views/item/Item.js +82 -19
  5. package/dist/infrastructure/ui/views/item/components/productVariantSlider/ProductVariantSlider.d.ts +1 -0
  6. package/dist/infrastructure/ui/views/item/components/productVariantSlider/ProductVariantSlider.js +5 -2
  7. package/dist/infrastructure/ui/views/notFound/NotFound.js +2 -2
  8. package/dist/infrastructure/ui/views/summary/Summary.js +41 -6
  9. package/dist/infrastructure/ui/views/summary/components/checkoutItemsTabs/CheckoutItemsTabs.d.ts +1 -0
  10. package/dist/infrastructure/ui/views/summary/components/checkoutItemsTabs/CheckoutItemsTabs.js +2 -2
  11. package/dist/shared/tracking/infrastructure/useTrackImageView.d.ts +21 -0
  12. package/dist/shared/tracking/infrastructure/useTrackImageView.js +25 -0
  13. package/dist/shared/tracking/infrastructure/useTrackItemPageView.d.ts +16 -0
  14. package/dist/shared/tracking/infrastructure/useTrackItemPageView.js +25 -0
  15. package/dist/shared/tracking/infrastructure/useTrackKeepItem.d.ts +16 -0
  16. package/dist/shared/tracking/infrastructure/useTrackKeepItem.js +23 -0
  17. package/dist/shared/tracking/infrastructure/useTrackPageView.d.ts +12 -0
  18. package/dist/shared/tracking/infrastructure/{usePageView.js → useTrackPageView.js} +4 -10
  19. package/dist/shared/tracking/infrastructure/useTrackPressContinue.d.ts +15 -0
  20. package/dist/shared/tracking/infrastructure/useTrackPressContinue.js +22 -0
  21. package/dist/shared/tracking/infrastructure/useTrackPressItem.d.ts +18 -0
  22. package/dist/shared/tracking/infrastructure/useTrackPressItem.js +23 -0
  23. package/dist/shared/tracking/infrastructure/useTrackPressPricing.d.ts +18 -0
  24. package/dist/shared/tracking/infrastructure/useTrackPressPricing.js +23 -0
  25. package/dist/shared/tracking/infrastructure/useTrackReplaceItem.d.ts +20 -0
  26. package/dist/shared/tracking/infrastructure/useTrackReplaceItem.js +25 -0
  27. package/dist/shared/tracking/infrastructure/useTrackResetItem.d.ts +16 -0
  28. package/dist/shared/tracking/infrastructure/useTrackResetItem.js +23 -0
  29. package/dist/shared/tracking/infrastructure/useTrackReturnItem.d.ts +16 -0
  30. package/dist/shared/tracking/infrastructure/useTrackReturnItem.js +23 -0
  31. package/dist/shared/tracking/infrastructure/useTrackTabView.d.ts +15 -0
  32. package/dist/shared/tracking/infrastructure/useTrackTabView.js +23 -0
  33. package/dist/shared/tracking/tracking.d.ts +47 -4
  34. package/dist/shared/tracking/tracking.js +9 -0
  35. package/package.json +1 -1
  36. package/dist/shared/tracking/infrastructure/usePageView.d.ts +0 -13
@@ -1,6 +1,6 @@
1
1
  import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
2
2
  import { animated, useSpring } from "@react-spring/native";
3
- import React, { Children, useCallback, useState } from "react";
3
+ import React, { Children, useCallback, useEffect, useState } from "react";
4
4
  import { Pressable, View } from "react-native";
5
5
  import invariant from "tiny-invariant";
6
6
  import { Slider } from "../../../../../shared/ui/components/layouts/slider/Slider";
@@ -35,10 +35,10 @@ const TabList = ({ labels = [], tabIndex = 0, style: customStyle, onSelect }) =>
35
35
  const Tabs = ({ children, defaultIndex = 0, tabLabels, style: customStyle, onChanged, tabLabelsWrapper = (children) => children, }) => {
36
36
  invariant(Children.count(children) === tabLabels.length, "Children and tab labels must be the same length");
37
37
  const [active, setActive] = useState(defaultIndex);
38
- const handleOnActiveChanged = useCallback((activeIndex) => {
39
- setActive(activeIndex);
40
- onChanged?.(activeIndex);
41
- }, [onChanged]);
38
+ const handleOnActiveChanged = useCallback((activeIndex) => setActive(activeIndex), []);
39
+ useEffect(() => {
40
+ onChanged?.(active);
41
+ }, [active, onChanged]);
42
42
  return (React.createElement(View, { style: [style.container, customStyle?.tabContainer], testID: "tabs" },
43
43
  tabLabelsWrapper(React.createElement(TabList, { labels: tabLabels, style: customStyle?.tabList, tabIndex: active, onSelect: handleOnActiveChanged })),
44
44
  React.createElement(View, { style: customStyle?.sliderContainer },
@@ -5,7 +5,7 @@ import React, { useCallback, useMemo } from "react";
5
5
  import { Platform, View } from "react-native";
6
6
  import { useNavigate } from "react-router-native";
7
7
  import { CheckoutItemStatus } from "../../../../domain/checkoutItem/model/checkoutItem";
8
- import { usePageView } from "../../../../shared/tracking/infrastructure/usePageView";
8
+ import { useTrackPageView } from "../../../../shared/tracking/infrastructure/useTrackPageView";
9
9
  import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
10
10
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
11
11
  import { useViewPricingByCheckoutId } from "../../../projection/pricing/react/useViewPricingByCheckoutId";
@@ -25,7 +25,7 @@ const Checkout = ({ children, customerId, country, useRedirect }) => {
25
25
  const titleText = useI18nMessage({ id: I18nMessages.CHECKOUT_TITLE });
26
26
  const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
27
27
  const [pricing, pricingStatus] = useViewPricingByCheckoutId({ checkoutId: checkout?.id });
28
- usePageView({
28
+ useTrackPageView({
29
29
  page: TrackingPage.CHECKOUT,
30
30
  country,
31
31
  checkoutId: checkout?.id,
@@ -2,7 +2,7 @@ import { CommandStatus, QueryStatus } from "@lookiero/messaging-react";
2
2
  import React, { useCallback, useEffect, useRef } from "react";
3
3
  import { Platform } from "react-native";
4
4
  import { useLogger } from "../../../../shared/logging/useLogger";
5
- import { usePageView } from "../../../../shared/tracking/infrastructure/usePageView";
5
+ import { useTrackPageView } from "../../../../shared/tracking/infrastructure/useTrackPageView";
6
6
  import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
7
7
  import { useGiveCheckoutFeedback } from "../../../domain/checkoutFeedback/react/useGiveCheckoutFeedback";
8
8
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
@@ -32,7 +32,7 @@ const Feedback = ({ customerId, country }) => {
32
32
  }
33
33
  catch (e) { }
34
34
  }, [giveCheckoutFeedback]);
35
- usePageView({
35
+ useTrackPageView({
36
36
  page: TrackingPage.FEEDBACK,
37
37
  country,
38
38
  checkoutId: checkout?.id,
@@ -5,7 +5,12 @@ import { useParams } from "react-router-native";
5
5
  import { CheckoutItemStatus } from "../../../../domain/checkoutItem/model/checkoutItem";
6
6
  import "../../../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
7
7
  import { useLogger } from "../../../../shared/logging/useLogger";
8
- import { usePageView } from "../../../../shared/tracking/infrastructure/usePageView";
8
+ import { useTrackImageView } from "../../../../shared/tracking/infrastructure/useTrackImageView";
9
+ import { useTrackItemPageView } from "../../../../shared/tracking/infrastructure/useTrackItemPageView";
10
+ import { useTrackKeepItem } from "../../../../shared/tracking/infrastructure/useTrackKeepItem";
11
+ import { useTrackReplaceItem } from "../../../../shared/tracking/infrastructure/useTrackReplaceItem";
12
+ import { useTrackResetItem } from "../../../../shared/tracking/infrastructure/useTrackResetItem";
13
+ import { useTrackReturnItem } from "../../../../shared/tracking/infrastructure/useTrackReturnItem";
9
14
  import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
10
15
  import { useBookCheckoutBookingForCheckoutItem } from "../../../domain/checkoutBooking/react/useBookCheckoutBookingForCheckoutItem";
11
16
  import { useKeepCheckoutItem } from "../../../domain/checkoutItem/react/useKeepCheckoutItem";
@@ -39,12 +44,69 @@ const Item = ({ customerId, country }) => {
39
44
  checkoutId: checkout?.id,
40
45
  });
41
46
  const checkoutItem = checkout?.items.find((checkoutItem) => checkoutItem.id === id);
42
- usePageView({
47
+ const [bookedProductsVariants] = useViewBookedProductsVariantsForCheckoutItem({
48
+ checkoutItemId: checkoutItem.id,
49
+ });
50
+ const [bookCheckoutBooking] = useBookCheckoutBookingForCheckoutItem({
51
+ checkoutItemId: checkoutItem.id,
52
+ checkoutBookingId: checkout?.checkoutBookingId,
53
+ logger,
54
+ });
55
+ const isBookingRequired = bookedProductsVariants === null && isSizeChangeEnabled;
56
+ useEffect(() => {
57
+ isBookingRequired && bookCheckoutBooking();
58
+ }, [bookCheckoutBooking, isBookingRequired]);
59
+ const replaceableFor = useMemo(() => sizeChangeEnabledStatus === QueryStatus.SUCCESS
60
+ ? isSizeChangeEnabled
61
+ ? bookedProductsVariants
62
+ ? bookedProductsVariants?.productVariants.map(({ id }) => id)
63
+ : undefined
64
+ : []
65
+ : undefined, [bookedProductsVariants, isSizeChangeEnabled, sizeChangeEnabledStatus]);
66
+ useTrackItemPageView({
43
67
  page: TrackingPage.ITEM,
44
68
  country,
45
69
  checkoutId: checkout?.id,
46
70
  checkoutItemId: checkoutItem.id,
71
+ productVariantId: checkoutItem.productVariant.id,
72
+ replaceableFor,
73
+ unique: checkoutItem.productVariant.size.unique,
47
74
  });
75
+ const trackKeepItem = useTrackKeepItem({
76
+ page: TrackingPage.ITEM,
77
+ country,
78
+ checkoutId: checkout?.id,
79
+ checkoutItemId: checkoutItem.id,
80
+ });
81
+ const trackReturnItem = useTrackReturnItem({
82
+ page: TrackingPage.ITEM,
83
+ country,
84
+ checkoutId: checkout?.id,
85
+ checkoutItemId: checkoutItem.id,
86
+ });
87
+ const trackReplaceItem = useTrackReplaceItem({
88
+ page: TrackingPage.ITEM,
89
+ country,
90
+ checkoutId: checkout?.id,
91
+ checkoutItemId: checkoutItem.id,
92
+ productVariantId: checkoutItem.productVariant.id,
93
+ });
94
+ const trackResetItem = useTrackResetItem({
95
+ page: TrackingPage.ITEM,
96
+ country,
97
+ checkoutId: checkout?.id,
98
+ checkoutItemId: checkoutItem.id,
99
+ });
100
+ const trackImageView = useTrackImageView({
101
+ page: TrackingPage.ITEM,
102
+ country,
103
+ checkoutId: checkout?.id,
104
+ checkoutItemId: checkoutItem.id,
105
+ productVariantId: checkoutItem.productVariant.id,
106
+ });
107
+ useEffect(() => trackImageView({
108
+ perspective: checkoutItem.productVariant.media[0]?.perspective,
109
+ }), [checkoutItem.productVariant.media, trackImageView]);
48
110
  const customerDecissionMade = checkoutItem.status !== CheckoutItemStatus.INITIAL;
49
111
  const [resetCheckoutItem, resetCheckoutItemStatus] = useResetCheckoutItem({
50
112
  checkoutItemId: checkoutItem.id,
@@ -62,18 +124,6 @@ const Item = ({ customerId, country }) => {
62
124
  const [sizeWithoutStockModalVisible, setSizeWithoutStockModalVisible] = useState(false);
63
125
  const handleOnShowSizeWithoutStockModal = useCallback(() => setSizeWithoutStockModalVisible(true), []);
64
126
  const handleOnHideSizeWithoutStockModal = useCallback(() => setSizeWithoutStockModalVisible(false), []);
65
- const [bookedProductsVariants] = useViewBookedProductsVariantsForCheckoutItem({
66
- checkoutItemId: checkoutItem.id,
67
- });
68
- const [bookCheckoutBooking] = useBookCheckoutBookingForCheckoutItem({
69
- checkoutItemId: checkoutItem.id,
70
- checkoutBookingId: checkout?.checkoutBookingId,
71
- logger,
72
- });
73
- const isBookingRequired = bookedProductsVariants === null && isSizeChangeEnabled;
74
- useEffect(() => {
75
- isBookingRequired && bookCheckoutBooking();
76
- }, [bookCheckoutBooking, isBookingRequired]);
77
127
  const [returnQuestions, returnQuestionsStatus] = useListReturnQuestionsByCheckoutItemId({
78
128
  checkoutItemId: checkoutItem.id,
79
129
  });
@@ -86,9 +136,22 @@ const Item = ({ customerId, country }) => {
86
136
  const handleOnSubmit = useCallback((feedbacks) => {
87
137
  handleOnHideReturnQuestions();
88
138
  returnCheckoutItem({ feedbacks });
89
- }, [handleOnHideReturnQuestions, returnCheckoutItem]);
90
- const handleOnReplace = useCallback((replacedForId) => replaceCheckoutItem({ replacedForId }), [replaceCheckoutItem]);
139
+ trackReturnItem();
140
+ }, [handleOnHideReturnQuestions, returnCheckoutItem, trackReturnItem]);
141
+ const handleOnReplace = useCallback((replacedForId) => {
142
+ replaceCheckoutItem({ replacedForId });
143
+ trackReplaceItem({ replaceFor: replacedForId });
144
+ }, [replaceCheckoutItem, trackReplaceItem]);
91
145
  const handleOnReturn = useCallback(() => handleOnShowReturnQuestions(), [handleOnShowReturnQuestions]);
146
+ const handleOnKeep = useCallback(() => {
147
+ keepCheckoutItem();
148
+ trackKeepItem();
149
+ }, [keepCheckoutItem, trackKeepItem]);
150
+ const handleOnPressCustomerDecissionBanner = useCallback(() => {
151
+ resetCheckoutItem();
152
+ trackResetItem();
153
+ }, [resetCheckoutItem, trackResetItem]);
154
+ const handleOnChangedProductVariantSlider = useCallback((active) => trackImageView({ perspective: checkoutItem.productVariant.media[active]?.perspective }), [checkoutItem.productVariant.media, trackImageView]);
92
155
  const productVariantSelected = useMemo(() => checkoutItem.status === CheckoutItemStatus.REPLACED && checkoutItem.replacedFor
93
156
  ? { id: checkoutItem.replacedFor.id, size: checkoutItem.replacedFor.size }
94
157
  : { id: checkoutItem.productVariant.id, size: checkoutItem.productVariant.size }, [checkoutItem.productVariant.id, checkoutItem.productVariant.size, checkoutItem.replacedFor, checkoutItem.status]);
@@ -104,12 +167,12 @@ const Item = ({ customerId, country }) => {
104
167
  const { media, brand, name, color } = checkoutItem.productVariant;
105
168
  return (React.createElement(ReturnQuestionFeedbackProvider, { feedback: checkoutItem.feedbacks || {} },
106
169
  React.createElement(SizeWithoutStockModal, { visible: sizeWithoutStockModalVisible, onDismiss: handleOnHideSizeWithoutStockModal }),
107
- React.createElement(SafeAreaScrollView, { scrollerPaddingTop: Platform.OS === "web" || Platform.OS === "android" ? HEADER_HEIGHT : 0, footer: !customerDecissionMade && (React.createElement(ItemActions, { country: country, keepButtonLoading: keepCheckoutItemStatus === CommandStatus.LOADING, productVariantSelected: productVariantSelected, productVariants: bookedProductsVariants?.productVariants, returnButtonLoading: returnCheckoutItemStatus === CommandStatus.LOADING, sizeSelectorDisabled: replaceCheckoutItemStatus === CommandStatus.LOADING, onKeep: keepCheckoutItem, onLayout: handleOnStickyLayout, onReplace: handleOnReplace, onReturn: handleOnReturn, onSizeSelectorPress: handleOnShowSizeWithoutStockModal })) },
170
+ React.createElement(SafeAreaScrollView, { scrollerPaddingTop: Platform.OS === "web" || Platform.OS === "android" ? HEADER_HEIGHT : 0, footer: !customerDecissionMade && (React.createElement(ItemActions, { country: country, keepButtonLoading: keepCheckoutItemStatus === CommandStatus.LOADING, productVariantSelected: productVariantSelected, productVariants: bookedProductsVariants?.productVariants, returnButtonLoading: returnCheckoutItemStatus === CommandStatus.LOADING, sizeSelectorDisabled: replaceCheckoutItemStatus === CommandStatus.LOADING, onKeep: handleOnKeep, onLayout: handleOnStickyLayout, onReplace: handleOnReplace, onReturn: handleOnReturn, onSizeSelectorPress: handleOnShowSizeWithoutStockModal })) },
108
171
  React.createElement(Body, null,
109
- customerDecissionMade && (React.createElement(CustomerDecissionBanner, { changingDecission: resetCheckoutItemStatus === CommandStatus.LOADING, checkoutItemStatus: checkoutItem.status, onPress: resetCheckoutItem })),
172
+ customerDecissionMade && (React.createElement(CustomerDecissionBanner, { changingDecission: resetCheckoutItemStatus === CommandStatus.LOADING, checkoutItemStatus: checkoutItem.status, onPress: handleOnPressCustomerDecissionBanner })),
110
173
  React.createElement(View, { style: [style.content, { paddingBottom: Platform.OS === "web" ? spaceXL : stickyHeight }] },
111
174
  React.createElement(View, { style: style.sliderContainer },
112
- React.createElement(ProductVariantSlider, { producVariantMedia: media })),
175
+ React.createElement(ProductVariantSlider, { producVariantMedia: media, onChanged: handleOnChangedProductVariantSlider })),
113
176
  React.createElement(ProductVariantDescription, { brand: brand, color: color, country: country, name: name, price: price, size: productVariantSelected.size }),
114
177
  checkoutItem.status === CheckoutItemStatus.RETURNED && (React.createElement(View, { style: style.feedbackContainer },
115
178
  React.createElement(ReturnQuestionsFeedback, { returnQuestions: returnQuestions || [], onEditFeedback: handleOnEditFeedback })))))),
@@ -2,6 +2,7 @@ import { FC } from "react";
2
2
  import { MediaProjection } from "../../../../../../projection/checkoutItem/checkoutItem";
3
3
  interface ProductVariantSlider {
4
4
  readonly producVariantMedia: MediaProjection[];
5
+ readonly onChanged?: (active: number) => void;
5
6
  }
6
7
  declare const ProductVariantSlider: FC<ProductVariantSlider>;
7
8
  export { ProductVariantSlider };
@@ -3,10 +3,13 @@ import { Image } from "react-native";
3
3
  import { Slider } from "../../../../../../shared/ui/components/layouts/slider/Slider";
4
4
  import { useMediaImage } from "../../../../hooks/useMediaImage";
5
5
  import { style } from "./ProductVariantSlider.style";
6
- const ProductVariantSlider = ({ producVariantMedia }) => {
6
+ const ProductVariantSlider = ({ producVariantMedia, onChanged }) => {
7
7
  const cdnImageUrl = useMediaImage();
8
8
  const [active, setActive] = useState(0);
9
- const handleOnActiveChanged = useCallback((activeIndex) => setActive(activeIndex), []);
9
+ const handleOnActiveChanged = useCallback((activeIndex) => {
10
+ setActive(activeIndex);
11
+ onChanged?.(activeIndex);
12
+ }, [onChanged]);
10
13
  return (React.createElement(Slider, { active: active, paginationActiveItemStyle: style.paginationActiveItemStyle, paginationItemStyle: style.paginationItemStyle, paginationStyle: style.paginationStyle, paginationRenderItem: (index) => (React.createElement(Image, { key: producVariantMedia[index]?.perspective, resizeMode: "contain", style: style.paginationImage, testID: "product-variant-pagination-image", source: {
11
14
  uri: cdnImageUrl({
12
15
  url: producVariantMedia[index]?.url,
@@ -5,7 +5,7 @@ import { QueryStatus } from "@lookiero/messaging-react";
5
5
  import React, { useCallback } from "react";
6
6
  import { Image, Platform } from "react-native";
7
7
  import { useNavigate } from "react-router-native";
8
- import { usePageView } from "../../../../shared/tracking/infrastructure/usePageView";
8
+ import { useTrackPageView } from "../../../../shared/tracking/infrastructure/useTrackPageView";
9
9
  import { AspectRatioView } from "../../../../shared/ui/components/atoms/aspectRatioView/AspectRatioView";
10
10
  import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
11
11
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
@@ -21,7 +21,7 @@ const NotFound = ({ customerId, country }) => {
21
21
  const descriptionText = useI18nMessage({ id: I18nMessages.NOT_FOUND_DESCRIPTION });
22
22
  const buttonText = useI18nMessage({ id: I18nMessages.NOT_FOUND_BUTTON });
23
23
  const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
24
- usePageView({
24
+ useTrackPageView({
25
25
  page: TrackingPage.NOT_FOUND,
26
26
  country,
27
27
  checkoutId: checkout?.id,
@@ -5,7 +5,11 @@ import React, { useCallback, useMemo, useState } from "react";
5
5
  import { Platform, View } from "react-native";
6
6
  import { generatePath, useNavigate } from "react-router-native";
7
7
  import { CheckoutItemStatus } from "../../../../domain/checkoutItem/model/checkoutItem";
8
- import { usePageView } from "../../../../shared/tracking/infrastructure/usePageView";
8
+ import { useTrackPageView } from "../../../../shared/tracking/infrastructure/useTrackPageView";
9
+ import { useTrackPressContinue } from "../../../../shared/tracking/infrastructure/useTrackPressContinue";
10
+ import { useTrackPressItem } from "../../../../shared/tracking/infrastructure/useTrackPressItem";
11
+ import { useTrackPressPricing } from "../../../../shared/tracking/infrastructure/useTrackPressPricing";
12
+ import { useTrackTabView } from "../../../../shared/tracking/infrastructure/useTrackTabView";
9
13
  import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
10
14
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
11
15
  import { useViewFiveItemsDiscountByCustomerId } from "../../../projection/checkout/react/useViewFiveItemsDiscountByCustomerId";
@@ -31,17 +35,48 @@ const Summary = ({ customerId, country }) => {
31
35
  const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
32
36
  const [pricing, pricingStatus] = useViewPricingByCheckoutId({ checkoutId: checkout?.id });
33
37
  const [fiveItemsDiscount = 0, fiveItemsDiscountStatus] = useViewFiveItemsDiscountByCustomerId({ customerId });
34
- usePageView({
38
+ useTrackPageView({
35
39
  page: TrackingPage.SUMMARY,
36
40
  country,
37
41
  checkoutId: checkout?.id,
38
42
  });
39
43
  const navigate = useNavigate();
40
44
  const basePath = useBasePath();
45
+ const trackPressPricing = useTrackPressPricing({
46
+ page: TrackingPage.SUMMARY,
47
+ country,
48
+ checkoutId: checkout?.id,
49
+ });
41
50
  const [pricingCollapsed, setPricingCollapsed] = useState(true);
42
- const handleOnPressPricing = useCallback(() => setPricingCollapsed(!pricingCollapsed), [pricingCollapsed]);
43
- const handleOnSubmit = useCallback(() => navigate(`${basePath}/${Routes.CHECKOUT}`), [basePath, navigate]);
44
- const handleOnPressItem = useCallback((checkoutItemId) => navigate(`${basePath}/${generatePath(Routes.ITEM_DETAIL, { id: checkoutItemId })}`), [basePath, navigate]);
51
+ const handleOnPressPricing = useCallback(() => {
52
+ const collapsed = !pricingCollapsed;
53
+ setPricingCollapsed(collapsed);
54
+ trackPressPricing({ collapse: collapsed });
55
+ }, [pricingCollapsed, trackPressPricing]);
56
+ const trackPressContinue = useTrackPressContinue({
57
+ page: TrackingPage.SUMMARY,
58
+ country,
59
+ checkoutId: checkout?.id,
60
+ });
61
+ const handleOnSubmit = useCallback(() => {
62
+ trackPressContinue();
63
+ navigate(`${basePath}/${Routes.CHECKOUT}`);
64
+ }, [basePath, navigate, trackPressContinue]);
65
+ const trackPressItem = useTrackPressItem({
66
+ page: TrackingPage.SUMMARY,
67
+ country,
68
+ checkoutId: checkout?.id,
69
+ });
70
+ const handleOnPressItem = useCallback((checkoutItemId) => {
71
+ trackPressItem({ checkoutItemId });
72
+ navigate(`${basePath}/${generatePath(Routes.ITEM_DETAIL, { id: checkoutItemId })}`);
73
+ }, [basePath, navigate, trackPressItem]);
74
+ const trackTabView = useTrackTabView({
75
+ page: TrackingPage.SUMMARY,
76
+ country,
77
+ checkoutId: checkout?.id,
78
+ });
79
+ const handleOnChangedTab = useCallback((active) => trackTabView({ tab: active === 0 ? "keep" : "return" }), [trackTabView]);
45
80
  const checkoutItemsKept = useMemo(() => checkout?.items.filter((checkoutItem) => checkoutItem.status === CheckoutItemStatus.KEPT || checkoutItem.status === CheckoutItemStatus.REPLACED), [checkout?.items]);
46
81
  const checkoutItemsReturned = useMemo(() => checkout?.items.filter((checkoutItem) => checkoutItem.status === CheckoutItemStatus.RETURNED || checkoutItem.status === CheckoutItemStatus.REPLACED), [checkout?.items]);
47
82
  const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
@@ -56,6 +91,6 @@ const Summary = ({ customerId, country }) => {
56
91
  React.createElement(View, { style: style.content },
57
92
  React.createElement(Text, { level: 3, style: style.title, heading: true }, titleText),
58
93
  React.createElement(Text, { level: 3, style: style.description, body: true }, descriptionText)),
59
- React.createElement(CheckoutItemsTabs, { checkoutItemsKept: checkoutItemsKept || [], checkoutItemsReturned: checkoutItemsReturned || [], country: country, onPressItem: handleOnPressItem }))));
94
+ React.createElement(CheckoutItemsTabs, { checkoutItemsKept: checkoutItemsKept || [], checkoutItemsReturned: checkoutItemsReturned || [], country: country, onChanged: handleOnChangedTab, onPressItem: handleOnPressItem }))));
60
95
  };
61
96
  export { Summary };
@@ -6,6 +6,7 @@ interface CheckoutItemsTabsProps {
6
6
  readonly checkoutItemsReturned: CheckoutItemProjection[];
7
7
  readonly country: Country;
8
8
  readonly onPressItem: (checkoutItemId: string) => void;
9
+ readonly onChanged?: (index: number) => void;
9
10
  }
10
11
  declare const CheckoutItemsTabs: FC<CheckoutItemsTabsProps>;
11
12
  export { CheckoutItemsTabs };
@@ -9,13 +9,13 @@ import { ProductVariant } from "../../../item/components/productVariant/ProductV
9
9
  import { style } from "./CheckoutItemsTabs.style";
10
10
  const CheckoutItem = ({ checkoutItemStatus, checkoutItemProductVariant, checkoutItemPrice, country, discarded = false, testID, style: customStyle, onPress, }) => (React.createElement(View, { style: style.checkoutItem, testID: testID },
11
11
  React.createElement(ProductVariant, { brand: checkoutItemProductVariant.brand, color: checkoutItemProductVariant.color, country: country, discarded: discarded, media: checkoutItemProductVariant.media, name: checkoutItemProductVariant.name, price: checkoutItemPrice, size: checkoutItemProductVariant.size, status: checkoutItemStatus, style: customStyle, onPress: onPress })));
12
- const CheckoutItemsTabs = ({ checkoutItemsKept, checkoutItemsReturned, country, onPressItem, }) => {
12
+ const CheckoutItemsTabs = ({ checkoutItemsKept, checkoutItemsReturned, country, onPressItem, onChanged, }) => {
13
13
  const keepTabText = useI18nMessage({ id: I18nMessages.SUMMARY_KEEP_TAB });
14
14
  const returnTabText = useI18nMessage({ id: I18nMessages.SUMMARY_RETURN_TAB });
15
15
  const keepEmptyText = useI18nMessage({ id: I18nMessages.SUMMARY_KEEP_EMPTY });
16
16
  const returnEmptyText = useI18nMessage({ id: I18nMessages.SUMMARY_RETURN_EMPTY });
17
17
  const handleOnPressItem = useCallback((checkoutItemId) => onPressItem(checkoutItemId), [onPressItem]);
18
- return (React.createElement(Tabs, { style: { sliderContainer: style.sliderContainer }, tabLabels: [`${keepTabText} (${checkoutItemsKept.length})`, `${returnTabText} (${checkoutItemsReturned.length})`] },
18
+ return (React.createElement(Tabs, { style: { sliderContainer: style.sliderContainer }, tabLabels: [`${keepTabText} (${checkoutItemsKept.length})`, `${returnTabText} (${checkoutItemsReturned.length})`], onChanged: onChanged },
19
19
  React.createElement(React.Fragment, null, checkoutItemsKept.length === 0 ? (React.createElement(Text, { style: style.emptyText }, keepEmptyText)) : (checkoutItemsKept.map((checkoutItem) => (React.createElement(CheckoutItem, { key: checkoutItem.id, checkoutItemPrice: checkoutItem.price, checkoutItemStatus: checkoutItem.status, country: country, testID: "keep-checkout-item", checkoutItemProductVariant: checkoutItem.status === CheckoutItemStatus.REPLACED && checkoutItem.replacedFor
20
20
  ? checkoutItem.replacedFor
21
21
  : checkoutItem.productVariant, onPress: () => handleOnPressItem(checkoutItem.id) }))))),
@@ -0,0 +1,21 @@
1
+ import { TrackingPage } from "../../../infrastructure/tracking/tracking";
2
+ import { MediaPerspective } from "../../../projection/checkoutItem/checkoutItem";
3
+ import { Country } from "../../../projection/shared/country";
4
+ interface ImageViewFunctionArgs {
5
+ readonly perspective: MediaPerspective;
6
+ }
7
+ interface ImageViewFunction {
8
+ (args: ImageViewFunctionArgs): void;
9
+ }
10
+ interface UseTrackImageViewFunctionArgs {
11
+ readonly page: TrackingPage;
12
+ readonly country: Country;
13
+ readonly checkoutId: string | undefined;
14
+ readonly checkoutItemId: string;
15
+ readonly productVariantId: string;
16
+ }
17
+ interface UseTrackImageViewFunction {
18
+ (agrs: UseTrackImageViewFunctionArgs): ImageViewFunction;
19
+ }
20
+ declare const useTrackImageView: UseTrackImageViewFunction;
21
+ export { useTrackImageView };
@@ -0,0 +1,25 @@
1
+ import { useCallback } from "react";
2
+ import { PROJECT } from "../../../infrastructure/tracking/tracking";
3
+ import { TrackingEvent, TrackingEventCategory } from "../tracking";
4
+ import { useEmitUserEvent } from "./useEmitUserEvent";
5
+ const useTrackImageView = ({ page, country, checkoutId, checkoutItemId, productVariantId, }) => {
6
+ const emitUserEvent = useEmitUserEvent();
7
+ const imageView = useCallback(({ perspective }) => {
8
+ if (!checkoutId) {
9
+ return;
10
+ }
11
+ const imageViewTrackingEvent = {
12
+ event: TrackingEvent.IMAGE_VIEW,
13
+ eventCategory: TrackingEventCategory.NAVIGATION,
14
+ section: `${PROJECT}_${page}`,
15
+ store: country,
16
+ checkoutId,
17
+ checkoutItemId,
18
+ productVariantId,
19
+ perspective,
20
+ };
21
+ emitUserEvent(imageViewTrackingEvent);
22
+ }, [checkoutId, checkoutItemId, country, emitUserEvent, page, productVariantId]);
23
+ return imageView;
24
+ };
25
+ export { useTrackImageView };
@@ -0,0 +1,16 @@
1
+ import { TrackingPage } from "../../../infrastructure/tracking/tracking";
2
+ import { Country } from "../../../projection/shared/country";
3
+ interface UseTrackItemPageViewFunctionArgs {
4
+ readonly page: TrackingPage;
5
+ readonly country: Country;
6
+ readonly checkoutId?: string;
7
+ readonly checkoutItemId: string;
8
+ readonly productVariantId: string;
9
+ readonly replaceableFor: string[] | undefined;
10
+ readonly unique: boolean;
11
+ }
12
+ interface UseTrackItemPageViewFunction {
13
+ (agrs: UseTrackItemPageViewFunctionArgs): void;
14
+ }
15
+ declare const useTrackItemPageView: UseTrackItemPageViewFunction;
16
+ export { useTrackItemPageView };
@@ -0,0 +1,25 @@
1
+ import { useLayoutEffect } from "react";
2
+ import { PROJECT } from "../../../infrastructure/tracking/tracking";
3
+ import { TrackingEvent, TrackingEventCategory } from "../tracking";
4
+ import { useEmitUserEvent } from "./useEmitUserEvent";
5
+ const useTrackItemPageView = ({ page, country, checkoutId, checkoutItemId, productVariantId, replaceableFor, unique, }) => {
6
+ const emitUserEvent = useEmitUserEvent();
7
+ useLayoutEffect(() => {
8
+ if (!(checkoutId && replaceableFor)) {
9
+ return;
10
+ }
11
+ const itemPageViewTrackingEvent = {
12
+ event: TrackingEvent.PAGEVIEW,
13
+ eventCategory: TrackingEventCategory.NAVIGATION,
14
+ section: `${PROJECT}_${page}`,
15
+ store: country,
16
+ checkoutId,
17
+ checkoutItemId,
18
+ productVariantId,
19
+ replaceableFor,
20
+ unique,
21
+ };
22
+ emitUserEvent(itemPageViewTrackingEvent);
23
+ }, [checkoutId, checkoutItemId, country, emitUserEvent, page, productVariantId, replaceableFor, unique]);
24
+ };
25
+ export { useTrackItemPageView };
@@ -0,0 +1,16 @@
1
+ import { TrackingPage } from "../../../infrastructure/tracking/tracking";
2
+ import { Country } from "../../../projection/shared/country";
3
+ interface KeepItemFunction {
4
+ (): void;
5
+ }
6
+ interface UseTrackKeepItemFunctionArgs {
7
+ readonly page: TrackingPage;
8
+ readonly country: Country;
9
+ readonly checkoutId: string | undefined;
10
+ readonly checkoutItemId: string;
11
+ }
12
+ interface UseTrackKeepItemFunction {
13
+ (agrs: UseTrackKeepItemFunctionArgs): KeepItemFunction;
14
+ }
15
+ declare const useTrackKeepItem: UseTrackKeepItemFunction;
16
+ export { useTrackKeepItem };
@@ -0,0 +1,23 @@
1
+ import { useCallback } from "react";
2
+ import { PROJECT } from "../../../infrastructure/tracking/tracking";
3
+ import { TrackingEvent, TrackingEventCategory } from "../tracking";
4
+ import { useEmitUserEvent } from "./useEmitUserEvent";
5
+ const useTrackKeepItem = ({ page, country, checkoutId, checkoutItemId }) => {
6
+ const emitUserEvent = useEmitUserEvent();
7
+ const keepItem = useCallback(() => {
8
+ if (!checkoutId) {
9
+ return;
10
+ }
11
+ const keepItemTrackingEvent = {
12
+ event: TrackingEvent.KEEP_ITEM,
13
+ eventCategory: TrackingEventCategory.NAVIGATION,
14
+ section: `${PROJECT}_${page}`,
15
+ store: country,
16
+ checkoutId,
17
+ checkoutItemId,
18
+ };
19
+ emitUserEvent(keepItemTrackingEvent);
20
+ }, [checkoutId, checkoutItemId, country, emitUserEvent, page]);
21
+ return keepItem;
22
+ };
23
+ export { useTrackKeepItem };
@@ -0,0 +1,12 @@
1
+ import { TrackingPage } from "../../../infrastructure/tracking/tracking";
2
+ import { Country } from "../../../projection/shared/country";
3
+ interface UseTrackPageViewFunctionArgs {
4
+ readonly page: TrackingPage;
5
+ readonly country: Country;
6
+ readonly checkoutId: string | undefined;
7
+ }
8
+ interface UseTrackPageViewFunction {
9
+ (agrs: UseTrackPageViewFunctionArgs): void;
10
+ }
11
+ declare const useTrackPageView: UseTrackPageViewFunction;
12
+ export { useTrackPageView };
@@ -2,26 +2,20 @@ import { useLayoutEffect } from "react";
2
2
  import { PROJECT } from "../../../infrastructure/tracking/tracking";
3
3
  import { TrackingEvent, TrackingEventCategory } from "../tracking";
4
4
  import { useEmitUserEvent } from "./useEmitUserEvent";
5
- const usePageView = ({ page, country, checkoutId, checkoutItemId }) => {
5
+ const useTrackPageView = ({ page, country, checkoutId }) => {
6
6
  const emitUserEvent = useEmitUserEvent();
7
7
  useLayoutEffect(() => {
8
8
  if (!checkoutId) {
9
9
  return;
10
10
  }
11
- const baseTrackingEvent = {
11
+ const pageViewTrackingEvent = {
12
12
  event: TrackingEvent.PAGEVIEW,
13
13
  eventCategory: TrackingEventCategory.NAVIGATION,
14
14
  section: `${PROJECT}_${page}`,
15
15
  store: country,
16
16
  checkoutId,
17
17
  };
18
- const pageViewTrackingEvent = checkoutItemId
19
- ? {
20
- ...baseTrackingEvent,
21
- checkoutItemId,
22
- }
23
- : baseTrackingEvent;
24
18
  emitUserEvent(pageViewTrackingEvent);
25
- }, [checkoutId, checkoutItemId, country, emitUserEvent, page]);
19
+ }, [checkoutId, country, emitUserEvent, page]);
26
20
  };
27
- export { usePageView };
21
+ export { useTrackPageView };
@@ -0,0 +1,15 @@
1
+ import { TrackingPage } from "../../../infrastructure/tracking/tracking";
2
+ import { Country } from "../../../projection/shared/country";
3
+ interface PressContinueFunction {
4
+ (): void;
5
+ }
6
+ interface UseTrackPressContinueFunctionArgs {
7
+ readonly page: TrackingPage;
8
+ readonly country: Country;
9
+ readonly checkoutId: string | undefined;
10
+ }
11
+ interface UseTrackPressContinueFunction {
12
+ (agrs: UseTrackPressContinueFunctionArgs): PressContinueFunction;
13
+ }
14
+ declare const useTrackPressContinue: UseTrackPressContinueFunction;
15
+ export { useTrackPressContinue };
@@ -0,0 +1,22 @@
1
+ import { useCallback } from "react";
2
+ import { PROJECT } from "../../../infrastructure/tracking/tracking";
3
+ import { TrackingEvent, TrackingEventCategory } from "../tracking";
4
+ import { useEmitUserEvent } from "./useEmitUserEvent";
5
+ const useTrackPressContinue = ({ page, country, checkoutId }) => {
6
+ const emitUserEvent = useEmitUserEvent();
7
+ const pressContinue = useCallback(() => {
8
+ if (!checkoutId) {
9
+ return;
10
+ }
11
+ const pressContinueTrackingEvent = {
12
+ event: TrackingEvent.PRESS_CONTINUE,
13
+ eventCategory: TrackingEventCategory.NAVIGATION,
14
+ section: `${PROJECT}_${page}`,
15
+ store: country,
16
+ checkoutId,
17
+ };
18
+ emitUserEvent(pressContinueTrackingEvent);
19
+ }, [checkoutId, country, emitUserEvent, page]);
20
+ return pressContinue;
21
+ };
22
+ export { useTrackPressContinue };
@@ -0,0 +1,18 @@
1
+ import { TrackingPage } from "../../../infrastructure/tracking/tracking";
2
+ import { Country } from "../../../projection/shared/country";
3
+ interface PressItemFunctionArgs {
4
+ readonly checkoutItemId: string;
5
+ }
6
+ interface PressItemFunction {
7
+ (args: PressItemFunctionArgs): void;
8
+ }
9
+ interface UseTrackPressItemFunctionArgs {
10
+ readonly page: TrackingPage;
11
+ readonly country: Country;
12
+ readonly checkoutId: string | undefined;
13
+ }
14
+ interface UseTrackPressItemFunction {
15
+ (agrs: UseTrackPressItemFunctionArgs): PressItemFunction;
16
+ }
17
+ declare const useTrackPressItem: UseTrackPressItemFunction;
18
+ export { useTrackPressItem };
@@ -0,0 +1,23 @@
1
+ import { useCallback } from "react";
2
+ import { PROJECT } from "../../../infrastructure/tracking/tracking";
3
+ import { TrackingEvent, TrackingEventCategory } from "../tracking";
4
+ import { useEmitUserEvent } from "./useEmitUserEvent";
5
+ const useTrackPressItem = ({ page, country, checkoutId }) => {
6
+ const emitUserEvent = useEmitUserEvent();
7
+ const pressItem = useCallback(({ checkoutItemId }) => {
8
+ if (!checkoutId) {
9
+ return;
10
+ }
11
+ const pressItemTrackingEvent = {
12
+ event: TrackingEvent.PRESS_ITEM,
13
+ eventCategory: TrackingEventCategory.NAVIGATION,
14
+ section: `${PROJECT}_${page}`,
15
+ store: country,
16
+ checkoutId,
17
+ checkoutItemId,
18
+ };
19
+ emitUserEvent(pressItemTrackingEvent);
20
+ }, [checkoutId, country, emitUserEvent, page]);
21
+ return pressItem;
22
+ };
23
+ export { useTrackPressItem };
@@ -0,0 +1,18 @@
1
+ import { TrackingPage } from "../../../infrastructure/tracking/tracking";
2
+ import { Country } from "../../../projection/shared/country";
3
+ interface PressPricingFunctionArgs {
4
+ readonly collapse: boolean;
5
+ }
6
+ interface PressPricingFunction {
7
+ (args: PressPricingFunctionArgs): void;
8
+ }
9
+ interface UseTrackPressPricingFunctionArgs {
10
+ readonly page: TrackingPage;
11
+ readonly country: Country;
12
+ readonly checkoutId: string | undefined;
13
+ }
14
+ interface UseTrackPressPricingFunction {
15
+ (agrs: UseTrackPressPricingFunctionArgs): PressPricingFunction;
16
+ }
17
+ declare const useTrackPressPricing: UseTrackPressPricingFunction;
18
+ export { useTrackPressPricing };
@@ -0,0 +1,23 @@
1
+ import { useCallback } from "react";
2
+ import { PROJECT } from "../../../infrastructure/tracking/tracking";
3
+ import { TrackingEvent, TrackingEventCategory } from "../tracking";
4
+ import { useEmitUserEvent } from "./useEmitUserEvent";
5
+ const useTrackPressPricing = ({ page, country, checkoutId }) => {
6
+ const emitUserEvent = useEmitUserEvent();
7
+ const pressPricing = useCallback(({ collapse }) => {
8
+ if (!checkoutId) {
9
+ return;
10
+ }
11
+ const pressPricingTrackingEvent = {
12
+ event: TrackingEvent.PRESS_PRICING,
13
+ eventCategory: TrackingEventCategory.NAVIGATION,
14
+ section: `${PROJECT}_${page}`,
15
+ store: country,
16
+ checkoutId,
17
+ collapse,
18
+ };
19
+ emitUserEvent(pressPricingTrackingEvent);
20
+ }, [checkoutId, country, emitUserEvent, page]);
21
+ return pressPricing;
22
+ };
23
+ export { useTrackPressPricing };
@@ -0,0 +1,20 @@
1
+ import { TrackingPage } from "../../../infrastructure/tracking/tracking";
2
+ import { Country } from "../../../projection/shared/country";
3
+ interface ReplaceItemFunctionArgs {
4
+ readonly replaceFor: string;
5
+ }
6
+ interface ReplaceItemFunction {
7
+ (args: ReplaceItemFunctionArgs): void;
8
+ }
9
+ interface UseTrackReplaceItemFunctionArgs {
10
+ readonly page: TrackingPage;
11
+ readonly country: Country;
12
+ readonly checkoutId: string | undefined;
13
+ readonly checkoutItemId: string;
14
+ readonly productVariantId: string;
15
+ }
16
+ interface UseTrackReplaceItemFunction {
17
+ (agrs: UseTrackReplaceItemFunctionArgs): ReplaceItemFunction;
18
+ }
19
+ declare const useTrackReplaceItem: UseTrackReplaceItemFunction;
20
+ export { useTrackReplaceItem };
@@ -0,0 +1,25 @@
1
+ import { useCallback } from "react";
2
+ import { PROJECT } from "../../../infrastructure/tracking/tracking";
3
+ import { TrackingEvent, TrackingEventCategory } from "../tracking";
4
+ import { useEmitUserEvent } from "./useEmitUserEvent";
5
+ const useTrackReplaceItem = ({ page, country, checkoutId, checkoutItemId, productVariantId, }) => {
6
+ const emitUserEvent = useEmitUserEvent();
7
+ const replaceItem = useCallback(({ replaceFor }) => {
8
+ if (!checkoutId) {
9
+ return;
10
+ }
11
+ const replaceItemTrackingEvent = {
12
+ event: TrackingEvent.REPLACE_ITEM,
13
+ eventCategory: TrackingEventCategory.NAVIGATION,
14
+ section: `${PROJECT}_${page}`,
15
+ store: country,
16
+ checkoutId,
17
+ checkoutItemId,
18
+ productVariantId,
19
+ replaceFor,
20
+ };
21
+ emitUserEvent(replaceItemTrackingEvent);
22
+ }, [checkoutId, checkoutItemId, country, emitUserEvent, page, productVariantId]);
23
+ return replaceItem;
24
+ };
25
+ export { useTrackReplaceItem };
@@ -0,0 +1,16 @@
1
+ import { TrackingPage } from "../../../infrastructure/tracking/tracking";
2
+ import { Country } from "../../../projection/shared/country";
3
+ interface ResetItemFunction {
4
+ (): void;
5
+ }
6
+ interface UseTrackResetItemFunctionArgs {
7
+ readonly page: TrackingPage;
8
+ readonly country: Country;
9
+ readonly checkoutId: string | undefined;
10
+ readonly checkoutItemId: string;
11
+ }
12
+ interface UseTrackResetItemFunction {
13
+ (agrs: UseTrackResetItemFunctionArgs): ResetItemFunction;
14
+ }
15
+ declare const useTrackResetItem: UseTrackResetItemFunction;
16
+ export { useTrackResetItem };
@@ -0,0 +1,23 @@
1
+ import { useCallback } from "react";
2
+ import { PROJECT } from "../../../infrastructure/tracking/tracking";
3
+ import { TrackingEvent, TrackingEventCategory } from "../tracking";
4
+ import { useEmitUserEvent } from "./useEmitUserEvent";
5
+ const useTrackResetItem = ({ page, country, checkoutId, checkoutItemId }) => {
6
+ const emitUserEvent = useEmitUserEvent();
7
+ const resetItem = useCallback(() => {
8
+ if (!checkoutId) {
9
+ return;
10
+ }
11
+ const resetItemTrackingEvent = {
12
+ event: TrackingEvent.RESET_ITEM,
13
+ eventCategory: TrackingEventCategory.NAVIGATION,
14
+ section: `${PROJECT}_${page}`,
15
+ store: country,
16
+ checkoutId,
17
+ checkoutItemId,
18
+ };
19
+ emitUserEvent(resetItemTrackingEvent);
20
+ }, [checkoutId, checkoutItemId, country, emitUserEvent, page]);
21
+ return resetItem;
22
+ };
23
+ export { useTrackResetItem };
@@ -0,0 +1,16 @@
1
+ import { TrackingPage } from "../../../infrastructure/tracking/tracking";
2
+ import { Country } from "../../../projection/shared/country";
3
+ interface ReturnItemFunction {
4
+ (): void;
5
+ }
6
+ interface UseTrackReturnItemFunctionArgs {
7
+ readonly page: TrackingPage;
8
+ readonly country: Country;
9
+ readonly checkoutId: string | undefined;
10
+ readonly checkoutItemId: string;
11
+ }
12
+ interface UseTrackReturnItemFunction {
13
+ (agrs: UseTrackReturnItemFunctionArgs): ReturnItemFunction;
14
+ }
15
+ declare const useTrackReturnItem: UseTrackReturnItemFunction;
16
+ export { useTrackReturnItem };
@@ -0,0 +1,23 @@
1
+ import { useCallback } from "react";
2
+ import { PROJECT } from "../../../infrastructure/tracking/tracking";
3
+ import { TrackingEvent, TrackingEventCategory } from "../tracking";
4
+ import { useEmitUserEvent } from "./useEmitUserEvent";
5
+ const useTrackReturnItem = ({ page, country, checkoutId, checkoutItemId }) => {
6
+ const emitUserEvent = useEmitUserEvent();
7
+ const returnItem = useCallback(() => {
8
+ if (!checkoutId) {
9
+ return;
10
+ }
11
+ const returnItemTrackingEvent = {
12
+ event: TrackingEvent.RETURN_ITEM,
13
+ eventCategory: TrackingEventCategory.NAVIGATION,
14
+ section: `${PROJECT}_${page}`,
15
+ store: country,
16
+ checkoutId,
17
+ checkoutItemId,
18
+ };
19
+ emitUserEvent(returnItemTrackingEvent);
20
+ }, [checkoutId, checkoutItemId, country, emitUserEvent, page]);
21
+ return returnItem;
22
+ };
23
+ export { useTrackReturnItem };
@@ -0,0 +1,15 @@
1
+ import { TrackingPage } from "../../../infrastructure/tracking/tracking";
2
+ import { Country } from "../../../projection/shared/country";
3
+ interface TabViewFunctionArgs<T> {
4
+ readonly tab: T;
5
+ }
6
+ interface TabViewFunction<T> {
7
+ (args: TabViewFunctionArgs<T>): void;
8
+ }
9
+ interface UseTrackTabViewFunctionArgs {
10
+ readonly page: TrackingPage;
11
+ readonly country: Country;
12
+ readonly checkoutId: string | undefined;
13
+ }
14
+ declare const useTrackTabView: <T>({ page, country, checkoutId }: UseTrackTabViewFunctionArgs) => TabViewFunction<T>;
15
+ export { useTrackTabView };
@@ -0,0 +1,23 @@
1
+ import { useCallback } from "react";
2
+ import { PROJECT } from "../../../infrastructure/tracking/tracking";
3
+ import { TrackingEvent, TrackingEventCategory } from "../tracking";
4
+ import { useEmitUserEvent } from "./useEmitUserEvent";
5
+ const useTrackTabView = ({ page, country, checkoutId }) => {
6
+ const emitUserEvent = useEmitUserEvent();
7
+ const tabView = useCallback(({ tab }) => {
8
+ if (!checkoutId) {
9
+ return;
10
+ }
11
+ const tabViewTrackingEvent = {
12
+ event: TrackingEvent.TAB_VIEW,
13
+ eventCategory: TrackingEventCategory.NAVIGATION,
14
+ section: `${PROJECT}_${page}`,
15
+ store: country,
16
+ checkoutId,
17
+ tab,
18
+ };
19
+ emitUserEvent(tabViewTrackingEvent);
20
+ }, [checkoutId, country, emitUserEvent, page]);
21
+ return tabView;
22
+ };
23
+ export { useTrackTabView };
@@ -1,6 +1,16 @@
1
+ import { MediaPerspective } from "../../projection/checkoutItem/checkoutItem";
1
2
  import { Country } from "../../projection/shared/country";
2
3
  declare enum TrackingEvent {
3
- PAGEVIEW = "pageview"
4
+ PAGEVIEW = "pageview",
5
+ KEEP_ITEM = "keep-item",
6
+ RETURN_ITEM = "return-item",
7
+ REPLACE_ITEM = "replace-item",
8
+ RESET_ITEM = "reset-item",
9
+ IMAGE_VIEW = "image-view",
10
+ PRESS_PRICING = "press-pricing",
11
+ PRESS_ITEM = "press-item",
12
+ PRESS_CONTINUE = "press-continue",
13
+ TAB_VIEW = "tab-view"
4
14
  }
5
15
  declare enum TrackingEventCategory {
6
16
  NAVIGATION = "navigation"
@@ -12,8 +22,41 @@ interface BaseTrackingEvent {
12
22
  readonly store: Country;
13
23
  readonly checkoutId: string;
14
24
  }
15
- interface PageViewTrackingEvent extends BaseTrackingEvent {
16
- readonly checkoutItemId?: string;
25
+ type PageViewTrackingEvent = BaseTrackingEvent;
26
+ interface ItemPageViewTrackingEvent extends BaseTrackingEvent {
27
+ readonly checkoutItemId: string;
28
+ readonly productVariantId: string;
29
+ readonly replaceableFor: string[] | undefined;
30
+ readonly unique: boolean;
17
31
  }
18
- export type { BaseTrackingEvent, PageViewTrackingEvent };
32
+ interface KeepItemTrackingEvent extends BaseTrackingEvent {
33
+ readonly checkoutItemId: string;
34
+ }
35
+ interface ReturnItemTrackingEvent extends BaseTrackingEvent {
36
+ readonly checkoutItemId: string;
37
+ }
38
+ interface ReplaceItemTrackingEvent extends BaseTrackingEvent {
39
+ readonly checkoutItemId: string;
40
+ readonly productVariantId: string;
41
+ readonly replaceFor: string;
42
+ }
43
+ interface ResetItemTrackingEvent extends BaseTrackingEvent {
44
+ readonly checkoutItemId: string;
45
+ }
46
+ interface ImageViewTrackingEvent extends BaseTrackingEvent {
47
+ readonly checkoutItemId: string;
48
+ readonly productVariantId: string;
49
+ readonly perspective: MediaPerspective;
50
+ }
51
+ interface PressPricingTrackingEvent extends BaseTrackingEvent {
52
+ readonly collapse: boolean;
53
+ }
54
+ interface PressItemTrackingEvent extends BaseTrackingEvent {
55
+ readonly checkoutItemId: string;
56
+ }
57
+ type PressContinueTrackingEvent = BaseTrackingEvent;
58
+ interface TabViewTrackingEvent<T> extends BaseTrackingEvent {
59
+ readonly tab: T;
60
+ }
61
+ export type { BaseTrackingEvent, ImageViewTrackingEvent, ItemPageViewTrackingEvent, KeepItemTrackingEvent, PageViewTrackingEvent, PressContinueTrackingEvent, PressItemTrackingEvent, PressPricingTrackingEvent, ReplaceItemTrackingEvent, ResetItemTrackingEvent, ReturnItemTrackingEvent, TabViewTrackingEvent, };
19
62
  export { TrackingEvent, TrackingEventCategory };
@@ -1,6 +1,15 @@
1
1
  var TrackingEvent;
2
2
  (function (TrackingEvent) {
3
3
  TrackingEvent["PAGEVIEW"] = "pageview";
4
+ TrackingEvent["KEEP_ITEM"] = "keep-item";
5
+ TrackingEvent["RETURN_ITEM"] = "return-item";
6
+ TrackingEvent["REPLACE_ITEM"] = "replace-item";
7
+ TrackingEvent["RESET_ITEM"] = "reset-item";
8
+ TrackingEvent["IMAGE_VIEW"] = "image-view";
9
+ TrackingEvent["PRESS_PRICING"] = "press-pricing";
10
+ TrackingEvent["PRESS_ITEM"] = "press-item";
11
+ TrackingEvent["PRESS_CONTINUE"] = "press-continue";
12
+ TrackingEvent["TAB_VIEW"] = "tab-view";
4
13
  })(TrackingEvent || (TrackingEvent = {}));
5
14
  var TrackingEventCategory;
6
15
  (function (TrackingEventCategory) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.8.23",
3
+ "version": "0.8.25",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -1,13 +0,0 @@
1
- import { TrackingPage } from "../../../infrastructure/tracking/tracking";
2
- import { Country } from "../../../projection/shared/country";
3
- interface UsePageViewFunctionArgs {
4
- readonly page: TrackingPage;
5
- readonly country: Country;
6
- readonly checkoutId?: string;
7
- readonly checkoutItemId?: string;
8
- }
9
- interface UsePageViewFunction {
10
- (agrs: UsePageViewFunctionArgs): void;
11
- }
12
- declare const usePageView: UsePageViewFunction;
13
- export { usePageView };