@lookiero/checkout 0.8.17 → 0.8.19-beta.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.
Files changed (137) hide show
  1. package/dist/domain/checkout/command/markCheckoutAsPaid.d.ts +13 -0
  2. package/dist/domain/checkout/command/markCheckoutAsPaid.js +4 -0
  3. package/dist/domain/checkout/event/createModalNotificationWhenCheckoutSubmitted.d.ts +7 -0
  4. package/dist/domain/checkout/event/createModalNotificationWhenCheckoutSubmitted.js +12 -0
  5. package/dist/domain/checkout/model/checkoutPaid.d.ts +13 -0
  6. package/dist/domain/checkout/model/checkoutPaid.js +4 -0
  7. package/dist/domain/checkoutBooking/event/createToastNotificationWhenCheckoutBookingExpired.d.ts +7 -0
  8. package/dist/domain/checkoutBooking/event/createToastNotificationWhenCheckoutBookingExpired.js +13 -0
  9. package/dist/domain/checkoutItem/event/createModalNotificationWhenCheckoutItemReplaced.d.ts +7 -0
  10. package/dist/domain/checkoutItem/event/createModalNotificationWhenCheckoutItemReplaced.js +12 -0
  11. package/dist/domain/checkoutItem/model/checkoutItem.js +1 -0
  12. package/dist/index.d.ts +2 -1
  13. package/dist/index.js +2 -1
  14. package/dist/infrastructure/delivery/baseBootstrap.js +8 -2
  15. package/dist/infrastructure/delivery/mock/checkoutDataSource.js +4 -1
  16. package/dist/infrastructure/domain/checkout/model/httpCheckoutsMarkAsPaid.d.ts +5 -0
  17. package/dist/infrastructure/domain/checkout/model/httpCheckoutsMarkAsPaid.js +13 -0
  18. package/dist/infrastructure/domain/checkout/react/useMarkCheckoutAsPaid.d.ts +13 -0
  19. package/dist/infrastructure/domain/checkout/react/useMarkCheckoutAsPaid.js +16 -0
  20. package/dist/infrastructure/domain/checkout/react/useSubmitCheckout.js +2 -2
  21. package/dist/infrastructure/domain/checkoutBooking/react/useBlockCheckoutBooking.js +2 -2
  22. package/dist/infrastructure/domain/checkoutBooking/react/useBookCheckouBookingForCheckoutItem.d.ts +13 -0
  23. package/dist/infrastructure/domain/checkoutBooking/react/useBookCheckouBookingForCheckoutItem.js +14 -0
  24. package/dist/infrastructure/domain/checkoutBooking/react/useBookCheckoutBookingForCheckoutItem.js +2 -2
  25. package/dist/infrastructure/domain/checkoutFeedback/react/useGiveCheckoutFeedback.js +2 -2
  26. package/dist/infrastructure/domain/checkoutItem/react/useKeepCheckoutItem.js +3 -5
  27. package/dist/infrastructure/domain/checkoutItem/react/useReplaceCheckoutItem.js +3 -6
  28. package/dist/infrastructure/domain/checkoutItem/react/useResetCheckoutItem.js +3 -5
  29. package/dist/infrastructure/domain/checkoutItem/react/useReturnCheckoutItem.js +3 -6
  30. package/dist/infrastructure/domain/uiSetting/react/useIncrementIntroShownCount.d.ts +10 -0
  31. package/dist/infrastructure/domain/uiSetting/react/useIncrementIntroShownCount.js +11 -0
  32. package/dist/infrastructure/projection/bookedProductsVariants/react/useViewBookedProductsVariantsForCheckoutItem.js +4 -1
  33. package/dist/infrastructure/projection/bookedSizeChangeProductsVariants/httpBookedSizeChangeProductsVariantsForCheckoutItemView.d.ts +12 -0
  34. package/dist/infrastructure/projection/bookedSizeChangeProductsVariants/httpBookedSizeChangeProductsVariantsForCheckoutItemView.js +9 -0
  35. package/dist/infrastructure/projection/bookedSizeChangeProductsVariants/react/useViewBookedSizeChangeProductsVariantsForCheckoutItem.d.ts +10 -0
  36. package/dist/infrastructure/projection/bookedSizeChangeProductsVariants/react/useViewBookedSizeChangeProductsVariantsForCheckoutItem.js +12 -0
  37. package/dist/infrastructure/projection/checkout/react/useViewFiveItemsDiscountByCustomerId.js +1 -1
  38. package/dist/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackByCheckoutIdView.d.ts +12 -0
  39. package/dist/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackByCheckoutIdView.js +9 -0
  40. package/dist/infrastructure/projection/checkoutQuestion/react/useListCheckoutQuestionsByCheckoutId.js +1 -1
  41. package/dist/infrastructure/projection/payment/react/useViewPaymentFlowPayloadByCheckoutId.js +6 -1
  42. package/dist/infrastructure/projection/pricing/react/useViewPricingByCheckoutId.js +6 -1
  43. package/dist/infrastructure/projection/returnQuestion/react/useListReturnQuestionsByCheckoutItemId.js +1 -1
  44. package/dist/infrastructure/projection/uiSetting/react/useShouldIntroBeShown.d.ts +6 -0
  45. package/dist/infrastructure/projection/uiSetting/react/useShouldIntroBeShown.js +7 -0
  46. package/dist/infrastructure/projection/uiSetting/react/useViewIntroShownCount.d.ts +6 -0
  47. package/dist/infrastructure/projection/uiSetting/react/useViewIntroShownCount.js +9 -0
  48. package/dist/infrastructure/ui/hooks/usePaymentInstrumentEvents.js +2 -2
  49. package/dist/infrastructure/ui/hooks/useSubmitCheckout.js +2 -2
  50. package/dist/infrastructure/ui/i18n/translationEndpoint.d.ts +10 -1
  51. package/dist/infrastructure/ui/i18n/translationEndpoint.js +19 -1
  52. package/dist/infrastructure/ui/routing/CheckoutMiddleware.js +54 -36
  53. package/dist/infrastructure/ui/routing/Routing.js +1 -7
  54. package/dist/infrastructure/ui/views/App.js +4 -4
  55. package/dist/infrastructure/ui/views/App.style.d.ts +4 -0
  56. package/dist/infrastructure/ui/views/App.style.js +16 -0
  57. package/dist/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.js +3 -7
  58. package/dist/infrastructure/ui/views/feedback/Feedback.js +10 -3
  59. package/dist/infrastructure/ui/views/header/Header.d.ts +15 -0
  60. package/dist/infrastructure/ui/views/header/Header.js +90 -0
  61. package/dist/infrastructure/ui/views/header/Header.style.d.ts +35 -0
  62. package/dist/infrastructure/ui/views/header/Header.style.js +38 -0
  63. package/dist/infrastructure/ui/views/header/components/Logo.d.ts +7 -0
  64. package/dist/infrastructure/ui/views/header/components/Logo.js +11 -0
  65. package/dist/infrastructure/ui/views/header/components/Logo.style.d.ts +7 -0
  66. package/dist/infrastructure/ui/views/header/components/Logo.style.js +8 -0
  67. package/dist/infrastructure/ui/views/intro/Intro.d.ts +6 -0
  68. package/dist/infrastructure/ui/views/intro/Intro.js +52 -0
  69. package/dist/infrastructure/ui/views/intro/Intro.style.d.ts +55 -0
  70. package/dist/infrastructure/ui/views/intro/Intro.style.js +58 -0
  71. package/dist/infrastructure/ui/views/item/Item.js +9 -53
  72. package/dist/infrastructure/ui/views/item/components/banner/CustomerDecissionBanner.d.ts +1 -0
  73. package/dist/infrastructure/ui/views/item/components/banner/CustomerDecissionBanner.js +10 -4
  74. package/dist/infrastructure/ui/views/item/components/banner/CustomerDecissionBanner.style.d.ts +8 -1
  75. package/dist/infrastructure/ui/views/item/components/banner/CustomerDecissionBanner.style.js +8 -1
  76. package/dist/projection/bookedSizeChangeProductsVariants/bookedSizeChangeProductsVariants.d.ts +10 -0
  77. package/dist/projection/bookedSizeChangeProductsVariants/bookedSizeChangeProductsVariants.js +1 -0
  78. package/dist/projection/bookedSizeChangeProductsVariants/viewBookedSizeChangeProductVariantsForCheckoutItem.d.ts +25 -0
  79. package/dist/projection/bookedSizeChangeProductsVariants/viewBookedSizeChangeProductVariantsForCheckoutItem.js +8 -0
  80. package/dist/projection/checkoutFeedback/viewCheckoutFeedbackByCheckoutId.d.ts +25 -0
  81. package/dist/projection/checkoutFeedback/viewCheckoutFeedbackByCheckoutId.js +8 -0
  82. package/dist/projection/shared/country.d.ts +10 -10
  83. package/dist/projection/shared/locale.d.ts +11 -0
  84. package/dist/projection/shared/locale.js +12 -0
  85. package/dist/shared/logging/location.d.ts +3 -0
  86. package/dist/shared/logging/location.js +5 -0
  87. package/dist/shared/logging/matchRoutes.d.ts +3 -0
  88. package/dist/shared/logging/matchRoutes.js +7 -0
  89. package/dist/shared/logging/reactRouterV6Instrumentation/reactRouterV6Instrumentation.native.d.ts +29 -0
  90. package/dist/shared/logging/reactRouterV6Instrumentation/reactRouterV6Instrumentation.native.js +134 -0
  91. package/dist/shared/logging/reactRouterV6Instrumentation/transactionContext.d.ts +22 -0
  92. package/dist/shared/logging/reactRouterV6Instrumentation/transactionContext.js +15 -0
  93. package/dist/shared/logging/reactRouterV6Instrumentation.native.d.ts +27 -0
  94. package/dist/shared/logging/reactRouterV6Instrumentation.native.js +115 -0
  95. package/dist/shared/notifications/domain/notification/command/createModalNotification.d.ts +18 -0
  96. package/dist/shared/notifications/domain/notification/command/createModalNotification.js +9 -0
  97. package/dist/shared/notifications/domain/notification/command/createToastNotification.d.ts +18 -0
  98. package/dist/shared/notifications/domain/notification/command/createToastNotification.js +9 -0
  99. package/dist/shared/notifications/domain/notification/command/removeNotification.tes.d.ts +1 -0
  100. package/dist/shared/notifications/domain/notification/command/removeNotification.tes.js +9 -0
  101. package/dist/shared/notifications/domain/notification/model/notification.d.ts +11 -4
  102. package/dist/shared/notifications/domain/notification/model/notification.js +20 -4
  103. package/dist/shared/notifications/index.d.ts +3 -2
  104. package/dist/shared/notifications/index.js +3 -2
  105. package/dist/shared/notifications/infrastructure/delivery/bootstrap.js +7 -4
  106. package/dist/shared/notifications/infrastructure/domain/notification/model/storageNotifications.js +3 -1
  107. package/dist/shared/notifications/infrastructure/domain/notification/model/storageNotificationsCreate.d.ts +1 -1
  108. package/dist/shared/notifications/infrastructure/domain/notification/model/storageNotificationsCreate.js +3 -1
  109. package/dist/shared/notifications/infrastructure/domain/notification/react/useCreateModalNotification.d.ts +20 -0
  110. package/dist/shared/notifications/infrastructure/domain/notification/react/useCreateModalNotification.js +22 -0
  111. package/dist/shared/notifications/infrastructure/domain/notification/react/useCreateToastNotification.d.ts +21 -0
  112. package/dist/shared/notifications/infrastructure/domain/notification/react/useCreateToastNotification.js +22 -0
  113. package/dist/shared/notifications/infrastructure/persistence/notificationDto.d.ts +3 -1
  114. package/dist/shared/notifications/infrastructure/projection/notification/notification.d.ts +2 -2
  115. package/dist/shared/notifications/infrastructure/projection/notification/notification.js +16 -6
  116. package/dist/shared/notifications/infrastructure/ui/components/modalNotifications/ModalNotificationItem.d.ts +10 -0
  117. package/dist/shared/notifications/infrastructure/ui/components/modalNotifications/ModalNotificationItem.js +26 -0
  118. package/dist/shared/notifications/infrastructure/ui/components/modalNotifications/ModalNotificationItem.style.d.ts +16 -0
  119. package/dist/shared/notifications/infrastructure/ui/components/modalNotifications/ModalNotificationItem.style.js +19 -0
  120. package/dist/shared/notifications/infrastructure/ui/components/modalNotifications/ModalNotifications.d.ts +8 -0
  121. package/dist/shared/notifications/infrastructure/ui/components/modalNotifications/ModalNotifications.js +6 -0
  122. package/dist/shared/notifications/infrastructure/ui/components/modalNotifications/ModalNotifications.style.d.ts +25 -0
  123. package/dist/shared/notifications/infrastructure/ui/components/modalNotifications/ModalNotifications.style.js +18 -0
  124. package/dist/shared/notifications/infrastructure/ui/components/toastNotifications/ToastNotificationItem.d.ts +12 -0
  125. package/dist/shared/notifications/infrastructure/ui/components/toastNotifications/ToastNotificationItem.js +24 -0
  126. package/dist/shared/notifications/infrastructure/ui/components/toastNotifications/ToastNotifications.d.ts +9 -0
  127. package/dist/shared/notifications/infrastructure/ui/components/toastNotifications/ToastNotifications.js +20 -0
  128. package/dist/shared/notifications/infrastructure/ui/components/toastNotifications/ToastNotifications.style.d.ts +36 -0
  129. package/dist/shared/notifications/infrastructure/ui/components/toastNotifications/ToastNotifications.style.js +31 -0
  130. package/dist/shared/notifications/infrastructure/ui/views/Notifications.js +9 -3
  131. package/dist/shared/notifications/projection/notification/notification.d.ts +18 -2
  132. package/dist/shared/notifications/projection/notification/notification.js +8 -1
  133. package/dist/shared/ui/components/atoms/spinner/Spinner.d.ts +6 -1
  134. package/dist/shared/ui/components/atoms/spinner/Spinner.js +2 -2
  135. package/dist/shared/ui/components/layouts/modal/Modal.d.ts +1 -0
  136. package/dist/shared/ui/components/layouts/modal/Modal.js +2 -2
  137. package/package.json +7 -5
@@ -0,0 +1,134 @@
1
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
2
+ import { RoutingInstrumentation } from "@sentry/react-native";
3
+ import { logger } from "@sentry/utils";
4
+ import React from "react";
5
+ import { stripFirstSlugFromLocation } from "../location";
6
+ import { normalizedNameAndMatchForLocation } from "./normalizedNameAndMatchForLocation";
7
+ import { transactionContext } from "./transactionContext";
8
+ /**
9
+ * This instrumentation has been built taking as an example the actual
10
+ * ReactNavigationV4Instrumentation implementation as suggested in the documentation.
11
+ *
12
+ * (https://docs.sentry.io/platforms/react-native/performance/instrumentation/automatic-instrumentation/#custom-instrumentation)
13
+ * (https://github.com/getsentry/sentry-react-native/blob/211ec081b6bf8d7d29541afe9d800040f61e3c4e/src/js/tracing/reactnavigationv4.ts)
14
+ */
15
+ class ReactRouterV6Instrumentation extends RoutingInstrumentation {
16
+ static instrumentationName = "react-router-v6";
17
+ useEffect;
18
+ useLocation;
19
+ matchRoutes;
20
+ prevRoute;
21
+ recentRouteKeys = [];
22
+ latestTransaction;
23
+ maxRecentRouteLen = 200;
24
+ constructor(useEffect, useLocation, matchRoutes) {
25
+ super();
26
+ this.useEffect = useEffect;
27
+ this.useLocation = useLocation;
28
+ this.matchRoutes = matchRoutes;
29
+ }
30
+ registerRoutingInstrumentation(listener, beforeNavigate, onConfirmRoute) {
31
+ super.registerRoutingInstrumentation(listener, beforeNavigate, onConfirmRoute);
32
+ this.latestTransaction = this.onRouteWillChange(INITIAL_TRANSACTION_CONTEXT);
33
+ }
34
+ onRouteChange(location, routes, updateLatestTransaction = false) {
35
+ const currentRoute = this.currentRouteFromLocation(location, routes);
36
+ if (!currentRoute || (this.prevRoute && currentRoute.key === this.prevRoute.key)) {
37
+ return;
38
+ }
39
+ const originalContext = transactionContext({
40
+ instrumentationName: ReactRouterV6Instrumentation.instrumentationName,
41
+ route: currentRoute,
42
+ previousRoute: this.prevRoute,
43
+ });
44
+ let finalContext = this._beforeNavigate?.(originalContext);
45
+ if (!finalContext) {
46
+ logger.error(`[ReactRouterV6Instrumentation] beforeNavigate returned ${finalContext}, return context.sampled = false to not send transaction.`);
47
+ finalContext = { ...originalContext, sampled: false };
48
+ }
49
+ if (finalContext.sampled === false) {
50
+ this.onBeforeNavigateNotSampled(finalContext.name);
51
+ }
52
+ if (updateLatestTransaction && this.latestTransaction) {
53
+ this.latestTransaction.updateWithContext(finalContext);
54
+ }
55
+ else {
56
+ this.latestTransaction = this.onRouteWillChange(finalContext);
57
+ }
58
+ this.pushRecentRouteKey(currentRoute.key);
59
+ this.prevRoute = currentRoute;
60
+ }
61
+ currentRouteFromLocation(location, routes) {
62
+ const normalizedLocation = stripFirstSlugFromLocation(location);
63
+ const branches = this.matchRoutes(routes, normalizedLocation);
64
+ if (!branches) {
65
+ return null;
66
+ }
67
+ const [normalizedName, match] = normalizedNameAndMatchForLocation({
68
+ location: normalizedLocation,
69
+ routes,
70
+ branches,
71
+ });
72
+ if (!match) {
73
+ return {
74
+ name: normalizedName,
75
+ key: normalizedName,
76
+ params: {},
77
+ hasBeenSeen: this.recentRouteKeys.includes(normalizedName),
78
+ };
79
+ }
80
+ return {
81
+ name: match.route.path,
82
+ key: normalizedName,
83
+ params: match.params,
84
+ hasBeenSeen: this.recentRouteKeys.includes(normalizedName),
85
+ };
86
+ }
87
+ pushRecentRouteKey(key) {
88
+ this.recentRouteKeys.push(key);
89
+ if (this.recentRouteKeys.length > this.maxRecentRouteLen) {
90
+ this.recentRouteKeys = this.recentRouteKeys.slice(this.recentRouteKeys.length - this.maxRecentRouteLen);
91
+ }
92
+ }
93
+ onBeforeNavigateNotSampled(transactionName) {
94
+ logger.log(`[ReactRouterV6Instrumentation] Will not send transaction "${transactionName}" due to beforeNavigate.`);
95
+ }
96
+ wrapUseRoutes = (origUseRoutes) => {
97
+ if (!this.useEffect || !this.useLocation || !this.matchRoutes) {
98
+ __DEBUG_BUILD__ &&
99
+ logger.warn("ReactRouterV6Instrumentation was unable to wrap `useRoutes` because of one or more missing parameters.");
100
+ return origUseRoutes;
101
+ }
102
+ let isMountRenderPass = true;
103
+ const useRoutes = (routes, locationArg) => {
104
+ const SentryRoutes = () => {
105
+ const Routes = origUseRoutes(routes, locationArg);
106
+ const location = this.useLocation();
107
+ const stableLocationParam = typeof locationArg === "string" || (locationArg && locationArg.pathname)
108
+ ? locationArg
109
+ : location;
110
+ this.useEffect(() => {
111
+ const normalizedLocation = typeof stableLocationParam === "string" ? { pathname: stableLocationParam } : stableLocationParam;
112
+ if (isMountRenderPass) {
113
+ this.onRouteChange(normalizedLocation, routes, true);
114
+ isMountRenderPass = false;
115
+ }
116
+ else {
117
+ this.onRouteChange(normalizedLocation, routes);
118
+ }
119
+ }, [stableLocationParam]);
120
+ return Routes;
121
+ };
122
+ return React.createElement(SentryRoutes, null);
123
+ };
124
+ return useRoutes;
125
+ };
126
+ }
127
+ const INITIAL_TRANSACTION_CONTEXT = {
128
+ name: "App Launch",
129
+ op: "navigation",
130
+ tags: {
131
+ ["routing.instrumentation"]: ReactRouterV6Instrumentation.instrumentationName,
132
+ },
133
+ };
134
+ export { ReactRouterV6Instrumentation };
@@ -0,0 +1,22 @@
1
+ import { TransactionContext } from "@sentry/types";
2
+ import { NavigationCurrentRoute, NavigationRoute } from "./types";
3
+ interface NavigationTransactionContext extends TransactionContext {
4
+ readonly tags: {
5
+ readonly ["routing.instrumentation"]: string;
6
+ readonly ["routing.route.name"]: string;
7
+ };
8
+ readonly data: {
9
+ readonly route: NavigationCurrentRoute;
10
+ readonly previousRoute: NavigationRoute | null;
11
+ };
12
+ }
13
+ interface TransactionContextFunctionArgs {
14
+ readonly instrumentationName: string;
15
+ readonly route: NavigationCurrentRoute;
16
+ readonly previousRoute?: NavigationRoute;
17
+ }
18
+ interface TransactionContextFunction {
19
+ (args: TransactionContextFunctionArgs): NavigationTransactionContext;
20
+ }
21
+ declare const transactionContext: TransactionContextFunction;
22
+ export { transactionContext };
@@ -0,0 +1,15 @@
1
+ const transactionContext = ({ instrumentationName, route, previousRoute = null, }) => {
2
+ return {
3
+ name: route.name,
4
+ op: "navigation",
5
+ tags: {
6
+ ["routing.instrumentation"]: instrumentationName,
7
+ ["routing.route.name"]: route.name,
8
+ },
9
+ data: {
10
+ route,
11
+ previousRoute,
12
+ },
13
+ };
14
+ };
15
+ export { transactionContext };
@@ -0,0 +1,27 @@
1
+ import { RoutingInstrumentation } from "@sentry/react-native";
2
+ import { OnConfirmRoute, TransactionCreator } from "@sentry/react-native/dist/js/tracing/routingInstrumentation";
3
+ import { BeforeNavigate } from "@sentry/react-native/dist/js/tracing/types";
4
+ import { MatchRoutes, UseEffect, UseLocation, UseNavigationType, WrapUseRoutes } from "./types";
5
+ declare class ReactRouterV6Instrumentation extends RoutingInstrumentation {
6
+ static instrumentationName: string;
7
+ private useEffect;
8
+ private useLocation;
9
+ private useNavigationType;
10
+ private matchRoutes;
11
+ private prevRoute?;
12
+ private recentRouteKeys;
13
+ private latestTransaction?;
14
+ private shouldUpdateLatestTransaction;
15
+ constructor(useEffect: UseEffect, useLocation: UseLocation, useNavigationType: UseNavigationType, matchRoutes: MatchRoutes);
16
+ /**
17
+ * Extends by calling _handleInitialState at the end.
18
+ */
19
+ registerRoutingInstrumentation(listener: TransactionCreator, beforeNavigate: BeforeNavigate, onConfirmRoute: OnConfirmRoute): void;
20
+ /**
21
+ * Starts an idle transaction for the initial state which won't get called by the router listener.
22
+ */
23
+ private handleInitialState;
24
+ private getTransactionContext;
25
+ wrapUseRoutes: WrapUseRoutes;
26
+ }
27
+ export { ReactRouterV6Instrumentation };
@@ -0,0 +1,115 @@
1
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
2
+ import { RoutingInstrumentation } from "@sentry/react-native";
3
+ import { logger } from "@sentry/utils";
4
+ import React from "react";
5
+ class ReactRouterV6Instrumentation extends RoutingInstrumentation {
6
+ static instrumentationName = "react-router-v6";
7
+ useEffect;
8
+ useLocation;
9
+ useNavigationType;
10
+ matchRoutes;
11
+ // @ts-ignore
12
+ prevRoute;
13
+ recentRouteKeys = [];
14
+ // @ts-ignore
15
+ latestTransaction;
16
+ // @ts-ignore
17
+ shouldUpdateLatestTransaction = false;
18
+ constructor(useEffect, useLocation, useNavigationType, matchRoutes) {
19
+ super();
20
+ this.useEffect = useEffect;
21
+ this.useLocation = useLocation;
22
+ this.useNavigationType = useNavigationType;
23
+ this.matchRoutes = matchRoutes;
24
+ }
25
+ /**
26
+ * Extends by calling _handleInitialState at the end.
27
+ */
28
+ registerRoutingInstrumentation(listener, beforeNavigate, onConfirmRoute) {
29
+ super.registerRoutingInstrumentation(listener, beforeNavigate, onConfirmRoute);
30
+ // Need to handle the initial state as the router patch will only attach transactions on subsequent route changes.
31
+ this.handleInitialState();
32
+ }
33
+ /**
34
+ * Starts an idle transaction for the initial state which won't get called by the router listener.
35
+ */
36
+ handleInitialState() {
37
+ this.latestTransaction = this.onRouteWillChange(INITIAL_TRANSACTION_CONTEXT);
38
+ // We set this to true so when registerAppContainer is called, the transaction gets updated with the actual route data
39
+ this.shouldUpdateLatestTransaction = true;
40
+ }
41
+ // @ts-ignore
42
+ getTransactionContext(route, previousRoute) {
43
+ return {
44
+ name: route.name,
45
+ op: "navigation",
46
+ tags: {
47
+ ["routing.instrumentation"]: ReactRouterV6Instrumentation.instrumentationName,
48
+ ["routing.route.name"]: route.name,
49
+ },
50
+ data: {
51
+ route: {
52
+ name: route.name,
53
+ key: route.key,
54
+ params: route.params ?? {},
55
+ hasBeenSeen: this.recentRouteKeys.includes(route.key),
56
+ },
57
+ previousRoute: previousRoute
58
+ ? {
59
+ name: previousRoute.name,
60
+ key: previousRoute.key,
61
+ params: previousRoute.params ?? {},
62
+ }
63
+ : null,
64
+ },
65
+ };
66
+ }
67
+ wrapUseRoutes = (origUseRoutes) => {
68
+ if (!this.useEffect ||
69
+ !this.useLocation ||
70
+ !this.useNavigationType ||
71
+ !this.matchRoutes
72
+ // !this._customStartTransaction
73
+ ) {
74
+ __DEBUG_BUILD__ &&
75
+ logger.warn("reactRouterV6Instrumentation was unable to wrap `useRoutes` because of one or more missing parameters.");
76
+ return origUseRoutes;
77
+ }
78
+ let isMountRenderPass = true;
79
+ // eslint-disable-next-line react/display-name
80
+ return (routes, locationArg) => {
81
+ const SentryRoutes = () => {
82
+ const Routes = origUseRoutes(routes, locationArg);
83
+ const location = this.useLocation();
84
+ const navigationType = this.useNavigationType();
85
+ // A value with stable identity to either pick `locationArg` if available or `location` if not
86
+ const stableLocationParam = typeof locationArg === "string" || (locationArg && locationArg.pathname)
87
+ ? locationArg
88
+ : location;
89
+ this.useEffect(() => {
90
+ const normalizedLocation = typeof stableLocationParam === "string" ? { pathname: stableLocationParam } : stableLocationParam;
91
+ if (isMountRenderPass) {
92
+ console.log("updatePageloadTransaction", normalizedLocation, routes);
93
+ // updatePageloadTransaction(normalizedLocation, routes);
94
+ isMountRenderPass = false;
95
+ }
96
+ else {
97
+ console.log("normalizedLocation", normalizedLocation, routes, navigationType);
98
+ // handleNavigation(normalizedLocation, routes, navigationType);
99
+ }
100
+ }, [navigationType, stableLocationParam]);
101
+ return Routes;
102
+ };
103
+ return React.createElement(SentryRoutes, null);
104
+ };
105
+ };
106
+ }
107
+ const INITIAL_TRANSACTION_CONTEXT = {
108
+ name: "App Launch",
109
+ op: "navigation",
110
+ tags: {
111
+ ["routing.instrumentation"]: ReactRouterV6Instrumentation.instrumentationName,
112
+ },
113
+ data: {},
114
+ };
115
+ export { ReactRouterV6Instrumentation };
@@ -0,0 +1,18 @@
1
+ import { Command } from "@lookiero/messaging";
2
+ import { NotificationType } from "../model/notification";
3
+ declare const CREATE_MODAL_NOTIFICATION = "create_modal_notification";
4
+ interface CreateModalNotificationPayload {
5
+ readonly aggregateId: string;
6
+ readonly bodyI18nKey: string;
7
+ readonly titleI18nKey: string;
8
+ readonly acceptI18nKey: string;
9
+ }
10
+ interface CreateModalNotification extends Command<typeof CREATE_MODAL_NOTIFICATION>, CreateModalNotificationPayload {
11
+ readonly type: NotificationType.MODAL;
12
+ }
13
+ interface CreateModalNotificationFunction {
14
+ (payload: CreateModalNotificationPayload): CreateModalNotification;
15
+ }
16
+ declare const createModalNotification: CreateModalNotificationFunction;
17
+ export type { CreateModalNotification };
18
+ export { CREATE_MODAL_NOTIFICATION, createModalNotification };
@@ -0,0 +1,9 @@
1
+ import { command } from "@lookiero/messaging";
2
+ import { NotificationType } from "../model/notification";
3
+ const CREATE_MODAL_NOTIFICATION = "create_modal_notification";
4
+ const createModalNotification = ({ aggregateId, ...payload }) => ({
5
+ ...command({ aggregateId, name: CREATE_MODAL_NOTIFICATION }),
6
+ ...payload,
7
+ type: NotificationType.MODAL,
8
+ });
9
+ export { CREATE_MODAL_NOTIFICATION, createModalNotification };
@@ -0,0 +1,18 @@
1
+ import { Command } from "@lookiero/messaging";
2
+ import { NotificationLevel, NotificationType } from "../model/notification";
3
+ declare const CREATE_TOAST_NOTIFICATION = "create_toast_notification";
4
+ interface CreateToastNotificationPayload {
5
+ readonly aggregateId: string;
6
+ readonly level: NotificationLevel;
7
+ readonly bodyI18nKey: string;
8
+ readonly titleI18nKey: string | undefined;
9
+ }
10
+ interface CreateToastNotification extends Command<typeof CREATE_TOAST_NOTIFICATION>, CreateToastNotificationPayload {
11
+ readonly type: NotificationType.TOAST;
12
+ }
13
+ interface CreateToastNotificationFunction {
14
+ (payload: CreateToastNotificationPayload): CreateToastNotification;
15
+ }
16
+ declare const createToastNotification: CreateToastNotificationFunction;
17
+ export type { CreateToastNotification };
18
+ export { CREATE_TOAST_NOTIFICATION, createToastNotification };
@@ -0,0 +1,9 @@
1
+ import { command } from "@lookiero/messaging";
2
+ import { NotificationType } from "../model/notification";
3
+ const CREATE_TOAST_NOTIFICATION = "create_toast_notification";
4
+ const createToastNotification = ({ aggregateId, ...payload }) => ({
5
+ ...command({ aggregateId, name: CREATE_TOAST_NOTIFICATION }),
6
+ ...payload,
7
+ type: NotificationType.TOAST,
8
+ });
9
+ export { CREATE_TOAST_NOTIFICATION, createToastNotification };
@@ -0,0 +1,9 @@
1
+ import { removeNotification as sut, REMOVE_NOTIFICATION } from "./removeNotification";
2
+ describe("removeNotification", () => {
3
+ it("returns a RemoveNotification command", () => {
4
+ const aggregateId = "67ac1d5c-6d24-4b19-bc01-8f61c266670c";
5
+ const command = sut({ aggregateId });
6
+ expect(command.aggregateId).toBe(aggregateId);
7
+ expect(command.name).toBe(REMOVE_NOTIFICATION);
8
+ });
9
+ });
@@ -1,18 +1,25 @@
1
1
  import { AggregateRoot, CommandHandlerFunction } from "@lookiero/messaging";
2
- import { CreateNotification } from "../command/createNotification";
2
+ import { CreateModalNotification } from "../command/createModalNotification";
3
+ import { CreateToastNotification } from "../command/createToastNotification";
3
4
  import { RemoveNotification } from "../command/removeNotification";
5
+ declare enum NotificationType {
6
+ TOAST = "TOAST",
7
+ MODAL = "MODAL"
8
+ }
4
9
  declare enum NotificationLevel {
5
10
  INFO = "INFO",
6
11
  ERROR = "ERROR",
7
12
  SUCCESS = "SUCCESS"
8
13
  }
9
- export { NotificationLevel };
10
14
  interface Notification extends AggregateRoot {
15
+ readonly type: NotificationType;
11
16
  readonly level: NotificationLevel;
12
17
  readonly bodyI18nKey: string;
13
18
  readonly titleI18nKey: string | undefined;
19
+ readonly acceptI18nKey: string | undefined;
14
20
  }
15
- declare const createNotificationHandler: CommandHandlerFunction<CreateNotification, Notification>;
21
+ declare const createToastNotificationHandler: CommandHandlerFunction<CreateToastNotification, Notification>;
22
+ declare const createModalNotificationHandler: CommandHandlerFunction<CreateModalNotification, Notification>;
16
23
  declare const removeNotificationHandler: CommandHandlerFunction<RemoveNotification, Notification>;
17
24
  export type { Notification };
18
- export { createNotificationHandler, removeNotificationHandler };
25
+ export { NotificationLevel, NotificationType, createToastNotificationHandler, createModalNotificationHandler, removeNotificationHandler, };
@@ -1,22 +1,38 @@
1
1
  import { notificationCreated } from "./notificationCreated";
2
2
  import { notificationRemoved } from "./notificationRemoved";
3
+ var NotificationType;
4
+ (function (NotificationType) {
5
+ NotificationType["TOAST"] = "TOAST";
6
+ NotificationType["MODAL"] = "MODAL";
7
+ })(NotificationType || (NotificationType = {}));
3
8
  var NotificationLevel;
4
9
  (function (NotificationLevel) {
5
10
  NotificationLevel["INFO"] = "INFO";
6
11
  NotificationLevel["ERROR"] = "ERROR";
7
12
  NotificationLevel["SUCCESS"] = "SUCCESS";
8
13
  })(NotificationLevel || (NotificationLevel = {}));
9
- export { NotificationLevel };
10
- const createNotificationHandler = () => async ({ aggregateRoot, command }) => {
11
- const { aggregateId, level, titleI18nKey, bodyI18nKey } = command;
14
+ const createToastNotificationHandler = () => async ({ aggregateRoot, command }) => {
15
+ const { aggregateId, type, level, titleI18nKey, bodyI18nKey } = command;
12
16
  return {
13
17
  ...aggregateRoot,
18
+ type,
14
19
  level,
15
20
  titleI18nKey,
16
21
  bodyI18nKey,
17
22
  domainEvents: [notificationCreated({ aggregateId })],
18
23
  };
19
24
  };
25
+ const createModalNotificationHandler = () => async ({ aggregateRoot, command }) => {
26
+ const { aggregateId, type, titleI18nKey, bodyI18nKey, acceptI18nKey } = command;
27
+ return {
28
+ ...aggregateRoot,
29
+ type,
30
+ titleI18nKey,
31
+ bodyI18nKey,
32
+ acceptI18nKey,
33
+ domainEvents: [notificationCreated({ aggregateId })],
34
+ };
35
+ };
20
36
  const removeNotificationHandler = () => async ({ aggregateRoot, command }) => {
21
37
  const { aggregateId } = command;
22
38
  return {
@@ -24,4 +40,4 @@ const removeNotificationHandler = () => async ({ aggregateRoot, command }) => {
24
40
  domainEvents: [notificationRemoved({ aggregateId })],
25
41
  };
26
42
  };
27
- export { createNotificationHandler, removeNotificationHandler };
43
+ export { NotificationLevel, NotificationType, createToastNotificationHandler, createModalNotificationHandler, removeNotificationHandler, };
@@ -1,8 +1,9 @@
1
- import { useCreateNotification } from "./infrastructure/domain/notification/react/useCreateNotification";
1
+ import { useCreateModalNotification } from "./infrastructure/domain/notification/react/useCreateModalNotification";
2
+ import { useCreateToastNotification } from "./infrastructure/domain/notification/react/useCreateToastNotification";
2
3
  import { useRemoveNotification } from "./infrastructure/domain/notification/react/useRemoveNotification";
3
4
  import { NotificationDto } from "./infrastructure/persistence/notificationDto";
4
5
  import { Storage } from "./infrastructure/persistence/storage";
5
6
  import { notificationsRoot, NotificationsRoot } from "./infrastructure/ui/notificationsRoot";
6
7
  import { useListNotifications } from "./projection/notification/react/useListNotifications";
7
8
  export type { Storage, NotificationDto, NotificationsRoot };
8
- export { useListNotifications, useCreateNotification, useRemoveNotification, notificationsRoot };
9
+ export { useListNotifications, useCreateToastNotification, useCreateModalNotification, useRemoveNotification, notificationsRoot, };
@@ -1,5 +1,6 @@
1
- import { useCreateNotification } from "./infrastructure/domain/notification/react/useCreateNotification";
1
+ import { useCreateModalNotification } from "./infrastructure/domain/notification/react/useCreateModalNotification";
2
+ import { useCreateToastNotification } from "./infrastructure/domain/notification/react/useCreateToastNotification";
2
3
  import { useRemoveNotification } from "./infrastructure/domain/notification/react/useRemoveNotification";
3
4
  import { notificationsRoot } from "./infrastructure/ui/notificationsRoot";
4
5
  import { useListNotifications } from "./projection/notification/react/useListNotifications";
5
- export { useListNotifications, useCreateNotification, useRemoveNotification, notificationsRoot };
6
+ export { useListNotifications, useCreateToastNotification, useCreateModalNotification, useRemoveNotification, notificationsRoot, };
@@ -1,18 +1,21 @@
1
1
  import { bootstrap as messagingReactBootstrap } from "@lookiero/messaging-react";
2
- import { CREATE_NOTIFICATION } from "../../domain/notification/command/createNotification";
2
+ import { CREATE_MODAL_NOTIFICATION } from "../../domain/notification/command/createModalNotification";
3
+ import { CREATE_TOAST_NOTIFICATION } from "../../domain/notification/command/createToastNotification";
3
4
  import { REMOVE_NOTIFICATION } from "../../domain/notification/command/removeNotification";
4
- import { createNotificationHandler, removeNotificationHandler } from "../../domain/notification/model/notification";
5
+ import { createModalNotificationHandler, createToastNotificationHandler, removeNotificationHandler, } from "../../domain/notification/model/notification";
5
6
  import { listNotificationsHandler, LIST_NOTIFICATIONS } from "../../projection/notification/listNotifications";
6
7
  import { getNotification, saveNotification } from "../domain/notification/model/storageNotifications";
7
8
  import { storageListNotificationsView } from "../projection/notification/storageListNotificationsView";
8
9
  const NOTIFICATIONS_MESSAGING_CONTEXT_ID = "notifications";
9
10
  const bootstrap = ({ storage }) => messagingReactBootstrap({ id: NOTIFICATIONS_MESSAGING_CONTEXT_ID })
10
11
  .query(LIST_NOTIFICATIONS, listNotificationsHandler, { view: storageListNotificationsView({ storage }) })
11
- .command(CREATE_NOTIFICATION, createNotificationHandler)(getNotification, saveNotification, { storage })
12
+ .command(CREATE_TOAST_NOTIFICATION, createToastNotificationHandler)(getNotification, saveNotification, { storage })
13
+ .command(CREATE_MODAL_NOTIFICATION, createModalNotificationHandler)(getNotification, saveNotification, { storage })
12
14
  .command(REMOVE_NOTIFICATION, removeNotificationHandler)(getNotification, saveNotification, { storage })
13
15
  .build();
14
16
  const bootstrapWithBuilder = ({ storage, messaging }) => messaging
15
17
  .query(LIST_NOTIFICATIONS, listNotificationsHandler, { view: storageListNotificationsView({ storage }) })
16
- .command(CREATE_NOTIFICATION, createNotificationHandler)(getNotification, saveNotification, { storage })
18
+ .command(CREATE_TOAST_NOTIFICATION, createToastNotificationHandler)(getNotification, saveNotification, { storage })
19
+ .command(CREATE_MODAL_NOTIFICATION, createModalNotificationHandler)(getNotification, saveNotification, { storage })
17
20
  .command(REMOVE_NOTIFICATION, removeNotificationHandler)(getNotification, saveNotification, { storage });
18
21
  export { NOTIFICATIONS_MESSAGING_CONTEXT_ID, bootstrap, bootstrapWithBuilder };
@@ -1,10 +1,12 @@
1
1
  import { storageNotificationsCreate } from "./storageNotificationsCreate";
2
2
  import { storageNotificationsRemove } from "./storageNotificationsRemove";
3
- const toDomain = ({ aggregateId, level, titleI18nKey, bodyI18nKey }) => ({
3
+ const toDomain = ({ aggregateId, type, level, titleI18nKey, bodyI18nKey, acceptI18nKey, }) => ({
4
4
  aggregateId,
5
+ type,
5
6
  level,
6
7
  titleI18nKey,
7
8
  bodyI18nKey,
9
+ acceptI18nKey,
8
10
  domainEvents: [],
9
11
  });
10
12
  const getNotification = ({ storage }) => async (aggregateId) => {
@@ -1,7 +1,7 @@
1
1
  import { Notification } from "../../../../domain/notification/model/notification";
2
2
  import { NotificationDto } from "../../../persistence/notificationDto";
3
3
  import { StorageNotificationsSaveFunction } from "./storageNotifications";
4
- declare const fromDomain: ({ aggregateId, level, titleI18nKey, bodyI18nKey }: Notification) => NotificationDto;
4
+ declare const fromDomain: ({ aggregateId, type, level, titleI18nKey, bodyI18nKey, acceptI18nKey, }: Notification) => NotificationDto;
5
5
  interface StorageNotificationsCreateFunction extends StorageNotificationsSaveFunction {
6
6
  }
7
7
  declare const storageNotificationsCreate: StorageNotificationsCreateFunction;
@@ -1,9 +1,11 @@
1
1
  import { NOTIFICATION_CREATED } from "../../../../domain/notification/model/notificationCreated";
2
- const fromDomain = ({ aggregateId, level, titleI18nKey, bodyI18nKey }) => ({
2
+ const fromDomain = ({ aggregateId, type, level, titleI18nKey, bodyI18nKey, acceptI18nKey, }) => ({
3
3
  aggregateId,
4
+ type,
4
5
  level,
5
6
  titleI18nKey,
6
7
  bodyI18nKey,
8
+ acceptI18nKey,
7
9
  });
8
10
  const isNotificationCreated = (event) => event.name === NOTIFICATION_CREATED;
9
11
  const storageNotificationsCreate = ({ storage }) => async (aggregateRoot) => {
@@ -0,0 +1,20 @@
1
+ import { CommandStatus } from "@lookiero/messaging-react";
2
+ import { Logger } from "../../../../../logging/Logger";
3
+ interface CreateModalNotificationFunctionArgs {
4
+ readonly aggregateId?: string;
5
+ readonly bodyI18nKey: string;
6
+ readonly titleI18nKey: string;
7
+ readonly acceptI18nKey: string;
8
+ }
9
+ interface CreateModalNotificationFunction {
10
+ (args: CreateModalNotificationFunctionArgs): Promise<void>;
11
+ }
12
+ interface UseCreateModalNotificationFunctionArgs {
13
+ readonly contextId: string;
14
+ readonly logger: Logger;
15
+ }
16
+ interface UseCreateModalNotificationFunction {
17
+ (args: UseCreateModalNotificationFunctionArgs): [create: CreateModalNotificationFunction, status: CommandStatus];
18
+ }
19
+ declare const useCreateModalNotification: UseCreateModalNotificationFunction;
20
+ export { useCreateModalNotification };
@@ -0,0 +1,22 @@
1
+ import { useCommand } from "@lookiero/messaging-react";
2
+ import { useCallback } from "react";
3
+ import { v4 as uuid } from "uuid";
4
+ import { createModalNotification } from "../../../../domain/notification/command/createModalNotification";
5
+ const useCreateModalNotification = ({ contextId, logger }) => {
6
+ const [commandBus, status] = useCommand({ contextId });
7
+ const create = useCallback(async ({ aggregateId, titleI18nKey, bodyI18nKey, acceptI18nKey }) => {
8
+ try {
9
+ await commandBus(createModalNotification({
10
+ aggregateId: aggregateId || uuid(),
11
+ titleI18nKey,
12
+ bodyI18nKey,
13
+ acceptI18nKey,
14
+ }));
15
+ }
16
+ catch (error) {
17
+ logger.captureException(error);
18
+ }
19
+ }, [commandBus, logger]);
20
+ return [create, status];
21
+ };
22
+ export { useCreateModalNotification };
@@ -0,0 +1,21 @@
1
+ import { CommandStatus } from "@lookiero/messaging-react";
2
+ import { Logger } from "../../../../../logging/Logger";
3
+ import { NotificationLevel } from "../../../../domain/notification/model/notification";
4
+ interface CreateToastNotificationFunctionArgs {
5
+ readonly aggregateId?: string;
6
+ readonly level: NotificationLevel;
7
+ readonly bodyI18nKey: string;
8
+ readonly titleI18nKey?: string;
9
+ }
10
+ interface CreateToastNotificationFunction {
11
+ (args: CreateToastNotificationFunctionArgs): Promise<void>;
12
+ }
13
+ interface UseCreateToastNotificationFunctionArgs {
14
+ readonly contextId: string;
15
+ readonly logger: Logger;
16
+ }
17
+ interface UseCreateToastNotificationFunction {
18
+ (args: UseCreateToastNotificationFunctionArgs): [create: CreateToastNotificationFunction, status: CommandStatus];
19
+ }
20
+ declare const useCreateToastNotification: UseCreateToastNotificationFunction;
21
+ export { useCreateToastNotification };
@@ -0,0 +1,22 @@
1
+ import { useCommand } from "@lookiero/messaging-react";
2
+ import { useCallback } from "react";
3
+ import { v4 as uuid } from "uuid";
4
+ import { createToastNotification } from "../../../../domain/notification/command/createToastNotification";
5
+ const useCreateToastNotification = ({ contextId, logger }) => {
6
+ const [commandBus, status] = useCommand({ contextId });
7
+ const create = useCallback(async ({ aggregateId, level, titleI18nKey, bodyI18nKey }) => {
8
+ try {
9
+ await commandBus(createToastNotification({
10
+ aggregateId: aggregateId || uuid(),
11
+ level,
12
+ titleI18nKey,
13
+ bodyI18nKey,
14
+ }));
15
+ }
16
+ catch (error) {
17
+ logger.captureException(error);
18
+ }
19
+ }, [commandBus, logger]);
20
+ return [create, status];
21
+ };
22
+ export { useCreateToastNotification };