@lookiero/checkout 0.6.4 → 0.7.1

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 (48) hide show
  1. package/dist/index.d.ts +4 -2
  2. package/dist/index.js +2 -2
  3. package/dist/infrastructure/ui/Root.d.ts +6 -2
  4. package/dist/infrastructure/ui/Root.js +10 -6
  5. package/dist/infrastructure/ui/i18n/i18n.d.ts +0 -7
  6. package/dist/infrastructure/ui/i18n/i18n.js +0 -7
  7. package/dist/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.js +1 -1
  8. package/dist/infrastructure/ui/routing/CheckoutMiddleware.js +13 -29
  9. package/dist/infrastructure/ui/routing/Routing.d.ts +11 -3
  10. package/dist/infrastructure/ui/routing/Routing.js +12 -12
  11. package/dist/infrastructure/ui/routing/routes.d.ts +0 -1
  12. package/dist/infrastructure/ui/routing/routes.js +0 -1
  13. package/dist/infrastructure/ui/settings/UISettings.d.ts +0 -1
  14. package/dist/infrastructure/ui/settings/UISettings.js +0 -1
  15. package/dist/shared/logging/SentryDependencies.d.ts +11 -0
  16. package/dist/shared/logging/SentryDependencies.js +17 -0
  17. package/dist/shared/logging/SentryDependencies.native.d.ts +10 -0
  18. package/dist/shared/logging/SentryDependencies.native.js +15 -0
  19. package/dist/shared/logging/SentryLogger.d.ts +19 -0
  20. package/dist/shared/logging/SentryLogger.js +122 -0
  21. package/dist/shared/logging/reactRouterV6Instrumentation/NativeReactRouterV6Instrumentation.d.ts +49 -0
  22. package/dist/shared/logging/reactRouterV6Instrumentation/NativeReactRouterV6Instrumentation.js +131 -0
  23. package/dist/shared/logging/reactRouterV6Instrumentation/location.d.ts +3 -0
  24. package/dist/shared/logging/reactRouterV6Instrumentation/location.js +5 -0
  25. package/dist/shared/logging/reactRouterV6Instrumentation/normalizedNameAndMatchForLocation.d.ts +12 -0
  26. package/dist/shared/logging/reactRouterV6Instrumentation/normalizedNameAndMatchForLocation.js +34 -0
  27. package/dist/shared/logging/reactRouterV6Instrumentation/reactRouterV6Instrumentation.d.ts +15 -0
  28. package/dist/shared/logging/reactRouterV6Instrumentation/reactRouterV6Instrumentation.js +92 -0
  29. package/dist/shared/logging/reactRouterV6Instrumentation/types.d.ts +9 -0
  30. package/dist/shared/logging/reactRouterV6Instrumentation/types.js +1 -0
  31. package/dist/shared/logging/types.d.ts +22 -0
  32. package/dist/shared/logging/types.js +1 -0
  33. package/dist/shared/ui/components/atoms/field/Field.js +5 -13
  34. package/dist/shared/ui/components/atoms/field/Field.style.js +2 -2
  35. package/dist/shared/ui/components/molecules/inputField/InputField.js +2 -2
  36. package/dist/shared/ui/components/molecules/inputField/InputField.style.d.ts +1 -0
  37. package/dist/shared/ui/components/molecules/inputField/InputField.style.js +1 -0
  38. package/package.json +2 -1
  39. package/dist/infrastructure/domain/uiSetting/react/useIncrementIntroShownCount.d.ts +0 -10
  40. package/dist/infrastructure/domain/uiSetting/react/useIncrementIntroShownCount.js +0 -11
  41. package/dist/infrastructure/projection/uiSetting/react/useShouldIntroBeShown.d.ts +0 -6
  42. package/dist/infrastructure/projection/uiSetting/react/useShouldIntroBeShown.js +0 -7
  43. package/dist/infrastructure/projection/uiSetting/react/useViewIntroShownCount.d.ts +0 -6
  44. package/dist/infrastructure/projection/uiSetting/react/useViewIntroShownCount.js +0 -9
  45. package/dist/infrastructure/ui/views/intro/Intro.d.ts +0 -6
  46. package/dist/infrastructure/ui/views/intro/Intro.js +0 -52
  47. package/dist/infrastructure/ui/views/intro/Intro.style.d.ts +0 -52
  48. package/dist/infrastructure/ui/views/intro/Intro.style.js +0 -55
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import { EndpointFunction } from "@lookiero/i18n";
2
- import { FC } from "react";
2
+ import { ComponentType } from "react";
3
3
  import { CheckoutStatus } from "./domain/checkout/model/checkout";
4
4
  import { RootProps } from "./infrastructure/ui/Root";
5
5
  import { CheckoutProjection } from "./projection/checkout/checkout";
6
6
  import { IsCheckoutAccessibleByCustomerIdProjection } from "./projection/checkout/viewIsCheckoutAccessibleByCustomerId";
7
+ import { SentryLoggerFunctionArgs } from "./shared/logging/SentryLogger";
7
8
  interface IsCheckoutAccessibleFunctionArgs {
8
9
  readonly customerId: string | undefined;
9
10
  }
@@ -20,9 +21,10 @@ interface BootstrapFunctionArgs {
20
21
  readonly getAuthToken: () => Promise<string>;
21
22
  readonly apiUrl: string;
22
23
  readonly translations: EndpointFunction;
24
+ readonly sentry: SentryLoggerFunctionArgs;
23
25
  }
24
26
  interface BootstrapFunctionReturn {
25
- readonly Root: FC<RootProps>;
27
+ readonly Root: ComponentType<RootProps>;
26
28
  readonly isCheckoutAccessible: IsCheckoutAccessibleFunction;
27
29
  readonly firstAvailableCheckoutByCustomerId: FirstAvailableCheckoutByCustomerIdFunction;
28
30
  }
package/dist/index.js CHANGED
@@ -5,13 +5,13 @@ import { bootstrap as checkoutBootstrap } from "./infrastructure/delivery/bootst
5
5
  import { root } from "./infrastructure/ui/Root";
6
6
  import { viewFirstAvailableCheckoutByCustomerId } from "./projection/checkout/viewFirstAvailableCheckoutByCustomerId";
7
7
  import { viewIsCheckoutAccessibleByCustomerId, } from "./projection/checkout/viewIsCheckoutAccessibleByCustomerId";
8
- const bootstrap = ({ apiUrl, getAuthToken, translations }) => {
8
+ const bootstrap = ({ apiUrl, getAuthToken, translations, sentry }) => {
9
9
  const { Component: Messaging, queryBus } = checkoutBootstrap({ apiUrl, getAuthToken });
10
10
  const I18n = i18n({
11
11
  fetchTranslation: fetchFetchTranslation({ endpoint: translations }),
12
12
  contextId: "CheckoutI18n",
13
13
  });
14
- const Root = root({ Messaging, I18n, getAuthToken });
14
+ const Root = root({ Messaging, I18n, getAuthToken, sentry });
15
15
  const isCheckoutAccessible = ({ customerId }) => queryBus(viewIsCheckoutAccessibleByCustomerId({ customerId }));
16
16
  const firstAvailableCheckoutByCustomerId = ({ customerId }) => queryBus(viewFirstAvailableCheckoutByCustomerId({ customerId: customerId }));
17
17
  return {
@@ -1,16 +1,19 @@
1
1
  import { I18n } from "@lookiero/i18n-react";
2
2
  import { MessagingRoot } from "@lookiero/messaging-react/bootstrap";
3
- import { FC } from "react";
3
+ import { ComponentType } from "react";
4
+ import { useRoutes as reactRouterUseRoutes } from "react-router-native";
4
5
  import { Customer } from "../../projection/shared/customer";
6
+ import { SentryLoggerFunctionArgs } from "../../shared/logging/SentryLogger";
5
7
  import { Menu, TabBar } from "./views/navigation/Navigation";
6
8
  interface RootFunctionArgs {
7
9
  readonly Messaging: MessagingRoot;
8
10
  readonly I18n: I18n;
9
11
  readonly development?: boolean;
12
+ readonly sentry: SentryLoggerFunctionArgs;
10
13
  readonly getAuthToken: () => Promise<string>;
11
14
  }
12
15
  interface RootFunction {
13
- (args: RootFunctionArgs): FC<RootProps>;
16
+ (args: RootFunctionArgs): ComponentType<RootProps>;
14
17
  }
15
18
  interface RootProps {
16
19
  readonly basePath: string;
@@ -20,6 +23,7 @@ interface RootProps {
20
23
  readonly tabBar: TabBar;
21
24
  readonly onNotAccessible: () => void;
22
25
  readonly useRedirect: () => Record<string, string>;
26
+ readonly useRoutes?: typeof reactRouterUseRoutes;
23
27
  }
24
28
  declare const root: RootFunction;
25
29
  export type { RootProps };
@@ -1,11 +1,15 @@
1
1
  import React, { useCallback } from "react";
2
2
  import { Platform } from "react-native";
3
+ import { useRoutes as reactRouterUseRoutes } from "react-router-native";
4
+ import { sentryLogger } from "../../shared/logging/SentryLogger";
3
5
  import { Routing } from "./routing/Routing";
4
- const root = ({ Messaging, I18n, getAuthToken, development }) =>
5
- // eslint-disable-next-line react/display-name, react/prop-types
6
- ({ basePath, locale = "en", customer, menu, tabBar, onNotAccessible, useRedirect }) => {
7
- const handleOnI18nError = useCallback(() => void 0, []);
8
- return (React.createElement(Messaging, { includeReactQueryDevTools: Platform.OS === "web" },
9
- 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 })));
6
+ const root = ({ Messaging, I18n, getAuthToken, development, sentry }) => {
7
+ // eslint-disable-next-line react/display-name, react/prop-types
8
+ const Root = ({ basePath, locale = "en", customer, menu, tabBar, onNotAccessible, useRedirect, useRoutes = reactRouterUseRoutes, }) => {
9
+ const handleOnI18nError = useCallback(() => void 0, []);
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, useRoutes: useRoutes, onI18nError: development ? undefined : handleOnI18nError, onNotAccessible: onNotAccessible })));
12
+ };
13
+ return sentryLogger(sentry)(Root);
10
14
  };
11
15
  export { root };
@@ -1,12 +1,5 @@
1
1
  declare const COLOR_I18N_PREFIX = "color.";
2
2
  declare enum I18nMessages {
3
- INTRO_TITLE = "intro.title",
4
- INTRO_SUBTITLE = "intro.subtitle",
5
- INTRO_DISCOUNT = "intro.discount",
6
- INTRO_BULLET_ONE = "intro.bullet_one",
7
- INTRO_BULLET_TWO = "intro.bullet_two",
8
- INTRO_BULLET_THREE = "intro.bullet_three",
9
- INTRO_BUTTON = "intro.button",
10
3
  ITEM_SIZE = "item.size",
11
4
  ITEM_COLOR = "item.color",
12
5
  ITEM_UNIQUE = "item.unique",
@@ -1,13 +1,6 @@
1
1
  const COLOR_I18N_PREFIX = "color.";
2
2
  var I18nMessages;
3
3
  (function (I18nMessages) {
4
- I18nMessages["INTRO_TITLE"] = "intro.title";
5
- I18nMessages["INTRO_SUBTITLE"] = "intro.subtitle";
6
- I18nMessages["INTRO_DISCOUNT"] = "intro.discount";
7
- I18nMessages["INTRO_BULLET_ONE"] = "intro.bullet_one";
8
- I18nMessages["INTRO_BULLET_TWO"] = "intro.bullet_two";
9
- I18nMessages["INTRO_BULLET_THREE"] = "intro.bullet_three";
10
- I18nMessages["INTRO_BUTTON"] = "intro.button";
11
4
  I18nMessages["ITEM_SIZE"] = "item.size";
12
5
  I18nMessages["ITEM_COLOR"] = "item.color";
13
6
  I18nMessages["ITEM_UNIQUE"] = "item.unique";
@@ -11,7 +11,7 @@ const CheckoutAccessibilityMiddleware = ({ customerId, onNotAccessible, loader =
11
11
  if (notAccessible) {
12
12
  onNotAccessibleRef.current();
13
13
  }
14
- }, [notAccessible, onNotAccessible]);
14
+ }, [notAccessible]);
15
15
  return accessible === undefined && [QueryStatus.IDLE, QueryStatus.LOADING].includes(status)
16
16
  ? loader
17
17
  : accessible
@@ -6,13 +6,10 @@ import { CheckoutItemStatus } from "../../../domain/checkoutItem/model/checkoutI
6
6
  import { Spinner } from "../../../shared/ui/components/atoms/spinner/Spinner";
7
7
  import { useStartCheckout } from "../../domain/checkout/react/useStartCheckout";
8
8
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
9
- import { useShouldIntroBeShown } from "../../projection/uiSetting/react/useShouldIntroBeShown";
10
9
  import { Routes } from "./routes";
11
10
  import { useBasePath } from "./useBasePath";
12
11
  const CheckoutMiddleware = ({ customerId, loader = React.createElement(Spinner, null), children }) => {
13
12
  const basePath = useBasePath();
14
- const introShown = useRef(false);
15
- const [shouldIntroBeShown, shouldIntroBeShownStatus] = useShouldIntroBeShown();
16
13
  const navigatedToFirstItemWithoutCustomerDecision = useRef(false);
17
14
  const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
18
15
  const firstItemWithoutCustomerDecision = checkout?.items.find((item) => item.status === CheckoutItemStatus.INITIAL);
@@ -22,7 +19,6 @@ const CheckoutMiddleware = ({ customerId, loader = React.createElement(Spinner,
22
19
  startCheckout();
23
20
  }
24
21
  }, [checkout?.id, startCheckout]);
25
- const introRouteMatch = useMatch(`${basePath}/${Routes.INTRO}`);
26
22
  const itemRouteMatch = useMatch(`${basePath}/${Routes.ITEM}`);
27
23
  const itemDetailRouteMatch = useMatch(`${basePath}/${Routes.ITEM_DETAIL}`);
28
24
  const summaryRouteMatch = useMatch(`${basePath}/${Routes.SUMMARY}`);
@@ -32,8 +28,7 @@ const CheckoutMiddleware = ({ customerId, loader = React.createElement(Spinner,
32
28
  const checkoutShown = useRef(false);
33
29
  checkoutShown.current = checkoutShown.current || (Boolean(checkoutRouteMatch) && !Boolean(checkoutPaymentRouteMatch));
34
30
  const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
35
- const dependenciesLoaded = dependenciesLoadedStatuses.includes(shouldIntroBeShownStatus) &&
36
- (dependenciesLoadedStatuses.includes(checkoutStatus) || checkout);
31
+ const dependenciesLoaded = dependenciesLoadedStatuses.includes(checkoutStatus) || checkout;
37
32
  if (!dependenciesLoaded) {
38
33
  return loader;
39
34
  }
@@ -54,31 +49,20 @@ const CheckoutMiddleware = ({ customerId, loader = React.createElement(Spinner,
54
49
  !(summaryRouteMatch || itemDetailRouteMatch || checkoutRouteMatch || checkoutPaymentRouteMatch)) {
55
50
  return React.createElement(Navigate, { to: `${basePath}/${Routes.SUMMARY}`, replace: true });
56
51
  }
57
- /* Navigate to the Intro if required */
58
- if (shouldIntroBeShown && !introShown.current && firstItemWithoutCustomerDecision !== undefined) {
59
- if (introRouteMatch) {
60
- introShown.current = true;
61
- }
62
- else {
63
- return React.createElement(Navigate, { to: `${basePath}/${Routes.INTRO}`, replace: true });
52
+ /* Item/ItemDetail 404 - Not found */
53
+ if (itemRouteMatch || itemDetailRouteMatch) {
54
+ const checkoutItem = checkout?.items.find((item) => item.id === itemRouteMatch?.params.id || itemDetailRouteMatch?.params.id);
55
+ if (!checkoutItem) {
56
+ return React.createElement(Navigate, { to: `${basePath}/${Routes.HOME}`, replace: true });
64
57
  }
65
58
  }
66
- else {
67
- /* Item/ItemDetail 404 - Not found */
68
- if (itemRouteMatch || itemDetailRouteMatch) {
69
- const checkoutItem = checkout?.items.find((item) => item.id === itemRouteMatch?.params.id || itemDetailRouteMatch?.params.id);
70
- if (!checkoutItem) {
71
- return React.createElement(Navigate, { to: `${basePath}/${Routes.HOME}`, replace: true });
72
- }
73
- }
74
- /* Navigate to the first item without customer's decission */
75
- navigatedToFirstItemWithoutCustomerDecision.current =
76
- navigatedToFirstItemWithoutCustomerDecision.current ||
77
- Boolean(itemRouteMatch && itemRouteMatch.params.id === firstItemWithoutCustomerDecision?.id);
78
- if (firstItemWithoutCustomerDecision && !navigatedToFirstItemWithoutCustomerDecision.current) {
79
- navigatedToFirstItemWithoutCustomerDecision.current = true;
80
- return (React.createElement(Navigate, { to: generatePath(`${basePath}/${Routes.ITEM}`, { id: firstItemWithoutCustomerDecision.id }), replace: true }));
81
- }
59
+ /* Navigate to the first item without customer's decission */
60
+ navigatedToFirstItemWithoutCustomerDecision.current =
61
+ navigatedToFirstItemWithoutCustomerDecision.current ||
62
+ Boolean(itemRouteMatch && itemRouteMatch.params.id === firstItemWithoutCustomerDecision?.id);
63
+ if (firstItemWithoutCustomerDecision && !navigatedToFirstItemWithoutCustomerDecision.current) {
64
+ navigatedToFirstItemWithoutCustomerDecision.current = true;
65
+ return (React.createElement(Navigate, { to: generatePath(`${basePath}/${Routes.ITEM}`, { id: firstItemWithoutCustomerDecision.id }), replace: true }));
82
66
  }
83
67
  return children;
84
68
  };
@@ -1,5 +1,6 @@
1
1
  import { I18n } from "@lookiero/i18n-react";
2
- import { FC } from "react";
2
+ import React from "react";
3
+ import { useRoutes as reactRouterUseRoutes } from "react-router-native";
3
4
  import { Customer } from "../../../projection/shared/customer";
4
5
  import { Menu, TabBar } from "../views/navigation/Navigation";
5
6
  interface RoutingProps {
@@ -13,6 +14,13 @@ interface RoutingProps {
13
14
  readonly onNotAccessible: () => void;
14
15
  readonly onI18nError?: (err: Error) => void;
15
16
  readonly useRedirect: () => Record<string, string>;
17
+ readonly useRoutes: typeof reactRouterUseRoutes;
16
18
  }
17
- declare const Routing: FC<RoutingProps>;
18
- export { Routing };
19
+ /**
20
+ * Provided useRoutes is not stable (when integrated with Sentry) as it's rendering a different component tree.
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 };
@@ -1,5 +1,5 @@
1
- import React, { lazy, Suspense } from "react";
2
- import { Navigate, Outlet, useRoutes } from "react-router-native";
1
+ import React, { lazy, memo, Suspense } from "react";
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";
@@ -7,14 +7,13 @@ import { CheckoutAccessibilityMiddleware } from "./CheckoutAccessibilityMiddlewa
7
7
  import { CheckoutMiddleware } from "./CheckoutMiddleware";
8
8
  import { Routes } from "./routes";
9
9
  import { BasePathProvider } from "./useBasePath";
10
- const Intro = lazy(() => import("../views/intro/Intro").then((module) => ({ default: module.Intro })));
11
10
  const Item = lazy(() => import("../views/item/Item").then((module) => ({ default: module.Item })));
12
11
  const Summary = lazy(() => import("../views/summary/Summary").then((module) => ({ default: module.Summary })));
13
12
  const Checkout = lazy(() => import("../views/checkout/Checkout").then((module) => ({ default: module.Checkout })));
14
13
  const Feedback = lazy(() => import("../views/feedback/Feedback").then((module) => ({ default: module.Feedback })));
15
14
  const NotFound = lazy(() => import("../views/notFound/NotFound").then((module) => ({ default: module.NotFound })));
16
- const Routing = ({ basePath = "", customer, locale, I18n, menu, tabBar, getAuthToken, onI18nError, onNotAccessible, useRedirect, }) => {
17
- const routes = useRoutes([
15
+ const Routing = ({ basePath = "", customer, locale, I18n, menu, tabBar, getAuthToken, onI18nError, onNotAccessible, useRedirect, useRoutes = reactRouterUseRoutes, }) => {
16
+ return useRoutes([
18
17
  {
19
18
  path: "",
20
19
  element: (React.createElement(BasePathProvider, { basePath: basePath },
@@ -24,11 +23,6 @@ const Routing = ({ basePath = "", customer, locale, I18n, menu, tabBar, getAuthT
24
23
  React.createElement(App, { customerId: customer?.customerId, menu: menu, tabBar: tabBar },
25
24
  React.createElement(Outlet, null))))))),
26
25
  children: [
27
- {
28
- path: Routes.INTRO,
29
- element: (React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
30
- React.createElement(Intro, { customerId: customer?.customerId }))),
31
- },
32
26
  {
33
27
  path: Routes.ITEM,
34
28
  element: (React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
@@ -73,6 +67,12 @@ const Routing = ({ basePath = "", customer, locale, I18n, menu, tabBar, getAuthT
73
67
  ],
74
68
  },
75
69
  ]);
76
- return routes;
77
70
  };
78
- export { Routing };
71
+ /**
72
+ * Provided useRoutes is not stable (when integrated with Sentry) as it's rendering a different component tree.
73
+ *
74
+ * https://github.com/getsentry/sentry-javascript/blob/master/packages/react/src/reactrouterv6.tsx#L221
75
+ * (SentryRoutes is a new component after each re-render)
76
+ */
77
+ const MemoizedRouting = memo(Routing);
78
+ export { MemoizedRouting as Routing };
@@ -1,6 +1,5 @@
1
1
  export declare enum Routes {
2
2
  HOME = "",
3
- INTRO = "intro",
4
3
  ITEM_DETAIL = "item/:id/detail",
5
4
  ITEM = "item/:id",
6
5
  SUMMARY = "summary",
@@ -1,7 +1,6 @@
1
1
  export var Routes;
2
2
  (function (Routes) {
3
3
  Routes["HOME"] = "";
4
- Routes["INTRO"] = "intro";
5
4
  Routes["ITEM_DETAIL"] = "item/:id/detail";
6
5
  Routes["ITEM"] = "item/:id";
7
6
  Routes["SUMMARY"] = "summary";
@@ -1,4 +1,3 @@
1
1
  declare enum UISettings {
2
- INTRO_SHOWN_COUNT = "INTRO_SHOWN_COUNT"
3
2
  }
4
3
  export { UISettings };
@@ -1,5 +1,4 @@
1
1
  var UISettings;
2
2
  (function (UISettings) {
3
- UISettings["INTRO_SHOWN_COUNT"] = "INTRO_SHOWN_COUNT";
4
3
  })(UISettings || (UISettings = {}));
5
4
  export { UISettings };
@@ -0,0 +1,11 @@
1
+ import { BrowserClient, Hub } from "@sentry/browser";
2
+ import { FetchImpl } from "@sentry/browser/types/transports/utils";
3
+ import { ErrorBoundary } from "@sentry/react";
4
+ import { ReactNativeTransportOptions } from "@sentry/react-native/dist/js/options";
5
+ import { Transport } from "@sentry/types";
6
+ import { wrapUseRoutes } from "./reactRouterV6Instrumentation/reactRouterV6Instrumentation";
7
+ import { Integrations, WrapComponent } from "./types";
8
+ declare const transport: (options: ReactNativeTransportOptions, nativeFetch?: FetchImpl) => Transport;
9
+ declare const integrations: Integrations;
10
+ declare const wrapComponent: WrapComponent;
11
+ export { BrowserClient as Client, Hub, ErrorBoundary, transport, integrations, wrapComponent, wrapUseRoutes };
@@ -0,0 +1,17 @@
1
+ import { BrowserClient, Hub, makeFetchTransport, defaultIntegrations } from "@sentry/browser";
2
+ import { ErrorBoundary } from "@sentry/react";
3
+ import { BrowserTracing } from "@sentry/tracing";
4
+ import { useEffect } from "react";
5
+ import { useLocation, useNavigationType, matchRoutes } from "react-router-native";
6
+ import { reactRouterV6Instrumentation, wrapUseRoutes, } from "./reactRouterV6Instrumentation/reactRouterV6Instrumentation";
7
+ const transport = (options, nativeFetch) => makeFetchTransport(options, nativeFetch);
8
+ /**
9
+ * BrowserTracing must be initialized before the BrowserClient
10
+ * so we instantiate it before the integrations function is called
11
+ */
12
+ const browserTracing = new BrowserTracing({
13
+ routingInstrumentation: reactRouterV6Instrumentation({ useEffect, useLocation, useNavigationType, matchRoutes }),
14
+ });
15
+ const integrations = () => [...defaultIntegrations, browserTracing];
16
+ const wrapComponent = (Component) => Component;
17
+ export { BrowserClient as Client, Hub, ErrorBoundary, transport, integrations, wrapComponent, wrapUseRoutes };
@@ -0,0 +1,10 @@
1
+ import { FetchImpl } from "@sentry/browser/types/transports/utils";
2
+ import { ReactNativeClient, Hub, ErrorBoundary } from "@sentry/react-native";
3
+ import { ReactNativeTransportOptions } from "@sentry/react-native/dist/js/options";
4
+ import { Transport } from "@sentry/types";
5
+ import { Integrations, WrapComponent, WrapUseRoutes } from "./types";
6
+ declare const transport: (options: ReactNativeTransportOptions, nativeFetch?: FetchImpl) => Transport;
7
+ declare const integrations: Integrations;
8
+ declare const wrapComponent: WrapComponent;
9
+ declare const wrapUseRoutes: WrapUseRoutes;
10
+ export { ReactNativeClient as Client, Hub, ErrorBoundary, transport, integrations, wrapComponent, wrapUseRoutes };
@@ -0,0 +1,15 @@
1
+ import { makeFetchTransport } from "@sentry/browser";
2
+ import { ReactNativeClient, Hub, ErrorBoundary, wrap as sentryWrap, ReactNativeTracing } 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
+ import { useEffect } from "react";
6
+ import { matchRoutes, useLocation } from "react-router-native";
7
+ import { NativeReactRouterV6Instrumentation } from "./reactRouterV6Instrumentation/NativeReactRouterV6Instrumentation";
8
+ const transport = (options, nativeFetch) => NATIVE.isNativeTransportAvailable() ? makeReactNativeTransport(options) : makeFetchTransport(options, nativeFetch);
9
+ const routingInstrumentation = new NativeReactRouterV6Instrumentation({ useEffect, useLocation, matchRoutes });
10
+ // ReactNativeTracing's instantiation must be delayed so we wrap it in a function
11
+ // that's going to be called when the Client is instantiated
12
+ const integrations = () => [new ReactNativeTracing({ routingInstrumentation })];
13
+ const wrapComponent = (Component) => sentryWrap(Component);
14
+ const wrapUseRoutes = routingInstrumentation.wrapUseRoutes.bind(routingInstrumentation);
15
+ export { ReactNativeClient as Client, Hub, ErrorBoundary, transport, integrations, wrapComponent, wrapUseRoutes };
@@ -0,0 +1,19 @@
1
+ import { ComponentType } from "react";
2
+ import { Platform } from "react-native";
3
+ interface SentryLoggerFunctionArgs {
4
+ readonly publicKey: string;
5
+ readonly environment: `${typeof Platform.OS}-${"DEV" | "PROD" | "EXPO"}`;
6
+ readonly release: string;
7
+ readonly project: string;
8
+ }
9
+ interface SentryLoggerHOCProps {
10
+ readonly customer: {
11
+ readonly customerId: string;
12
+ } | undefined;
13
+ }
14
+ interface SentryLoggerFunction {
15
+ (args: SentryLoggerFunctionArgs): <P extends SentryLoggerHOCProps>(Component: ComponentType<P>) => ComponentType<P & JSX.IntrinsicAttributes>;
16
+ }
17
+ declare const sentryLogger: SentryLoggerFunction;
18
+ export type { SentryLoggerFunctionArgs, SentryLoggerHOCProps };
19
+ export { sentryLogger };
@@ -0,0 +1,122 @@
1
+ import { defaultStackParser } from "@sentry/browser";
2
+ import { makeMain } from "@sentry/core";
3
+ import React, { useEffect } from "react";
4
+ import { Platform } from "react-native";
5
+ import { useRoutes as reactRouterUseRoutes } from "react-router-native";
6
+ import { Client, Hub, transport, integrations, wrapUseRoutes, wrapComponent, ErrorBoundary, } from "./SentryDependencies";
7
+ // This configuration is obtained from
8
+ // https://docs.sentry.io/clients/javascript/tips/#decluttering-sentry
9
+ const IGNORED_ERRORS = [
10
+ // Random plugins/extensions
11
+ "top.GLOBALS",
12
+ // See: http://blog.errorception.com/2012/03/tale-of-unfindable-js-error.html
13
+ "originalCreateNotification",
14
+ "canvas.contentDocument",
15
+ "MyApp_RemoveAllHighlights",
16
+ "http://tt.epicplay.com",
17
+ "Can't find variable: ZiteReader",
18
+ "jigsaw is not defined",
19
+ "ComboSearch is not defined",
20
+ "http://loading.retry.widdit.com/",
21
+ "atomicFindClose",
22
+ // Facebook borked
23
+ "fb_xd_fragment",
24
+ // ISP "optimizing" proxy - `Cache-Control: no-transform` seems to reduce this. (thanks @acdha)
25
+ // See http://stackoverflow.com/questions/4113268/how-to-stop-javascript-injection-from-vodafone-proxy
26
+ "bmi_SafeAddOnload",
27
+ "EBCallBackMessageReceived",
28
+ // See http://toolbar.conduit.com/Developer/HtmlAndGadget/Methods/JSInjection.aspx
29
+ "conduitPage",
30
+ // Generic error code from errors outside the security sandbox
31
+ // You can delete this if using raven.js > 1.0, which ignores these automatically.
32
+ "Script error.",
33
+ // Avast extension error
34
+ "_avast_submit",
35
+ ];
36
+ const DENIED_URLS = [
37
+ // Google Adsense
38
+ /pagead\/js/i,
39
+ // Facebook flakiness
40
+ /graph\.facebook\.com/i,
41
+ // Facebook blocked
42
+ /connect\.facebook\.net\/en_US\/all\.js/i,
43
+ // Woopra flakiness
44
+ /eatdifferent\.com\.woopra-ns\.com/i,
45
+ /static\.woopra\.com\/js\/woopra\.js/i,
46
+ // Chrome extensions
47
+ /extensions\//i,
48
+ /^chrome:\/\//i,
49
+ // Other plugins
50
+ /127\.0\.0\.1:4001\/isrunning/i,
51
+ /webappstoolbarba\.texthelp\.com\//i,
52
+ /metrics\.itunes\.apple\.com\.edgesuite\.net\//i,
53
+ ];
54
+ const sentryLogger = ({ publicKey, environment, release, project }) => {
55
+ let globalHub;
56
+ let currentHub;
57
+ const initHub = () => {
58
+ const client = new Client({
59
+ environment,
60
+ release,
61
+ dsn: `https://${publicKey}@o179049.ingest.sentry.io/${project}`,
62
+ integrations: integrations(),
63
+ tracesSampleRate: 0.5,
64
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
65
+ // @ts-ignore
66
+ enableNative: Platform.OS !== "web",
67
+ autoInitializeNativeSdk: Platform.OS !== "web",
68
+ stackParser: defaultStackParser,
69
+ transport,
70
+ ignoreErrors: IGNORED_ERRORS,
71
+ denyUrls: DENIED_URLS,
72
+ });
73
+ return new Hub(client);
74
+ };
75
+ /**
76
+ * BrowserClient must be initialized before wrapUseRoutes is used.
77
+ *
78
+ * ReactNativeClient cannot be initialized until actual component is rendered.
79
+ * Its initialization will trigger the native sdk setup with the provided settings,
80
+ * but by the time an event will be sent to Sentry, the host project (UAF)
81
+ * will have overridden its configuration (dsn, etc) after initializing it
82
+ * so we have to initialize it after the component mount.
83
+ */
84
+ if (Platform.OS === "web") {
85
+ currentHub = initHub();
86
+ }
87
+ const onMount = (customerId) => {
88
+ // currentHub won't be initialized in native until this time
89
+ currentHub = currentHub ?? initHub();
90
+ currentHub.setUser({ id: customerId });
91
+ currentHub.startSession();
92
+ if (!globalHub) {
93
+ globalHub = makeMain(currentHub);
94
+ }
95
+ };
96
+ const onUnMount = () => {
97
+ if (currentHub) {
98
+ currentHub.setUser(null);
99
+ currentHub.endSession();
100
+ }
101
+ if (globalHub) {
102
+ makeMain(globalHub);
103
+ globalHub = null;
104
+ }
105
+ };
106
+ const useRoutes = wrapUseRoutes(reactRouterUseRoutes);
107
+ return (Component) => {
108
+ const WrappedComponent = wrapComponent(Component);
109
+ const SentryLogger = (props) => {
110
+ const { customer } = props;
111
+ useEffect(() => {
112
+ onMount(customer?.customerId);
113
+ return onUnMount;
114
+ // eslint-disable-next-line react-hooks/exhaustive-deps
115
+ }, []);
116
+ return (React.createElement(ErrorBoundary, null,
117
+ React.createElement(WrappedComponent, { ...props, useRoutes: useRoutes })));
118
+ };
119
+ return SentryLogger;
120
+ };
121
+ };
122
+ export { sentryLogger };
@@ -0,0 +1,49 @@
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 { TransactionContext } from "@sentry/types";
5
+ import { Location, MatchRoutes, UseEffect, UseLocation, WrapUseRoutes } from "../types";
6
+ import { NavigationCurrentRoute, NavigationRoute } from "./types";
7
+ /**
8
+ * This instrumentation has been built taking as an example the actual
9
+ * ReactNavigationV4Instrumentation implementation as suggested in the documentation.
10
+ *
11
+ * (https://docs.sentry.io/platforms/react-native/performance/instrumentation/automatic-instrumentation/#custom-instrumentation)
12
+ * (https://github.com/getsentry/sentry-react-native/blob/211ec081b6bf8d7d29541afe9d800040f61e3c4e/src/js/tracing/reactnavigationv4.ts)
13
+ */
14
+ interface NavigationTransactionContext extends TransactionContext {
15
+ readonly tags: {
16
+ readonly ["routing.instrumentation"]: string;
17
+ readonly ["routing.route.name"]: string;
18
+ };
19
+ readonly data: {
20
+ readonly route: NavigationCurrentRoute;
21
+ readonly previousRoute: NavigationRoute | null;
22
+ };
23
+ }
24
+ interface NativeReactRouterV6InstrumentationConstructorArgs {
25
+ readonly useEffect: UseEffect;
26
+ readonly useLocation: UseLocation;
27
+ readonly matchRoutes: MatchRoutes;
28
+ readonly transformLocation?: (location: Location) => Location;
29
+ }
30
+ declare class NativeReactRouterV6Instrumentation extends RoutingInstrumentation {
31
+ static instrumentationName: string;
32
+ private useEffect;
33
+ private useLocation;
34
+ private matchRoutes;
35
+ private transformLocation;
36
+ private prevRoute?;
37
+ private recentRouteKeys;
38
+ private latestTransaction?;
39
+ private readonly maxRecentRouteLen;
40
+ constructor({ useEffect, useLocation, matchRoutes, transformLocation, }: NativeReactRouterV6InstrumentationConstructorArgs);
41
+ registerRoutingInstrumentation(listener: TransactionCreator, beforeNavigate: BeforeNavigate, onConfirmRoute: OnConfirmRoute): void;
42
+ private onRouteChange;
43
+ private currentRouteFromLocation;
44
+ private pushRecentRouteKey;
45
+ private onBeforeNavigateNotSampled;
46
+ wrapUseRoutes: WrapUseRoutes;
47
+ }
48
+ export type { NavigationTransactionContext };
49
+ export { NativeReactRouterV6Instrumentation };