@lookiero/checkout 0.6.0-beta.26 → 0.6.0-beta.28
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/infrastructure/ui/Root.d.ts +2 -2
- package/dist/infrastructure/ui/Root.js +3 -3
- package/dist/infrastructure/ui/routing/Routing.d.ts +5 -11
- package/dist/infrastructure/ui/routing/Routing.js +22 -62
- package/dist/shared/logging/SentryDependencies.d.ts +1 -1
- package/dist/shared/logging/SentryDependencies.js +4 -3
- package/dist/shared/logging/SentryDependencies.native.d.ts +1 -1
- package/dist/shared/logging/SentryDependencies.native.js +1 -1
- package/dist/shared/logging/SentryLogger.d.ts +1 -0
- package/dist/shared/logging/SentryLogger.js +7 -6
- package/dist/shared/logging/matchRoutes.d.ts +6 -0
- package/dist/shared/logging/matchRoutes.js +3 -0
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { I18n } from "@lookiero/i18n-react";
|
|
2
2
|
import { MessagingRoot } from "@lookiero/messaging-react/bootstrap";
|
|
3
3
|
import { ComponentType } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { Routes as ReactRouterRoutes } from "react-router-native";
|
|
5
5
|
import { Customer } from "../../projection/shared/customer";
|
|
6
6
|
import { SentryLoggerFunctionArgs } from "../../shared/logging/SentryLogger";
|
|
7
7
|
import { Menu, TabBar } from "./views/navigation/Navigation";
|
|
@@ -23,7 +23,7 @@ interface RootProps {
|
|
|
23
23
|
readonly tabBar: TabBar;
|
|
24
24
|
readonly onNotAccessible: () => void;
|
|
25
25
|
readonly useRedirect: () => Record<string, string>;
|
|
26
|
-
readonly
|
|
26
|
+
readonly rootRoutes?: typeof ReactRouterRoutes;
|
|
27
27
|
}
|
|
28
28
|
declare const root: RootFunction;
|
|
29
29
|
export type { RootProps };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import React, { useCallback } from "react";
|
|
2
2
|
import { Platform } from "react-native";
|
|
3
|
-
import {
|
|
3
|
+
import { Routes as ReactRouterRoutes } from "react-router-native";
|
|
4
4
|
import { sentryLogger } from "../../shared/logging/SentryLogger";
|
|
5
5
|
import { Routing } from "./routing/Routing";
|
|
6
6
|
const root = ({ Messaging, I18n, getAuthToken, development, sentry }) => {
|
|
7
7
|
// eslint-disable-next-line react/display-name, react/prop-types
|
|
8
|
-
const Root = ({ basePath, locale = "en", customer, menu, tabBar, onNotAccessible, useRedirect,
|
|
8
|
+
const Root = ({ basePath, locale = "en", customer, menu, tabBar, onNotAccessible, useRedirect, rootRoutes = ReactRouterRoutes, }) => {
|
|
9
9
|
const handleOnI18nError = useCallback(() => void 0, []);
|
|
10
10
|
return (React.createElement(Messaging, { includeReactQueryDevTools: Platform.OS === "web" },
|
|
11
|
-
React.createElement(Routing, { I18n: I18n, basePath: basePath, customer: customer, getAuthToken: getAuthToken, locale: locale, menu: menu, tabBar: tabBar, useRedirect: useRedirect,
|
|
11
|
+
React.createElement(Routing, { I18n: I18n, basePath: basePath, customer: customer, getAuthToken: getAuthToken, locale: locale, menu: menu, rootRoutes: rootRoutes, tabBar: tabBar, useRedirect: useRedirect, onI18nError: development ? undefined : handleOnI18nError, onNotAccessible: onNotAccessible })));
|
|
12
12
|
};
|
|
13
13
|
return sentryLogger(sentry)(Root);
|
|
14
14
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { I18n } from "@lookiero/i18n-react";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import { FC } from "react";
|
|
3
|
+
import { Routes as ReactRouterRoutes } from "react-router-native";
|
|
4
4
|
import { Customer } from "../../../projection/shared/customer";
|
|
5
5
|
import { Menu, TabBar } from "../views/navigation/Navigation";
|
|
6
6
|
interface RoutingProps {
|
|
@@ -14,13 +14,7 @@ interface RoutingProps {
|
|
|
14
14
|
readonly onNotAccessible: () => void;
|
|
15
15
|
readonly onI18nError?: (err: Error) => void;
|
|
16
16
|
readonly useRedirect: () => Record<string, string>;
|
|
17
|
-
readonly
|
|
17
|
+
readonly rootRoutes: typeof ReactRouterRoutes;
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
*
|
|
22
|
-
* https://github.com/getsentry/sentry-javascript/blob/master/packages/react/src/reactrouterv6.tsx#L221
|
|
23
|
-
* (SentryRoutes is a new component after each re-render)
|
|
24
|
-
*/
|
|
25
|
-
declare const MemoizedRouting: React.NamedExoticComponent<RoutingProps>;
|
|
26
|
-
export { MemoizedRouting as Routing };
|
|
19
|
+
declare const Routing: FC<RoutingProps>;
|
|
20
|
+
export { Routing };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { lazy,
|
|
2
|
-
import { Navigate, Outlet } from "react-router-native";
|
|
1
|
+
import React, { lazy, Suspense } from "react";
|
|
2
|
+
import { Navigate, Outlet, Route } from "react-router-native";
|
|
3
3
|
import { Spinner } from "../../../shared/ui/components/atoms/spinner/Spinner";
|
|
4
4
|
import { App } from "../views/App";
|
|
5
5
|
import { CheckoutPaymentModal } from "../views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal";
|
|
@@ -12,68 +12,28 @@ const Item = lazy(() => import("../views/item/Item").then((module) => ({ default
|
|
|
12
12
|
const Summary = lazy(() => import("../views/summary/Summary").then((module) => ({ default: module.Summary })));
|
|
13
13
|
const Checkout = lazy(() => import("../views/checkout/Checkout").then((module) => ({ default: module.Checkout })));
|
|
14
14
|
const Feedback = lazy(() => import("../views/feedback/Feedback").then((module) => ({ default: module.Feedback })));
|
|
15
|
-
const Routing = ({ basePath = "", customer, locale, I18n, menu, tabBar, getAuthToken, onI18nError, onNotAccessible, useRedirect,
|
|
16
|
-
|
|
17
|
-
{
|
|
18
|
-
path: basePath,
|
|
19
|
-
element: (React.createElement(BasePathProvider, { basePath: basePath },
|
|
15
|
+
const Routing = ({ basePath = "", customer, locale, I18n, menu, tabBar, getAuthToken, onI18nError, onNotAccessible, useRedirect, rootRoutes: RootRoutes, }) => {
|
|
16
|
+
return (React.createElement(RootRoutes, null,
|
|
17
|
+
React.createElement(Route, { path: "", element: React.createElement(BasePathProvider, { basePath: basePath },
|
|
20
18
|
React.createElement(CheckoutAccessibilityMiddleware, { customerId: customer?.customerId, onNotAccessible: onNotAccessible },
|
|
21
19
|
React.createElement(I18n, { loader: React.createElement(Spinner, null), locale: locale, onError: onI18nError },
|
|
22
20
|
React.createElement(CheckoutMiddleware, { customerId: customer?.customerId },
|
|
23
21
|
React.createElement(App, { customerId: customer?.customerId, menu: menu, tabBar: tabBar },
|
|
24
|
-
React.createElement(Outlet, null))))))
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
{
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
path: Routes.SUMMARY,
|
|
43
|
-
element: (React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
|
|
44
|
-
React.createElement(Summary, { country: customer?.country, customerId: customer?.customerId }))),
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
path: Routes.CHECKOUT,
|
|
48
|
-
element: (React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
|
|
49
|
-
React.createElement(Checkout, { country: customer?.country, customerId: customer?.customerId, useRedirect: useRedirect },
|
|
50
|
-
React.createElement(Outlet, null)))),
|
|
51
|
-
children: [
|
|
52
|
-
{
|
|
53
|
-
path: Routes.CHECKOUT_PAYMENT,
|
|
54
|
-
element: React.createElement(CheckoutPaymentModal, { customerId: customer?.customerId, getAuthToken: getAuthToken }),
|
|
55
|
-
},
|
|
56
|
-
],
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
path: Routes.FEEDBACK,
|
|
60
|
-
element: (React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
|
|
61
|
-
React.createElement(Feedback, { customerId: customer?.customerId }))),
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
path: "*",
|
|
65
|
-
element: React.createElement(Navigate, { to: `${Routes.HOME}`, replace: true }),
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
},
|
|
69
|
-
]);
|
|
70
|
-
return routes;
|
|
22
|
+
React.createElement(Outlet, null)))))) },
|
|
23
|
+
React.createElement(Route, { path: Routes.INTRO, element: React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
|
|
24
|
+
React.createElement(Intro, { customerId: customer?.customerId })) }),
|
|
25
|
+
React.createElement(Route, { path: Routes.ITEM, element: React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
|
|
26
|
+
React.createElement(Item, { country: customer?.country, customerId: customer?.customerId })) }),
|
|
27
|
+
React.createElement(Route, { path: Routes.ITEM_DETAIL, element: React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
|
|
28
|
+
React.createElement(Item, { country: customer?.country, customerId: customer?.customerId })) }),
|
|
29
|
+
React.createElement(Route, { path: Routes.SUMMARY, element: React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
|
|
30
|
+
React.createElement(Summary, { country: customer?.country, customerId: customer?.customerId })) }),
|
|
31
|
+
React.createElement(Route, { path: Routes.CHECKOUT, element: React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
|
|
32
|
+
React.createElement(Checkout, { country: customer?.country, customerId: customer?.customerId, useRedirect: useRedirect },
|
|
33
|
+
React.createElement(Outlet, null))) },
|
|
34
|
+
React.createElement(Route, { element: React.createElement(CheckoutPaymentModal, { customerId: customer?.customerId, getAuthToken: getAuthToken }), path: Routes.CHECKOUT_PAYMENT })),
|
|
35
|
+
React.createElement(Route, { path: Routes.FEEDBACK, element: React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
|
|
36
|
+
React.createElement(Feedback, { customerId: customer?.customerId })) }),
|
|
37
|
+
React.createElement(Route, { element: React.createElement(Navigate, { to: `${Routes.HOME}`, replace: true }), path: "*" }))));
|
|
71
38
|
};
|
|
72
|
-
|
|
73
|
-
* Provided useRoutes is not stable (when integrated with Sentry) as it's rendering a different component tree.
|
|
74
|
-
*
|
|
75
|
-
* https://github.com/getsentry/sentry-javascript/blob/master/packages/react/src/reactrouterv6.tsx#L221
|
|
76
|
-
* (SentryRoutes is a new component after each re-render)
|
|
77
|
-
*/
|
|
78
|
-
const MemoizedRouting = memo(Routing);
|
|
79
|
-
export { MemoizedRouting as Routing };
|
|
39
|
+
export { Routing };
|
|
@@ -4,6 +4,6 @@ import { ReactNativeTransportOptions } from "@sentry/react-native/dist/js/option
|
|
|
4
4
|
import { Transport, Integration } from "@sentry/types";
|
|
5
5
|
import { ComponentType } from "react";
|
|
6
6
|
declare const transport: (options: ReactNativeTransportOptions) => Transport;
|
|
7
|
-
declare const integrations: Integration[];
|
|
7
|
+
declare const integrations: (basename: string) => Integration[];
|
|
8
8
|
declare const wrap: <P>(Component: ComponentType<P>) => ComponentType<P>;
|
|
9
9
|
export { BrowserClient as Client, Hub, ErrorBoundary, transport, integrations, wrap };
|
|
@@ -2,12 +2,13 @@ import { BrowserClient, Hub, makeFetchTransport, defaultIntegrations } from "@se
|
|
|
2
2
|
import { ErrorBoundary, reactRouterV6Instrumentation } from "@sentry/react";
|
|
3
3
|
import { BrowserTracing } from "@sentry/tracing";
|
|
4
4
|
import { useEffect } from "react";
|
|
5
|
-
import { createRoutesFromChildren,
|
|
5
|
+
import { createRoutesFromChildren, useLocation, useNavigationType } from "react-router-native";
|
|
6
|
+
import { matchRoutesForBasename } from "./matchRoutes";
|
|
6
7
|
const transport = (options, nativeFetch) => makeFetchTransport(options, nativeFetch);
|
|
7
|
-
const integrations = [
|
|
8
|
+
const integrations = (basename) => [
|
|
8
9
|
...defaultIntegrations,
|
|
9
10
|
new BrowserTracing({
|
|
10
|
-
routingInstrumentation: reactRouterV6Instrumentation(useEffect, useLocation, useNavigationType, createRoutesFromChildren,
|
|
11
|
+
routingInstrumentation: reactRouterV6Instrumentation(useEffect, useLocation, useNavigationType, createRoutesFromChildren, matchRoutesForBasename(basename)),
|
|
11
12
|
}),
|
|
12
13
|
];
|
|
13
14
|
const wrap = (Component) => Component;
|
|
@@ -3,6 +3,6 @@ import { ReactNativeTransportOptions } from "@sentry/react-native/dist/js/option
|
|
|
3
3
|
import { Transport, Integration } from "@sentry/types";
|
|
4
4
|
import { ComponentType } from "react";
|
|
5
5
|
declare const transport: (options: ReactNativeTransportOptions) => Transport;
|
|
6
|
-
declare const integrations: Integration[];
|
|
6
|
+
declare const integrations: () => Integration[];
|
|
7
7
|
declare const wrap: <P>(Component: ComponentType<P>) => ComponentType<P>;
|
|
8
8
|
export { ReactNativeClient as Client, Hub, ErrorBoundary, transport, integrations, wrap };
|
|
@@ -3,6 +3,6 @@ import { ReactNativeClient, Hub, ErrorBoundary, wrap as sentryWrap } from "@sent
|
|
|
3
3
|
import { makeReactNativeTransport } from "@sentry/react-native/dist/js/transports/native";
|
|
4
4
|
import { NATIVE } from "@sentry/react-native/dist/js/wrapper";
|
|
5
5
|
const transport = (options, nativeFetch) => NATIVE.isNativeTransportAvailable() ? makeReactNativeTransport(options) : makeFetchTransport(options, nativeFetch);
|
|
6
|
-
const integrations = [];
|
|
6
|
+
const integrations = () => [];
|
|
7
7
|
const wrap = (Component) => sentryWrap(Component);
|
|
8
8
|
export { ReactNativeClient as Client, Hub, ErrorBoundary, transport, integrations, wrap };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ComponentType } from "react";
|
|
2
2
|
import { Platform } from "react-native";
|
|
3
3
|
interface SentryLoggerFunctionArgs {
|
|
4
|
+
readonly routerBasename: string;
|
|
4
5
|
readonly publicKey: string;
|
|
5
6
|
readonly environment: `${typeof Platform.OS}-${"DEV" | "PROD"}`;
|
|
6
7
|
readonly release: string;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { defaultStackParser } from "@sentry/browser";
|
|
2
2
|
import { makeMain } from "@sentry/core";
|
|
3
|
-
import {
|
|
3
|
+
import { withSentryReactRouterV6Routing } from "@sentry/react";
|
|
4
4
|
import React, { useEffect } from "react";
|
|
5
5
|
import { Platform } from "react-native";
|
|
6
|
-
import {
|
|
6
|
+
import { Routes as ReactRouterRoutes } from "react-router-native";
|
|
7
7
|
import { Client, Hub, ErrorBoundary, transport, integrations, wrap } from "./SentryDependencies";
|
|
8
|
-
const sentryLogger = ({ publicKey, environment, release, project }) => {
|
|
8
|
+
const sentryLogger = ({ routerBasename, publicKey, environment, release, project }) => {
|
|
9
9
|
let mainHub;
|
|
10
10
|
const client = new Client({
|
|
11
11
|
environment,
|
|
12
12
|
release,
|
|
13
13
|
dsn: `https://${publicKey}@o179049.ingest.sentry.io/${project}`,
|
|
14
|
-
integrations,
|
|
14
|
+
integrations: integrations(routerBasename),
|
|
15
15
|
tracesSampleRate: 1.0,
|
|
16
16
|
debug: true,
|
|
17
17
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -84,7 +84,8 @@ const sentryLogger = ({ publicKey, environment, release, project }) => {
|
|
|
84
84
|
hub.endSession();
|
|
85
85
|
makeMain(mainHub);
|
|
86
86
|
};
|
|
87
|
-
const useRoutes = wrapUseRoutes(reactRouterUseRoutes);
|
|
87
|
+
// const useRoutes = wrapUseRoutes(reactRouterUseRoutes);
|
|
88
|
+
const Routes = withSentryReactRouterV6Routing(ReactRouterRoutes);
|
|
88
89
|
return (Component) => {
|
|
89
90
|
const WrappedComponent = wrap(Component);
|
|
90
91
|
const SentryLogger = (props) => {
|
|
@@ -94,7 +95,7 @@ const sentryLogger = ({ publicKey, environment, release, project }) => {
|
|
|
94
95
|
return onUnMount;
|
|
95
96
|
}, [customer?.customerId]);
|
|
96
97
|
return (React.createElement(ErrorBoundary, null,
|
|
97
|
-
React.createElement(WrappedComponent, { ...props,
|
|
98
|
+
React.createElement(WrappedComponent, { ...props, rootRoutes: Routes })));
|
|
98
99
|
};
|
|
99
100
|
return SentryLogger;
|
|
100
101
|
};
|