@lookiero/checkout 0.5.5 → 0.5.7

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.
@@ -0,0 +1,9 @@
1
+ declare const PROJECT = "checkout";
2
+ declare enum TrackingPage {
3
+ ITEM = "item",
4
+ CHECKOUT = "checkout",
5
+ SUMMARY = "summary",
6
+ FEEDBACK = "feedback",
7
+ NOT_FOUND = "not_found"
8
+ }
9
+ export { PROJECT, TrackingPage };
@@ -0,0 +1,10 @@
1
+ const PROJECT = "checkout";
2
+ var TrackingPage;
3
+ (function (TrackingPage) {
4
+ TrackingPage["ITEM"] = "item";
5
+ TrackingPage["CHECKOUT"] = "checkout";
6
+ TrackingPage["SUMMARY"] = "summary";
7
+ TrackingPage["FEEDBACK"] = "feedback";
8
+ TrackingPage["NOT_FOUND"] = "not_found";
9
+ })(TrackingPage || (TrackingPage = {}));
10
+ export { PROJECT, TrackingPage };
@@ -61,12 +61,12 @@ const Routing = ({ basePath = "", customer, locale, I18n, menu, tabBar, getAuthT
61
61
  {
62
62
  path: Routes.FEEDBACK,
63
63
  element: (React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
64
- React.createElement(Feedback, { customerId: customer?.customerId }))),
64
+ React.createElement(Feedback, { country: customer?.country, customerId: customer?.customerId }))),
65
65
  },
66
66
  {
67
67
  path: Routes.NOT_FOUND,
68
68
  element: (React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
69
- React.createElement(NotFound, null))),
69
+ React.createElement(NotFound, { country: customer?.country, customerId: customer?.customerId }))),
70
70
  },
71
71
  {
72
72
  path: "*",
@@ -6,9 +6,11 @@ import React, { useCallback, useMemo, useRef } from "react";
6
6
  import { Platform, View } from "react-native";
7
7
  import { useNavigate } from "react-router-native";
8
8
  import { CheckoutItemStatus } from "../../../../domain/checkoutItem/model/checkoutItem";
9
+ import { usePageView } from "../../../../shared/tracking/infrastructure/usePageView";
9
10
  import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
10
11
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
11
12
  import { useViewPricingByCheckoutId } from "../../../projection/pricing/react/useViewPricingByCheckoutId";
13
+ import { TrackingPage } from "../../../tracking/tracking";
12
14
  import { Body } from "../../components/layouts/body/Body";
13
15
  import { SafeAreaScrollView } from "../../components/templates/SafeAreaScrollView";
14
16
  import { I18nMessages } from "../../i18n/i18n";
@@ -24,6 +26,11 @@ const Checkout = ({ children, customerId, country, useRedirect }) => {
24
26
  const paymentInstrumentSelectRef = useRef(null);
25
27
  const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
26
28
  const [pricing, pricingStatus] = useViewPricingByCheckoutId({ checkoutId: checkout?.id });
29
+ usePageView({
30
+ page: TrackingPage.CHECKOUT,
31
+ country,
32
+ checkoutId: checkout?.id,
33
+ });
27
34
  const navigate = useNavigate();
28
35
  const basePath = useBasePath();
29
36
  const { returnUrl } = useRedirect();
@@ -1,6 +1,8 @@
1
1
  import { FC } from "react";
2
+ import { Country } from "../../../../projection/shared/country";
2
3
  interface FeedbackProps {
3
4
  readonly customerId: string;
5
+ readonly country: Country;
4
6
  }
5
7
  declare const Feedback: FC<FeedbackProps>;
6
8
  export { Feedback };
@@ -1,17 +1,19 @@
1
1
  import { CommandStatus, QueryStatus } from "@lookiero/messaging-react";
2
2
  import React, { useCallback } from "react";
3
3
  import { Platform } from "react-native";
4
+ import { usePageView } from "../../../../shared/tracking/infrastructure/usePageView";
4
5
  import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
5
6
  import { useGiveCheckoutFeedback } from "../../../domain/checkoutFeedback/react/useGiveCheckoutFeedback";
6
7
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
7
8
  import { useListCheckoutQuestionsByCheckoutId } from "../../../projection/checkoutQuestion/react/useListCheckoutQuestionsByCheckoutId";
9
+ import { TrackingPage } from "../../../tracking/tracking";
8
10
  import { Body } from "../../components/layouts/body/Body";
9
11
  import { CheckoutQuestionFeedbackProvider } from "../../components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionFeedback";
10
12
  import { SafeAreaScrollView } from "../../components/templates/SafeAreaScrollView";
11
13
  import { HEADER_HEIGHT } from "../navigation/components/header/Header.style";
12
14
  import { style } from "./Feedback.style";
13
15
  import { CheckoutQuestionsForm } from "./components/checkoutQuestionsForm/CheckoutQuestionsForm";
14
- const Feedback = ({ customerId }) => {
16
+ const Feedback = ({ customerId, country }) => {
15
17
  const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
16
18
  const [checkoutQuestions, checkoutQuestionsStatus] = useListCheckoutQuestionsByCheckoutId({
17
19
  checkoutId: checkout?.id,
@@ -25,6 +27,11 @@ const Feedback = ({ customerId }) => {
25
27
  }
26
28
  catch (e) { }
27
29
  }, [giveCheckoutFeedback]);
30
+ usePageView({
31
+ page: TrackingPage.FEEDBACK,
32
+ country,
33
+ checkoutId: checkout?.id,
34
+ });
28
35
  const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
29
36
  const dependenciesLoaded = dependenciesLoadedStatuses.includes(checkoutStatus) && dependenciesLoadedStatuses.includes(checkoutQuestionsStatus);
30
37
  if (!dependenciesLoaded)
@@ -4,6 +4,7 @@ import { Platform, View } from "react-native";
4
4
  import { generatePath, useMatch, useNavigate, useParams } from "react-router-native";
5
5
  import { CheckoutItemStatus } from "../../../../domain/checkoutItem/model/checkoutItem";
6
6
  import "../../../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
7
+ import { usePageView } from "../../../../shared/tracking/infrastructure/usePageView";
7
8
  import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
8
9
  import { useBookCheckoutBookingForCheckoutItem } from "../../../domain/checkoutBooking/react/useBookCheckoutBookingForCheckoutItem";
9
10
  import { useKeepCheckoutItem } from "../../../domain/checkoutItem/react/useKeepCheckoutItem";
@@ -12,6 +13,7 @@ import { useReturnCheckoutItem } from "../../../domain/checkoutItem/react/useRet
12
13
  import { useViewBookedProductsVariantsForCheckoutItem } from "../../../projection/bookedProductsVariants/react/useViewBookedProductsVariantsForCheckoutItem";
13
14
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
14
15
  import { useListReturnQuestionsByCheckoutItemId } from "../../../projection/returnQuestion/react/useListReturnQuestionsByCheckoutItemId";
16
+ import { TrackingPage } from "../../../tracking/tracking";
15
17
  import { Body } from "../../components/layouts/body/Body";
16
18
  import { ReturnQuestionFeedbackProvider } from "../../components/organisms/returnQuestions/behaviors/useReturnQuestionFeedback";
17
19
  import { SafeAreaScrollView } from "../../components/templates/SafeAreaScrollView";
@@ -33,6 +35,12 @@ const Item = ({ customerId, country }) => {
33
35
  const { id } = useParams();
34
36
  const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
35
37
  const checkoutItem = checkout?.items.find((checkoutItem) => checkoutItem.id === id);
38
+ usePageView({
39
+ page: TrackingPage.ITEM,
40
+ country,
41
+ checkoutId: checkout?.id,
42
+ checkoutItemId: checkoutItem.id,
43
+ });
36
44
  const basePath = useBasePath();
37
45
  const itemRouteMatch = useMatch(`${basePath}/${Routes.ITEM}`);
38
46
  const itemDetailRouteMatch = useMatch(`${basePath}/${Routes.ITEM_DETAIL}`);
@@ -1,3 +1,8 @@
1
1
  import { FC } from "react";
2
- declare const NotFound: FC;
2
+ import { Country } from "../../../../projection/shared/country";
3
+ interface NotFoundProps {
4
+ readonly customerId: string;
5
+ readonly country: Country;
6
+ }
7
+ declare const NotFound: FC<NotFoundProps>;
3
8
  export { NotFound };
@@ -1,10 +1,15 @@
1
1
  import { Button } from "@lookiero/aurora-next/build/components/atoms/Button/Button";
2
2
  import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
3
3
  import { useI18nMessage } from "@lookiero/i18n-react";
4
+ import { QueryStatus } from "@lookiero/messaging-react";
4
5
  import React, { useCallback } from "react";
5
6
  import { Image, Platform } from "react-native";
6
7
  import { useNavigate } from "react-router-native";
8
+ import { usePageView } from "../../../../shared/tracking/infrastructure/usePageView";
7
9
  import { AspectRatioView } from "../../../../shared/ui/components/atoms/aspectRatioView/AspectRatioView";
10
+ import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
11
+ import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
12
+ import { TrackingPage } from "../../../tracking/tracking";
8
13
  import { Body } from "../../components/layouts/body/Body";
9
14
  import { SafeAreaScrollView } from "../../components/templates/SafeAreaScrollView";
10
15
  import { I18nMessages } from "../../i18n/i18n";
@@ -12,12 +17,22 @@ import { Routes } from "../../routing/routes";
12
17
  import { useBasePath } from "../../routing/useBasePath";
13
18
  import { HEADER_HEIGHT } from "../navigation/components/header/Header.style";
14
19
  import { style } from "./NotFound.style";
15
- const NotFound = () => {
20
+ const NotFound = ({ customerId, country }) => {
16
21
  const descriptionText = useI18nMessage({ id: I18nMessages.NOT_FOUND_DESCRIPTION });
17
22
  const buttonText = useI18nMessage({ id: I18nMessages.NOT_FOUND_BUTTON });
23
+ const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
24
+ usePageView({
25
+ page: TrackingPage.NOT_FOUND,
26
+ country,
27
+ checkoutId: checkout?.id,
28
+ });
18
29
  const navigate = useNavigate();
19
30
  const basePath = useBasePath();
20
31
  const handleOnPress = useCallback(() => navigate(`${basePath}/${Routes.HOME}`), [basePath, navigate]);
32
+ const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
33
+ const dependenciesLoaded = dependenciesLoadedStatuses.includes(checkoutStatus);
34
+ if (!dependenciesLoaded)
35
+ return React.createElement(Spinner, null);
21
36
  return (React.createElement(SafeAreaScrollView, { scrollerPaddingTop: Platform.OS === "web" || Platform.OS === "android" ? HEADER_HEIGHT : 0, style: { scrollView: style.container } },
22
37
  React.createElement(Body, { style: { column: style.bodyColumn } },
23
38
  React.createElement(AspectRatioView, { aspectRatio: 1.25 },
@@ -5,10 +5,12 @@ 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
9
  import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
9
10
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
10
11
  import { useViewFiveItemsDiscountByCustomerId } from "../../../projection/checkout/react/useViewFiveItemsDiscountByCustomerId";
11
12
  import { useViewPricingByCheckoutId } from "../../../projection/pricing/react/useViewPricingByCheckoutId";
13
+ import { TrackingPage } from "../../../tracking/tracking";
12
14
  import { Body } from "../../components/layouts/body/Body";
13
15
  import { SafeAreaScrollView } from "../../components/templates/SafeAreaScrollView";
14
16
  import { I18nMessages } from "../../i18n/i18n";
@@ -29,6 +31,11 @@ const Summary = ({ customerId, country }) => {
29
31
  const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
30
32
  const [pricing, pricingStatus] = useViewPricingByCheckoutId({ checkoutId: checkout?.id });
31
33
  const [fiveItemsDiscount = 0, fiveItemsDiscountStatus] = useViewFiveItemsDiscountByCustomerId({ customerId });
34
+ usePageView({
35
+ page: TrackingPage.SUMMARY,
36
+ country,
37
+ checkoutId: checkout?.id,
38
+ });
32
39
  const navigate = useNavigate();
33
40
  const basePath = useBasePath();
34
41
  const [pricingCollapsed, setPricingCollapsed] = useState(true);
@@ -0,0 +1,6 @@
1
+ import { BaseTrackingEvent } from "../tracking";
2
+ interface EmitUserEventFunction<T extends BaseTrackingEvent> {
3
+ (args: T): void;
4
+ }
5
+ declare const useEmitUserEvent: <T extends BaseTrackingEvent>() => EmitUserEventFunction<T>;
6
+ export { useEmitUserEvent };
@@ -0,0 +1,7 @@
1
+ import { emitUserEvent as emit } from "@lookiero/user-tracking-front";
2
+ import { useCallback } from "react";
3
+ const useEmitUserEvent = () => {
4
+ const emitUserEvent = useCallback((event) => emit(event), []);
5
+ return emitUserEvent;
6
+ };
7
+ export { useEmitUserEvent };
@@ -0,0 +1,13 @@
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 };
@@ -0,0 +1,21 @@
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 usePageView = ({ page, country, checkoutId, checkoutItemId }) => {
6
+ const emitUserEvent = useEmitUserEvent();
7
+ useLayoutEffect(() => {
8
+ if (!checkoutId) {
9
+ return;
10
+ }
11
+ emitUserEvent({
12
+ event: TrackingEvent.PAGEVIEW,
13
+ eventCategory: TrackingEventCategory.NAVIGATION,
14
+ section: `${PROJECT}_${page}`,
15
+ store: country,
16
+ checkoutId,
17
+ checkoutItemId,
18
+ });
19
+ }, [checkoutId, checkoutItemId, country, emitUserEvent, page]);
20
+ };
21
+ export { usePageView };
@@ -0,0 +1,19 @@
1
+ import { Country } from "../../projection/shared/country";
2
+ declare enum TrackingEvent {
3
+ PAGEVIEW = "pageview"
4
+ }
5
+ declare enum TrackingEventCategory {
6
+ NAVIGATION = "navigation"
7
+ }
8
+ interface BaseTrackingEvent {
9
+ readonly event: TrackingEvent;
10
+ readonly eventCategory: TrackingEventCategory;
11
+ readonly section: string;
12
+ readonly store: Country;
13
+ readonly checkoutId: string;
14
+ }
15
+ interface PageViewTrackingEvent extends BaseTrackingEvent {
16
+ readonly checkoutItemId?: string;
17
+ }
18
+ export type { BaseTrackingEvent, PageViewTrackingEvent };
19
+ export { TrackingEvent, TrackingEventCategory };
@@ -0,0 +1,9 @@
1
+ var TrackingEvent;
2
+ (function (TrackingEvent) {
3
+ TrackingEvent["PAGEVIEW"] = "pageview";
4
+ })(TrackingEvent || (TrackingEvent = {}));
5
+ var TrackingEventCategory;
6
+ (function (TrackingEventCategory) {
7
+ TrackingEventCategory["NAVIGATION"] = "navigation";
8
+ })(TrackingEventCategory || (TrackingEventCategory = {}));
9
+ export { TrackingEvent, TrackingEventCategory };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.5.5",
3
+ "version": "0.5.7",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -47,6 +47,7 @@
47
47
  "@lookiero/event": "^0.3",
48
48
  "@lookiero/locale": "^0.3",
49
49
  "@lookiero/payments-front": "^0.16.9",
50
+ "@lookiero/user-tracking-front": "0.0.37",
50
51
  "apollo-boost": "0.4.4",
51
52
  "graphql": "16.6.0",
52
53
  "graphql-tag": "2.12.6",
@@ -68,8 +69,11 @@
68
69
  "@lookiero/event": "^0.3",
69
70
  "@lookiero/locale": "^0.3",
70
71
  "@lookiero/payments-front": "^0.16.9",
72
+ "@lookiero/user-tracking-front": "0.0.37",
71
73
  "@pact-foundation/pact": "^10.1.4",
72
74
  "@pact-foundation/pact-node": "^10.17.6",
75
+ "@react-native-firebase/analytics": "10.5.1",
76
+ "@react-native-firebase/app": "10.5.0",
73
77
  "@testing-library/react": "^13.4.0",
74
78
  "@testing-library/react-hooks": "^8.0.1",
75
79
  "@testing-library/react-native": "^11.5.0",
@@ -106,6 +110,7 @@
106
110
  "react": "^18.0.0",
107
111
  "react-dom": "^18.0.0",
108
112
  "react-native": "^0.70.6",
113
+ "react-native-adjust": "^4.33.0",
109
114
  "react-native-get-random-values": "^1.8.0",
110
115
  "react-native-unimodules": "^0.14.10",
111
116
  "react-native-web": "^0.18.9",