@lookiero/checkout 0.6.0-beta.19 → 0.6.0-beta.2

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,15 +1,13 @@
1
- import { wrapUseRoutes as sentryWrapUseRoutes } from "@sentry/react";
2
1
  import React, { useCallback } from "react";
3
2
  import { Platform } from "react-native";
4
3
  import { sentryLogger } from "../../shared/logging/SentryLogger";
5
4
  import { Routing } from "./routing/Routing";
6
5
  const root = ({ Messaging, I18n, getAuthToken, development, sentry }) => {
7
- const wrapUseRoutes = sentry ? sentryWrapUseRoutes : undefined;
8
6
  // eslint-disable-next-line react/display-name, react/prop-types
9
7
  const Root = ({ basePath, locale = "en", customer, menu, tabBar, onNotAccessible, useRedirect }) => {
10
8
  const handleOnI18nError = useCallback(() => void 0, []);
11
9
  return (React.createElement(Messaging, { includeReactQueryDevTools: Platform.OS === "web" },
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 })));
10
+ React.createElement(Routing, { I18n: I18n, basePath: basePath, customer: customer, getAuthToken: getAuthToken, locale: locale, menu: menu, tabBar: tabBar, useRedirect: useRedirect, onI18nError: development ? undefined : handleOnI18nError, onNotAccessible: onNotAccessible })));
13
11
  };
14
12
  return sentry
15
13
  ? sentryLogger({
@@ -1,9 +1,7 @@
1
1
  import { I18n } from "@lookiero/i18n-react";
2
- import React, { FC } from "react";
3
- import { Location, RouteObject } from "react-router-native";
2
+ import { FC } from "react";
4
3
  import { Customer } from "../../../projection/shared/customer";
5
4
  import { Menu, TabBar } from "../views/navigation/Navigation";
6
- type UseRoutes = (routes: RouteObject[], locationArg?: Partial<Location> | string) => React.ReactElement | null;
7
5
  interface RoutingProps {
8
6
  readonly basePath?: string;
9
7
  readonly customer: Customer | undefined;
@@ -15,7 +13,6 @@ interface RoutingProps {
15
13
  readonly onNotAccessible: () => void;
16
14
  readonly onI18nError?: (err: Error) => void;
17
15
  readonly useRedirect: () => Record<string, string>;
18
- readonly wrapUseRoutes?: (origUseRoutes: UseRoutes) => UseRoutes;
19
16
  }
20
17
  declare const Routing: FC<RoutingProps>;
21
18
  export { Routing };
@@ -1,5 +1,5 @@
1
- import React, { lazy, Suspense, useMemo } from "react";
2
- import { Navigate, Outlet, useRoutes as reactRouterUseRoutes } from "react-router-native";
1
+ import React, { lazy, Suspense } from "react";
2
+ import { Navigate, Outlet, useRoutes } 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,8 +12,7 @@ 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, wrapUseRoutes = (routes) => routes, }) => {
16
- const useRoutes = useMemo(() => wrapUseRoutes(reactRouterUseRoutes), [wrapUseRoutes]);
15
+ const Routing = ({ basePath = "", customer, locale, I18n, menu, tabBar, getAuthToken, onI18nError, onNotAccessible, useRedirect, }) => {
17
16
  const routes = useRoutes([
18
17
  {
19
18
  path: "",
@@ -4,8 +4,14 @@ import { SafeAreaProvider } from "react-native-safe-area-context";
4
4
  import { Notifications } from "../../../shared/notifications/infrastructure/ui/views/Notifications";
5
5
  import { MESSAGING_CONTEXT_ID } from "../../delivery/baseBootstrap";
6
6
  import { Navigation } from "./navigation/Navigation";
7
- const App = ({ customerId, menu, tabBar, children }) => (React.createElement(SafeAreaProvider, null,
8
- React.createElement(Notifications, { contextId: MESSAGING_CONTEXT_ID }),
9
- React.createElement(Navigation, { customerId: customerId, menu: menu, tabBar: tabBar },
10
- React.createElement(PortalProvider, null, children))));
7
+ const a = true;
8
+ const App = ({ customerId, menu, tabBar, children }) => {
9
+ if (a) {
10
+ throw new Error("This is my first Sentry error");
11
+ }
12
+ return (React.createElement(SafeAreaProvider, null,
13
+ React.createElement(Notifications, { contextId: MESSAGING_CONTEXT_ID }),
14
+ React.createElement(Navigation, { customerId: customerId, menu: menu, tabBar: tabBar },
15
+ React.createElement(PortalProvider, null, children))));
16
+ };
11
17
  export { App };
@@ -1,3 +1,4 @@
1
+ import "@sentry/tracing";
1
2
  import { ComponentType } from "react";
2
3
  import { Platform } from "react-native";
3
4
  interface SentryLoggerFunctionArgs {
@@ -6,13 +7,8 @@ interface SentryLoggerFunctionArgs {
6
7
  readonly release: string;
7
8
  readonly project: string;
8
9
  }
9
- interface SentryLoggerHOCProps {
10
- readonly customer: {
11
- readonly customerId: string;
12
- } | undefined;
13
- }
14
10
  interface SentryLoggerFunction {
15
- (args: SentryLoggerFunctionArgs): <P extends SentryLoggerHOCProps>(Component: ComponentType<P>) => ComponentType<P & JSX.IntrinsicAttributes>;
11
+ (args: SentryLoggerFunctionArgs): <P>(Component: ComponentType<P>) => ComponentType<P & JSX.IntrinsicAttributes>;
16
12
  }
17
13
  declare const sentryLogger: SentryLoggerFunction;
18
14
  export type { SentryLoggerFunctionArgs };
@@ -1,103 +1,41 @@
1
- import { defaultStackParser } from "@sentry/browser";
2
1
  import { makeMain } from "@sentry/core";
2
+ import * as Sentry from "@sentry/react-native";
3
+ import "@sentry/tracing";
3
4
  import React, { useEffect } from "react";
4
5
  import { Platform } from "react-native";
5
- import { Client, Hub, ErrorBoundary, transport, integrations, wrap } from "./SentryDependencies";
6
6
  const sentryLogger = ({ publicKey, environment, release, project }) => {
7
7
  let mainHub;
8
- const client = new Client({
8
+ /**
9
+ * TS complains about not providing 'transport' and 'stackParser' implementations
10
+ * although 'ReactNativeClient' defaults to its own implementation for those options.
11
+ */
12
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
13
+ // @ts-ignore
14
+ const client = new Sentry.ReactNativeClient({
9
15
  environment,
10
16
  release,
11
17
  dsn: `https://${publicKey}@o179049.ingest.sentry.io/${project}`,
12
- integrations,
18
+ integrations: [new Sentry.ReactNativeTracing()],
13
19
  tracesSampleRate: 1.0,
14
20
  debug: true,
15
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
16
- // @ts-ignore
17
21
  enableNative: Platform.OS !== "web",
18
- stackParser: defaultStackParser,
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
- ],
67
- beforeSend: (event) => {
68
- console.log(event);
69
- return event;
70
- },
71
- beforeSendTransaction: (event) => {
72
- console.log(event);
73
- return event;
74
- },
75
22
  });
76
- const hub = new Hub(client);
77
- const onMount = (customerId) => {
78
- if (!mainHub) {
79
- hub.setUser({ id: customerId });
80
- hub.startSession();
81
- mainHub = makeMain(hub);
82
- }
23
+ const hub = new Sentry.Hub(client);
24
+ hub.bindClient(client);
25
+ const switchMainHub = () => {
26
+ mainHub = makeMain(hub);
83
27
  };
84
- const onUnMount = () => {
85
- hub.setUser(null);
86
- hub.endSession();
28
+ const revertMainHub = () => {
87
29
  makeMain(mainHub);
88
30
  };
89
31
  return (Component) => {
90
- const WrappedComponent = wrap(Component);
91
- const SentryLogger = (props) => {
92
- const { customer } = props;
93
- useEffect(() => {
94
- onMount(customer?.customerId);
95
- return onUnMount;
96
- }, [customer?.customerId]);
97
- return (React.createElement(ErrorBoundary, null,
98
- React.createElement(WrappedComponent, { ...props })));
32
+ switchMainHub();
33
+ const WrappedComponent = Sentry.wrap(Component);
34
+ // eslint-disable-next-line react/display-name
35
+ return (props) => {
36
+ useEffect(() => revertMainHub, []);
37
+ return React.createElement(WrappedComponent, { ...props });
99
38
  };
100
- return SentryLogger;
101
39
  };
102
40
  };
103
41
  export { sentryLogger };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.6.0-beta.19",
3
+ "version": "0.6.0-beta.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -33,7 +33,7 @@
33
33
  "@lookiero/messaging": "^8.0.0",
34
34
  "@lookiero/messaging-react": "^8.0.0",
35
35
  "@react-spring/native": "^9.5.5",
36
- "@sentry/react-native": "^4.13.0",
36
+ "@sentry/react-native": "^4.12.0",
37
37
  "inline-style-prefixer": "6.0.1",
38
38
  "react-native-safe-area-context": "^4.4.1",
39
39
  "react-native-svg": "^12.1.1",
@@ -1,9 +0,0 @@
1
- import { BrowserClient, Hub } from "@sentry/browser";
2
- import { ErrorBoundary } from "@sentry/react";
3
- import { ReactNativeTransportOptions } from "@sentry/react-native/dist/js/options";
4
- import { Transport, Integration } from "@sentry/types";
5
- import { ComponentType } from "react";
6
- declare const transport: (options: ReactNativeTransportOptions) => Transport;
7
- declare const integrations: Integration[];
8
- declare const wrap: <P>(Component: ComponentType<P>) => ComponentType<P>;
9
- export { BrowserClient as Client, Hub, ErrorBoundary, transport, integrations, wrap };
@@ -1,22 +0,0 @@
1
- import { BrowserClient, Hub, makeFetchTransport, defaultIntegrations } from "@sentry/browser";
2
- import { ErrorBoundary, reactRouterV6Instrumentation } from "@sentry/react";
3
- import { BrowserTracing } from "@sentry/tracing";
4
- import { useEffect } from "react";
5
- import { createRoutesFromChildren, matchRoutes, useLocation, useNavigationType } from "react-router-native";
6
- const transport = (options, nativeFetch) => makeFetchTransport(options, nativeFetch);
7
- const integrations = [
8
- ...defaultIntegrations,
9
- new BrowserTracing({
10
- routingInstrumentation: reactRouterV6Instrumentation(useEffect, useLocation, useNavigationType, createRoutesFromChildren, matchRoutes),
11
- beforeNavigate: (context) => {
12
- console.log("beforeNavigate", context);
13
- return context;
14
- },
15
- shouldCreateSpanForRequest: (url) => {
16
- console.log(url);
17
- return true;
18
- },
19
- }),
20
- ];
21
- const wrap = (Component) => Component;
22
- export { BrowserClient as Client, Hub, ErrorBoundary, transport, integrations, wrap };
@@ -1,8 +0,0 @@
1
- import { ReactNativeClient, Hub, ErrorBoundary } from "@sentry/react-native";
2
- import { ReactNativeTransportOptions } from "@sentry/react-native/dist/js/options";
3
- import { Transport, Integration } from "@sentry/types";
4
- import { ComponentType } from "react";
5
- declare const transport: (options: ReactNativeTransportOptions) => Transport;
6
- declare const integrations: Integration[];
7
- declare const wrap: <P>(Component: ComponentType<P>) => ComponentType<P>;
8
- export { ReactNativeClient as Client, Hub, ErrorBoundary, transport, integrations, wrap };
@@ -1,8 +0,0 @@
1
- import { makeFetchTransport } from "@sentry/browser";
2
- import { ReactNativeClient, Hub, ErrorBoundary, wrap as sentryWrap } from "@sentry/react-native";
3
- import { makeReactNativeTransport } from "@sentry/react-native/dist/js/transports/native";
4
- import { NATIVE } from "@sentry/react-native/dist/js/wrapper";
5
- const transport = (options, nativeFetch) => NATIVE.isNativeTransportAvailable() ? makeReactNativeTransport(options) : makeFetchTransport(options, nativeFetch);
6
- const integrations = [];
7
- const wrap = (Component) => sentryWrap(Component);
8
- export { ReactNativeClient as Client, Hub, ErrorBoundary, transport, integrations, wrap };