@lookiero/checkout 0.6.0-beta.16 → 0.6.0-beta.17
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.
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { wrapUseRoutes } from "@sentry/react";
|
|
1
|
+
import { wrapUseRoutes as sentryWrapUseRoutes } from "@sentry/react";
|
|
2
2
|
import React, { useCallback } from "react";
|
|
3
3
|
import { Platform } from "react-native";
|
|
4
|
-
import { useRoutes as reactRouterUseRoutes } from "react-router-native";
|
|
5
4
|
import { sentryLogger } from "../../shared/logging/SentryLogger";
|
|
6
5
|
import { Routing } from "./routing/Routing";
|
|
7
6
|
const root = ({ Messaging, I18n, getAuthToken, development, sentry }) => {
|
|
8
|
-
const
|
|
7
|
+
const wrapUseRoutes = sentry ? sentryWrapUseRoutes : undefined;
|
|
9
8
|
// eslint-disable-next-line react/display-name, react/prop-types
|
|
10
9
|
const Root = ({ basePath, locale = "en", customer, menu, tabBar, onNotAccessible, useRedirect }) => {
|
|
11
10
|
const handleOnI18nError = useCallback(() => void 0, []);
|
|
12
11
|
return (React.createElement(Messaging, { includeReactQueryDevTools: Platform.OS === "web" },
|
|
13
|
-
React.createElement(Routing, { I18n: I18n, basePath: basePath, customer: customer, getAuthToken: getAuthToken, locale: locale, menu: menu, tabBar: tabBar, useRedirect: useRedirect,
|
|
12
|
+
React.createElement(Routing, { I18n: I18n, basePath: basePath, customer: customer, getAuthToken: getAuthToken, locale: locale, menu: menu, tabBar: tabBar, useRedirect: useRedirect, wrapUseRoutes: wrapUseRoutes, onI18nError: development ? undefined : handleOnI18nError, onNotAccessible: onNotAccessible })));
|
|
14
13
|
};
|
|
15
14
|
return sentry
|
|
16
15
|
? sentryLogger({
|
|
@@ -3,6 +3,7 @@ import React, { FC } from "react";
|
|
|
3
3
|
import { Location, RouteObject } from "react-router-native";
|
|
4
4
|
import { Customer } from "../../../projection/shared/customer";
|
|
5
5
|
import { Menu, TabBar } from "../views/navigation/Navigation";
|
|
6
|
+
type UseRoutes = (routes: RouteObject[], locationArg?: Partial<Location> | string) => React.ReactElement | null;
|
|
6
7
|
interface RoutingProps {
|
|
7
8
|
readonly basePath?: string;
|
|
8
9
|
readonly customer: Customer | undefined;
|
|
@@ -14,7 +15,7 @@ interface RoutingProps {
|
|
|
14
15
|
readonly onNotAccessible: () => void;
|
|
15
16
|
readonly onI18nError?: (err: Error) => void;
|
|
16
17
|
readonly useRedirect: () => Record<string, string>;
|
|
17
|
-
readonly
|
|
18
|
+
readonly wrapUseRoutes?: (origUseRoutes: UseRoutes) => UseRoutes;
|
|
18
19
|
}
|
|
19
20
|
declare const Routing: FC<RoutingProps>;
|
|
20
21
|
export { Routing };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { lazy, Suspense } from "react";
|
|
2
|
-
import { Navigate, Outlet } from "react-router-native";
|
|
2
|
+
import { Navigate, Outlet, useRoutes as reactRouterUseRoutes } 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,7 +12,8 @@ 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,
|
|
15
|
+
const Routing = ({ basePath = "", customer, locale, I18n, menu, tabBar, getAuthToken, onI18nError, onNotAccessible, useRedirect, wrapUseRoutes = (routes) => routes, }) => {
|
|
16
|
+
const useRoutes = wrapUseRoutes(reactRouterUseRoutes);
|
|
16
17
|
const routes = useRoutes([
|
|
17
18
|
{
|
|
18
19
|
path: "",
|
|
@@ -6,8 +6,13 @@ interface SentryLoggerFunctionArgs {
|
|
|
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
|
+
}
|
|
9
14
|
interface SentryLoggerFunction {
|
|
10
|
-
(args: SentryLoggerFunctionArgs): <P>(Component: ComponentType<P>) => ComponentType<P & JSX.IntrinsicAttributes>;
|
|
15
|
+
(args: SentryLoggerFunctionArgs): <P extends SentryLoggerHOCProps>(Component: ComponentType<P>) => ComponentType<P & JSX.IntrinsicAttributes>;
|
|
11
16
|
}
|
|
12
17
|
declare const sentryLogger: SentryLoggerFunction;
|
|
13
18
|
export type { SentryLoggerFunctionArgs };
|
|
@@ -17,23 +17,75 @@ const sentryLogger = ({ publicKey, environment, release, project }) => {
|
|
|
17
17
|
enableNative: Platform.OS !== "web",
|
|
18
18
|
stackParser: defaultStackParser,
|
|
19
19
|
transport,
|
|
20
|
+
// This configuration is obtained from
|
|
21
|
+
// https://docs.sentry.io/clients/javascript/tips/#decluttering-sentry
|
|
22
|
+
ignoreErrors: [
|
|
23
|
+
// Random plugins/extensions
|
|
24
|
+
"top.GLOBALS",
|
|
25
|
+
// See: http://blog.errorception.com/2012/03/tale-of-unfindable-js-error.html
|
|
26
|
+
"originalCreateNotification",
|
|
27
|
+
"canvas.contentDocument",
|
|
28
|
+
"MyApp_RemoveAllHighlights",
|
|
29
|
+
"http://tt.epicplay.com",
|
|
30
|
+
"Can't find variable: ZiteReader",
|
|
31
|
+
"jigsaw is not defined",
|
|
32
|
+
"ComboSearch is not defined",
|
|
33
|
+
"http://loading.retry.widdit.com/",
|
|
34
|
+
"atomicFindClose",
|
|
35
|
+
// Facebook borked
|
|
36
|
+
"fb_xd_fragment",
|
|
37
|
+
// ISP "optimizing" proxy - `Cache-Control: no-transform` seems to reduce this. (thanks @acdha)
|
|
38
|
+
// See http://stackoverflow.com/questions/4113268/how-to-stop-javascript-injection-from-vodafone-proxy
|
|
39
|
+
"bmi_SafeAddOnload",
|
|
40
|
+
"EBCallBackMessageReceived",
|
|
41
|
+
// See http://toolbar.conduit.com/Developer/HtmlAndGadget/Methods/JSInjection.aspx
|
|
42
|
+
"conduitPage",
|
|
43
|
+
// Generic error code from errors outside the security sandbox
|
|
44
|
+
// You can delete this if using raven.js > 1.0, which ignores these automatically.
|
|
45
|
+
"Script error.",
|
|
46
|
+
// Avast extension error
|
|
47
|
+
"_avast_submit",
|
|
48
|
+
],
|
|
49
|
+
denyUrls: [
|
|
50
|
+
// Google Adsense
|
|
51
|
+
/pagead\/js/i,
|
|
52
|
+
// Facebook flakiness
|
|
53
|
+
/graph\.facebook\.com/i,
|
|
54
|
+
// Facebook blocked
|
|
55
|
+
/connect\.facebook\.net\/en_US\/all\.js/i,
|
|
56
|
+
// Woopra flakiness
|
|
57
|
+
/eatdifferent\.com\.woopra-ns\.com/i,
|
|
58
|
+
/static\.woopra\.com\/js\/woopra\.js/i,
|
|
59
|
+
// Chrome extensions
|
|
60
|
+
/extensions\//i,
|
|
61
|
+
/^chrome:\/\//i,
|
|
62
|
+
// Other plugins
|
|
63
|
+
/127\.0\.0\.1:4001\/isrunning/i,
|
|
64
|
+
/webappstoolbarba\.texthelp\.com\//i,
|
|
65
|
+
/metrics\.itunes\.apple\.com\.edgesuite\.net\//i,
|
|
66
|
+
],
|
|
20
67
|
});
|
|
21
68
|
const hub = new Hub(client);
|
|
22
|
-
const
|
|
69
|
+
const onMount = (customerId) => {
|
|
23
70
|
if (!mainHub) {
|
|
71
|
+
hub.setUser({ id: customerId });
|
|
72
|
+
// hub.startSession();
|
|
24
73
|
mainHub = makeMain(hub);
|
|
25
74
|
}
|
|
26
75
|
};
|
|
27
|
-
const
|
|
76
|
+
const onUnMount = () => {
|
|
77
|
+
hub.setUser(null);
|
|
78
|
+
// hub.endSession();
|
|
28
79
|
makeMain(mainHub);
|
|
29
80
|
};
|
|
30
81
|
return (Component) => {
|
|
31
82
|
const WrappedComponent = wrap(Component);
|
|
32
83
|
const SentryLogger = (props) => {
|
|
84
|
+
const { customer } = props;
|
|
33
85
|
useEffect(() => {
|
|
34
|
-
|
|
35
|
-
return
|
|
36
|
-
}, []);
|
|
86
|
+
onMount(customer?.customerId);
|
|
87
|
+
return onUnMount;
|
|
88
|
+
}, [customer?.customerId]);
|
|
37
89
|
return (React.createElement(ErrorBoundary, null,
|
|
38
90
|
React.createElement(WrappedComponent, { ...props })));
|
|
39
91
|
};
|