@lookiero/checkout 0.8.3 → 0.8.4-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.
- package/dist/domain/checkout/command/markCheckoutAsPaid.d.ts +13 -0
- package/dist/domain/checkout/command/markCheckoutAsPaid.js +4 -0
- package/dist/domain/checkout/model/checkout.js +1 -0
- package/dist/domain/checkout/model/checkoutPaid.d.ts +13 -0
- package/dist/domain/checkout/model/checkoutPaid.js +4 -0
- package/dist/infrastructure/delivery/http/fetchHttpClient.js +36 -19
- package/dist/infrastructure/delivery/http/httpClient.d.ts +9 -3
- package/dist/infrastructure/domain/checkout/model/httpCheckoutsMarkAsPaid.d.ts +5 -0
- package/dist/infrastructure/domain/checkout/model/httpCheckoutsMarkAsPaid.js +13 -0
- package/dist/infrastructure/domain/checkout/react/useMarkCheckoutAsPaid.d.ts +13 -0
- package/dist/infrastructure/domain/checkout/react/useMarkCheckoutAsPaid.js +16 -0
- package/dist/infrastructure/domain/checkout/react/useStartCheckout.d.ts +1 -1
- package/dist/infrastructure/domain/checkout/react/useStartCheckout.js +9 -2
- package/dist/infrastructure/domain/checkoutBooking/react/useBookCheckouBookingForCheckoutItem.d.ts +13 -0
- package/dist/infrastructure/domain/checkoutBooking/react/useBookCheckouBookingForCheckoutItem.js +14 -0
- package/dist/infrastructure/domain/uiSetting/react/useIncrementIntroShownCount.d.ts +10 -0
- package/dist/infrastructure/domain/uiSetting/react/useIncrementIntroShownCount.js +11 -0
- package/dist/infrastructure/projection/bookedProductsVariants/httpBookedProductsVariantsForCheckoutItemView.js +9 -8
- package/dist/infrastructure/projection/bookedSizeChangeProductsVariants/httpBookedSizeChangeProductsVariantsForCheckoutItemView.d.ts +12 -0
- package/dist/infrastructure/projection/bookedSizeChangeProductsVariants/httpBookedSizeChangeProductsVariantsForCheckoutItemView.js +9 -0
- package/dist/infrastructure/projection/bookedSizeChangeProductsVariants/react/useViewBookedSizeChangeProductsVariantsForCheckoutItem.d.ts +10 -0
- package/dist/infrastructure/projection/bookedSizeChangeProductsVariants/react/useViewBookedSizeChangeProductsVariantsForCheckoutItem.js +12 -0
- package/dist/infrastructure/projection/checkout/httpCheckoutByIdView.js +9 -8
- package/dist/infrastructure/projection/checkout/httpFirstAvailableCheckoutByCustomerIdView.js +9 -8
- package/dist/infrastructure/projection/checkout/httpFiveItemsDiscountByCustomerIdView.js +8 -7
- package/dist/infrastructure/projection/checkout/httpIsCheckoutEnabledByCustomerIdView.js +8 -7
- package/dist/infrastructure/projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId.js +1 -4
- package/dist/infrastructure/projection/checkoutBooking/httpCheckoutBookingByIdView.js +9 -8
- package/dist/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackByCheckoutIdView.d.ts +12 -0
- package/dist/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackByCheckoutIdView.js +9 -0
- package/dist/infrastructure/projection/checkoutItem/httpCheckoutItemByIdView.js +9 -8
- package/dist/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.js +9 -8
- package/dist/infrastructure/projection/payment/httpPaymentFlowPayloadByCheckoutIdView.js +9 -8
- package/dist/infrastructure/projection/pricing/httpPricingByCheckoutIdView.js +9 -8
- package/dist/infrastructure/projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView.js +9 -8
- package/dist/infrastructure/projection/uiSetting/react/useShouldIntroBeShown.d.ts +6 -0
- package/dist/infrastructure/projection/uiSetting/react/useShouldIntroBeShown.js +7 -0
- package/dist/infrastructure/projection/uiSetting/react/useViewIntroShownCount.d.ts +6 -0
- package/dist/infrastructure/projection/uiSetting/react/useViewIntroShownCount.js +9 -0
- package/dist/infrastructure/ui/Root.js +2 -1
- package/dist/infrastructure/ui/views/App.style.d.ts +4 -0
- package/dist/infrastructure/ui/views/App.style.js +16 -0
- package/dist/infrastructure/ui/views/checkout/Checkout.js +5 -3
- package/dist/infrastructure/ui/views/header/Header.d.ts +15 -0
- package/dist/infrastructure/ui/views/header/Header.js +90 -0
- package/dist/infrastructure/ui/views/header/Header.style.d.ts +35 -0
- package/dist/infrastructure/ui/views/header/Header.style.js +38 -0
- package/dist/infrastructure/ui/views/header/components/Logo.d.ts +7 -0
- package/dist/infrastructure/ui/views/header/components/Logo.js +11 -0
- package/dist/infrastructure/ui/views/header/components/Logo.style.d.ts +7 -0
- package/dist/infrastructure/ui/views/header/components/Logo.style.js +8 -0
- package/dist/infrastructure/ui/views/intro/Intro.d.ts +6 -0
- package/dist/infrastructure/ui/views/intro/Intro.js +52 -0
- package/dist/infrastructure/ui/views/intro/Intro.style.d.ts +55 -0
- package/dist/infrastructure/ui/views/intro/Intro.style.js +58 -0
- package/dist/projection/bookedSizeChangeProductsVariants/bookedSizeChangeProductsVariants.d.ts +10 -0
- package/dist/projection/bookedSizeChangeProductsVariants/bookedSizeChangeProductsVariants.js +1 -0
- package/dist/projection/bookedSizeChangeProductsVariants/viewBookedSizeChangeProductVariantsForCheckoutItem.d.ts +25 -0
- package/dist/projection/bookedSizeChangeProductsVariants/viewBookedSizeChangeProductVariantsForCheckoutItem.js +8 -0
- package/dist/projection/checkoutFeedback/viewCheckoutFeedbackByCheckoutId.d.ts +25 -0
- package/dist/projection/checkoutFeedback/viewCheckoutFeedbackByCheckoutId.js +8 -0
- package/dist/shared/logging/Logger.d.ts +7 -0
- package/dist/shared/logging/Logger.js +1 -0
- package/dist/shared/logging/SentryLogger.d.ts +3 -8
- package/dist/shared/logging/SentryLogger.js +27 -33
- package/dist/shared/logging/SentryLoggerHOC.d.ts +15 -0
- package/dist/shared/logging/SentryLoggerHOC.js +22 -0
- package/dist/shared/logging/location.d.ts +3 -0
- package/dist/shared/logging/location.js +5 -0
- package/dist/shared/logging/matchRoutes.d.ts +3 -0
- package/dist/shared/logging/matchRoutes.js +7 -0
- package/dist/shared/logging/reactRouterV6Instrumentation/reactRouterV6Instrumentation.native.d.ts +29 -0
- package/dist/shared/logging/reactRouterV6Instrumentation/reactRouterV6Instrumentation.native.js +134 -0
- package/dist/shared/logging/reactRouterV6Instrumentation/transactionContext.d.ts +22 -0
- package/dist/shared/logging/reactRouterV6Instrumentation/transactionContext.js +15 -0
- package/dist/shared/logging/reactRouterV6Instrumentation.native.d.ts +27 -0
- package/dist/shared/logging/reactRouterV6Instrumentation.native.js +115 -0
- package/dist/shared/notifications/domain/notification/command/removeNotification.tes.d.ts +1 -0
- package/dist/shared/notifications/domain/notification/command/removeNotification.tes.js +9 -0
- package/package.json +2 -1
- package/dist/infrastructure/ui/hooks/usePaymentInstrumentEvents.d.ts +0 -2
- package/dist/infrastructure/ui/hooks/usePaymentInstrumentEvents.js +0 -28
- package/dist/infrastructure/ui/hooks/useToast.d.ts +0 -11
- package/dist/infrastructure/ui/hooks/useToast.js +0 -44
- package/dist/infrastructure/ui/views/checkout/components/paymentInstrument/PaymentInstrument.d.ts +0 -6
- package/dist/infrastructure/ui/views/checkout/components/paymentInstrument/PaymentInstrument.js +0 -10
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
import { ComponentType } from "react";
|
|
2
1
|
import { Platform } from "react-native";
|
|
2
|
+
import { Logger } from "./Logger";
|
|
3
3
|
interface SentryLoggerFunctionArgs {
|
|
4
4
|
readonly publicKey: string;
|
|
5
5
|
readonly environment: `${typeof Platform.OS}-${"DEV" | "PROD" | "EXPO"}`;
|
|
6
6
|
readonly release: string;
|
|
7
7
|
readonly project: string;
|
|
8
8
|
}
|
|
9
|
-
interface SentryLoggerHOCProps {
|
|
10
|
-
readonly customer: {
|
|
11
|
-
readonly customerId: string;
|
|
12
|
-
} | undefined;
|
|
13
|
-
}
|
|
14
9
|
interface SentryLoggerFunction {
|
|
15
|
-
(args: SentryLoggerFunctionArgs):
|
|
10
|
+
(args: SentryLoggerFunctionArgs): Logger;
|
|
16
11
|
}
|
|
17
12
|
declare const sentryLogger: SentryLoggerFunction;
|
|
18
|
-
export type { SentryLoggerFunctionArgs
|
|
13
|
+
export type { SentryLoggerFunctionArgs };
|
|
19
14
|
export { sentryLogger };
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { defaultStackParser } from "@sentry/browser";
|
|
2
2
|
import { makeMain } from "@sentry/core";
|
|
3
|
-
import React, { useEffect } from "react";
|
|
4
3
|
import { Platform } from "react-native";
|
|
5
|
-
import {
|
|
6
|
-
import { Client, Hub, transport, integrations, wrapUseRoutes, wrapComponent, ErrorBoundary, } from "./SentryDependencies";
|
|
4
|
+
import { Client, Hub, integrations, transport } from "./SentryDependencies";
|
|
7
5
|
// This configuration is obtained from
|
|
8
6
|
// https://docs.sentry.io/clients/javascript/tips/#decluttering-sentry
|
|
9
7
|
const IGNORED_ERRORS = [
|
|
@@ -51,10 +49,10 @@ const DENIED_URLS = [
|
|
|
51
49
|
/webappstoolbarba\.texthelp\.com\//i,
|
|
52
50
|
/metrics\.itunes\.apple\.com\.edgesuite\.net\//i,
|
|
53
51
|
];
|
|
54
|
-
const sentryLogger = ({
|
|
52
|
+
const sentryLogger = ({ environment, release, publicKey, project }) => {
|
|
55
53
|
let globalHub;
|
|
56
54
|
let currentHub;
|
|
57
|
-
const
|
|
55
|
+
const createHub = () => {
|
|
58
56
|
const client = new Client({
|
|
59
57
|
environment,
|
|
60
58
|
release,
|
|
@@ -72,28 +70,30 @@ const sentryLogger = ({ publicKey, environment, release, project }) => {
|
|
|
72
70
|
});
|
|
73
71
|
return new Hub(client);
|
|
74
72
|
};
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
73
|
+
const init = () => {
|
|
74
|
+
/**
|
|
75
|
+
* BrowserClient must be initialized before wrapUseRoutes is used.
|
|
76
|
+
*
|
|
77
|
+
* ReactNativeClient cannot be initialized until actual component is rendered.
|
|
78
|
+
* Its initialization will trigger the native sdk setup with the provided settings,
|
|
79
|
+
* but by the time an event will be sent to Sentry, the host project (UAF)
|
|
80
|
+
* will have overridden its configuration (dsn, etc) after initializing it
|
|
81
|
+
* so we have to initialize it after the component mount.
|
|
82
|
+
*/
|
|
83
|
+
if (Platform.OS === "web") {
|
|
84
|
+
currentHub = createHub();
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
87
|
const onMount = (customerId) => {
|
|
88
88
|
// currentHub won't be initialized in native until this time
|
|
89
|
-
currentHub = currentHub ??
|
|
89
|
+
currentHub = currentHub ?? createHub();
|
|
90
90
|
currentHub.setUser({ id: customerId });
|
|
91
91
|
currentHub.startSession();
|
|
92
92
|
if (!globalHub) {
|
|
93
93
|
globalHub = makeMain(currentHub);
|
|
94
94
|
}
|
|
95
95
|
};
|
|
96
|
-
const
|
|
96
|
+
const onUnmount = () => {
|
|
97
97
|
if (currentHub) {
|
|
98
98
|
currentHub.endSession();
|
|
99
99
|
currentHub.setUser(null);
|
|
@@ -104,20 +104,14 @@ const sentryLogger = ({ publicKey, environment, release, project }) => {
|
|
|
104
104
|
globalHub = null;
|
|
105
105
|
}
|
|
106
106
|
};
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
116
|
-
}, []);
|
|
117
|
-
return (React.createElement(ErrorBoundary, null,
|
|
118
|
-
React.createElement(WrappedComponent, { ...props, useRoutes: useRoutes })));
|
|
119
|
-
};
|
|
120
|
-
return SentryLogger;
|
|
107
|
+
const captureException = (error) => {
|
|
108
|
+
currentHub?.captureException(error);
|
|
109
|
+
};
|
|
110
|
+
return {
|
|
111
|
+
init,
|
|
112
|
+
onMount,
|
|
113
|
+
onUnmount,
|
|
114
|
+
captureException,
|
|
121
115
|
};
|
|
122
116
|
};
|
|
123
117
|
export { sentryLogger };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ComponentType } from "react";
|
|
2
|
+
import { Logger } from "./Logger";
|
|
3
|
+
interface SentryLoggerHOCFunctionArgs {
|
|
4
|
+
readonly logger: Logger;
|
|
5
|
+
}
|
|
6
|
+
interface SentryLoggerHOCProps {
|
|
7
|
+
readonly customer: {
|
|
8
|
+
readonly customerId: string;
|
|
9
|
+
} | undefined;
|
|
10
|
+
}
|
|
11
|
+
interface SentryLoggerHOCFunction {
|
|
12
|
+
(args: SentryLoggerHOCFunctionArgs): <P extends SentryLoggerHOCProps>(Component: ComponentType<P>) => ComponentType<P & JSX.IntrinsicAttributes>;
|
|
13
|
+
}
|
|
14
|
+
declare const sentryLoggerHOC: SentryLoggerHOCFunction;
|
|
15
|
+
export { sentryLoggerHOC };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React, { useEffect } from "react";
|
|
2
|
+
import { useRoutes as reactRouterUseRoutes } from "react-router-native";
|
|
3
|
+
import { wrapUseRoutes, wrapComponent, ErrorBoundary } from "./SentryDependencies";
|
|
4
|
+
const sentryLoggerHOC = ({ logger }) => {
|
|
5
|
+
logger.init();
|
|
6
|
+
const useRoutes = wrapUseRoutes(reactRouterUseRoutes);
|
|
7
|
+
return (Component) => {
|
|
8
|
+
const WrappedComponent = wrapComponent(Component);
|
|
9
|
+
const SentryLogger = (props) => {
|
|
10
|
+
const { customer } = props;
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
logger.onMount(customer?.customerId);
|
|
13
|
+
return logger.onUnmount;
|
|
14
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15
|
+
}, []);
|
|
16
|
+
return (React.createElement(ErrorBoundary, null,
|
|
17
|
+
React.createElement(WrappedComponent, { ...props, useRoutes: useRoutes })));
|
|
18
|
+
};
|
|
19
|
+
return SentryLogger;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export { sentryLoggerHOC };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Remove the location's first path ("/checkout"). Otherwise it won't match the proper route.
|
|
2
|
+
const stripFirstSlugFromLocation = (locationArg) => ({
|
|
3
|
+
pathname: (typeof locationArg === "string" ? locationArg : locationArg?.pathname || "").replace(/^\/\w+/, ""),
|
|
4
|
+
});
|
|
5
|
+
export { stripFirstSlugFromLocation };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { matchRoutes as reactRouterMatchRoutes } from "@remix-run/router";
|
|
2
|
+
const matchRoutes = (routes, locationArg) => {
|
|
3
|
+
// Remove the location's first path ("/checkout"). Otherwise it won't match the proper route.
|
|
4
|
+
const location = (typeof locationArg === "string" ? locationArg : locationArg?.pathname || "").replace(/^\/\w+/, "");
|
|
5
|
+
return reactRouterMatchRoutes(routes, location);
|
|
6
|
+
};
|
|
7
|
+
export { matchRoutes };
|
package/dist/shared/logging/reactRouterV6Instrumentation/reactRouterV6Instrumentation.native.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
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, WrapUseRoutes } from "../types";
|
|
5
|
+
/**
|
|
6
|
+
* This instrumentation has been built taking as an example the actual
|
|
7
|
+
* ReactNavigationV4Instrumentation implementation as suggested in the documentation.
|
|
8
|
+
*
|
|
9
|
+
* (https://docs.sentry.io/platforms/react-native/performance/instrumentation/automatic-instrumentation/#custom-instrumentation)
|
|
10
|
+
* (https://github.com/getsentry/sentry-react-native/blob/211ec081b6bf8d7d29541afe9d800040f61e3c4e/src/js/tracing/reactnavigationv4.ts)
|
|
11
|
+
*/
|
|
12
|
+
declare class ReactRouterV6Instrumentation extends RoutingInstrumentation {
|
|
13
|
+
static instrumentationName: string;
|
|
14
|
+
private useEffect;
|
|
15
|
+
private useLocation;
|
|
16
|
+
private matchRoutes;
|
|
17
|
+
private prevRoute?;
|
|
18
|
+
private recentRouteKeys;
|
|
19
|
+
private latestTransaction?;
|
|
20
|
+
private readonly maxRecentRouteLen;
|
|
21
|
+
constructor(useEffect: UseEffect, useLocation: UseLocation, matchRoutes: MatchRoutes);
|
|
22
|
+
registerRoutingInstrumentation(listener: TransactionCreator, beforeNavigate: BeforeNavigate, onConfirmRoute: OnConfirmRoute): void;
|
|
23
|
+
private onRouteChange;
|
|
24
|
+
private currentRouteFromLocation;
|
|
25
|
+
private pushRecentRouteKey;
|
|
26
|
+
private onBeforeNavigateNotSampled;
|
|
27
|
+
wrapUseRoutes: WrapUseRoutes;
|
|
28
|
+
}
|
|
29
|
+
export { ReactRouterV6Instrumentation };
|
package/dist/shared/logging/reactRouterV6Instrumentation/reactRouterV6Instrumentation.native.js
ADDED
|
@@ -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 @@
|
|
|
1
|
+
export {};
|
|
@@ -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
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lookiero/checkout",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4-beta.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -110,6 +110,7 @@
|
|
|
110
110
|
"prettier": "^2.7.1",
|
|
111
111
|
"react": "^18.0.0",
|
|
112
112
|
"react-dom": "^18.0.0",
|
|
113
|
+
"react-error-overlay": "^6.0.9",
|
|
113
114
|
"react-native": "^0.70.6",
|
|
114
115
|
"react-native-adjust": "^4.33.0",
|
|
115
116
|
"react-native-get-random-values": "^1.8.0",
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { useEvent } from "@lookiero/event";
|
|
2
|
-
import { useCallback, useEffect } from "react";
|
|
3
|
-
import { useCreateNotification } from "../../../shared/notifications";
|
|
4
|
-
import { MESSAGING_CONTEXT_ID } from "../../delivery/baseBootstrap";
|
|
5
|
-
import { I18nMessages } from "../i18n/i18n";
|
|
6
|
-
import { useToast } from "./useToast";
|
|
7
|
-
const PAYMENT_ERROR = "ERROR";
|
|
8
|
-
const PAYMENT_SUCCESS = "PAYMENT_INSTRUMENT_UPDATED";
|
|
9
|
-
const usePaymentInstrumentEvents = () => {
|
|
10
|
-
const { subscribe, unsubscribe } = useEvent();
|
|
11
|
-
const { showError, showSuccess } = useToast();
|
|
12
|
-
const [createNotification] = useCreateNotification({ contextId: MESSAGING_CONTEXT_ID });
|
|
13
|
-
const onSuccess = useCallback(({ message }) => showSuccess({ message: message.id }), [showSuccess]);
|
|
14
|
-
const onError = useCallback(({ error }) => {
|
|
15
|
-
if (error.toaster) {
|
|
16
|
-
showError({ message: error.toaster.id || I18nMessages.CHECKOUT_TOAST_PAYMENT_ERROR });
|
|
17
|
-
}
|
|
18
|
-
}, [showError]);
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
subscribe({ event: PAYMENT_ERROR }, onError);
|
|
21
|
-
subscribe({ event: PAYMENT_SUCCESS }, onSuccess);
|
|
22
|
-
return () => {
|
|
23
|
-
unsubscribe({ event: PAYMENT_ERROR }, onError);
|
|
24
|
-
unsubscribe({ event: PAYMENT_SUCCESS }, onSuccess);
|
|
25
|
-
};
|
|
26
|
-
}, [subscribe, unsubscribe, createNotification, onError, onSuccess]);
|
|
27
|
-
};
|
|
28
|
-
export { usePaymentInstrumentEvents };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
interface ShowErrorFunctionArgs {
|
|
2
|
-
readonly message: string;
|
|
3
|
-
}
|
|
4
|
-
interface ShowErrorFunction {
|
|
5
|
-
(args: ShowErrorFunctionArgs): void;
|
|
6
|
-
}
|
|
7
|
-
declare const useToast: () => {
|
|
8
|
-
showError: ShowErrorFunction;
|
|
9
|
-
showSuccess: ShowErrorFunction;
|
|
10
|
-
};
|
|
11
|
-
export { useToast };
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { Notification } from "@lookiero/aurora-next/build/components/molecules/Notification/Notification";
|
|
2
|
-
import { useStack } from "@lookiero/aurora-next/build/contexts/Stack/Stack";
|
|
3
|
-
import { useIntl } from "@lookiero/i18n-react";
|
|
4
|
-
import { useCallback } from "react";
|
|
5
|
-
import { StyleSheet } from "react-native";
|
|
6
|
-
import { v4 as uuid } from "uuid";
|
|
7
|
-
import { theme } from "../theme/theme";
|
|
8
|
-
const { layoutXXS, elevationColor, elevationOffset, elevationOpacityM, elevationRadius } = theme();
|
|
9
|
-
const style = StyleSheet.create({
|
|
10
|
-
container: {
|
|
11
|
-
marginHorizontal: layoutXXS,
|
|
12
|
-
marginTop: layoutXXS,
|
|
13
|
-
shadowColor: elevationColor,
|
|
14
|
-
shadowOffset: elevationOffset,
|
|
15
|
-
shadowOpacity: elevationOpacityM,
|
|
16
|
-
shadowRadius: elevationRadius,
|
|
17
|
-
},
|
|
18
|
-
inAppContainer: {
|
|
19
|
-
top: 75,
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
const NOTIFICATION_DEFAULTS = {
|
|
23
|
-
motion: "top",
|
|
24
|
-
timeoutClose: 10000,
|
|
25
|
-
style: style.container,
|
|
26
|
-
};
|
|
27
|
-
const IN_APP_NOTIFICATION_DEFAULTS = {
|
|
28
|
-
...NOTIFICATION_DEFAULTS,
|
|
29
|
-
style: [style.container, style.inAppContainer],
|
|
30
|
-
};
|
|
31
|
-
const iOSInAppBrowser = window.screen?.height > 667 && /FBIOS/.test(navigator.userAgent);
|
|
32
|
-
const getNotificationDefaults = () => (iOSInAppBrowser ? IN_APP_NOTIFICATION_DEFAULTS : NOTIFICATION_DEFAULTS);
|
|
33
|
-
const useToast = () => {
|
|
34
|
-
const Stack = useStack();
|
|
35
|
-
const intl = useIntl();
|
|
36
|
-
const translate = useCallback((message) => intl.formatMessage({ id: message, defaultMessage: message }), [intl]);
|
|
37
|
-
const showError = useCallback(({ message }) => Stack.alert(uuid(), Notification, { ...getNotificationDefaults(), text: translate(message) }), [Stack, translate]);
|
|
38
|
-
const showSuccess = useCallback(({ message }) => Stack.success(uuid(), Notification, { ...getNotificationDefaults(), text: translate(message) }), [Stack, translate]);
|
|
39
|
-
return {
|
|
40
|
-
showError,
|
|
41
|
-
showSuccess,
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
export { useToast };
|