@lookiero/checkout 0.6.4 → 0.7.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/index.d.ts +4 -2
- package/dist/index.js +2 -2
- package/dist/infrastructure/ui/Root.d.ts +6 -2
- package/dist/infrastructure/ui/Root.js +10 -6
- package/dist/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.js +1 -1
- package/dist/infrastructure/ui/routing/Routing.d.ts +11 -3
- package/dist/infrastructure/ui/routing/Routing.js +12 -6
- package/dist/shared/logging/SentryDependencies.d.ts +11 -0
- package/dist/shared/logging/SentryDependencies.js +17 -0
- package/dist/shared/logging/SentryDependencies.native.d.ts +10 -0
- package/dist/shared/logging/SentryDependencies.native.js +15 -0
- package/dist/shared/logging/SentryLogger.d.ts +19 -0
- package/dist/shared/logging/SentryLogger.js +122 -0
- package/dist/shared/logging/reactRouterV6Instrumentation/NativeReactRouterV6Instrumentation.d.ts +49 -0
- package/dist/shared/logging/reactRouterV6Instrumentation/NativeReactRouterV6Instrumentation.js +131 -0
- package/dist/shared/logging/reactRouterV6Instrumentation/location.d.ts +3 -0
- package/dist/shared/logging/reactRouterV6Instrumentation/location.js +5 -0
- package/dist/shared/logging/reactRouterV6Instrumentation/normalizedNameAndMatchForLocation.d.ts +12 -0
- package/dist/shared/logging/reactRouterV6Instrumentation/normalizedNameAndMatchForLocation.js +34 -0
- package/dist/shared/logging/reactRouterV6Instrumentation/reactRouterV6Instrumentation.d.ts +15 -0
- package/dist/shared/logging/reactRouterV6Instrumentation/reactRouterV6Instrumentation.js +92 -0
- package/dist/shared/logging/reactRouterV6Instrumentation/types.d.ts +9 -0
- package/dist/shared/logging/reactRouterV6Instrumentation/types.js +1 -0
- package/dist/shared/logging/types.d.ts +22 -0
- package/dist/shared/logging/types.js +1 -0
- package/dist/shared/ui/components/atoms/field/Field.js +5 -13
- package/dist/shared/ui/components/atoms/field/Field.style.js +2 -2
- package/dist/shared/ui/components/molecules/inputField/InputField.js +2 -2
- package/dist/shared/ui/components/molecules/inputField/InputField.style.d.ts +1 -0
- package/dist/shared/ui/components/molecules/inputField/InputField.style.js +1 -0
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { EndpointFunction } from "@lookiero/i18n";
|
|
2
|
-
import {
|
|
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:
|
|
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 {
|
|
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):
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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 };
|
|
@@ -11,7 +11,7 @@ const CheckoutAccessibilityMiddleware = ({ customerId, onNotAccessible, loader =
|
|
|
11
11
|
if (notAccessible) {
|
|
12
12
|
onNotAccessibleRef.current();
|
|
13
13
|
}
|
|
14
|
-
}, [notAccessible
|
|
14
|
+
}, [notAccessible]);
|
|
15
15
|
return accessible === undefined && [QueryStatus.IDLE, QueryStatus.LOADING].includes(status)
|
|
16
16
|
? loader
|
|
17
17
|
: accessible
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { I18n } from "@lookiero/i18n-react";
|
|
2
|
-
import
|
|
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
|
-
|
|
18
|
-
|
|
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";
|
|
@@ -13,8 +13,8 @@ const Summary = lazy(() => import("../views/summary/Summary").then((module) => (
|
|
|
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
15
|
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
|
-
|
|
16
|
+
const Routing = ({ basePath = "", customer, locale, I18n, menu, tabBar, getAuthToken, onI18nError, onNotAccessible, useRedirect, useRoutes = reactRouterUseRoutes, }) => {
|
|
17
|
+
return useRoutes([
|
|
18
18
|
{
|
|
19
19
|
path: "",
|
|
20
20
|
element: (React.createElement(BasePathProvider, { basePath: basePath },
|
|
@@ -73,6 +73,12 @@ const Routing = ({ basePath = "", customer, locale, I18n, menu, tabBar, getAuthT
|
|
|
73
73
|
],
|
|
74
74
|
},
|
|
75
75
|
]);
|
|
76
|
-
return routes;
|
|
77
76
|
};
|
|
78
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Provided useRoutes is not stable (when integrated with Sentry) as it's rendering a different component tree.
|
|
79
|
+
*
|
|
80
|
+
* https://github.com/getsentry/sentry-javascript/blob/master/packages/react/src/reactrouterv6.tsx#L221
|
|
81
|
+
* (SentryRoutes is a new component after each re-render)
|
|
82
|
+
*/
|
|
83
|
+
const MemoizedRouting = memo(Routing);
|
|
84
|
+
export { MemoizedRouting as Routing };
|
|
@@ -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 };
|
package/dist/shared/logging/reactRouterV6Instrumentation/NativeReactRouterV6Instrumentation.d.ts
ADDED
|
@@ -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 };
|
package/dist/shared/logging/reactRouterV6Instrumentation/NativeReactRouterV6Instrumentation.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
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
|
+
const transactionContext = ({ instrumentationName, route, previousRoute = null, }) => ({
|
|
8
|
+
name: route.name,
|
|
9
|
+
op: "navigation",
|
|
10
|
+
tags: {
|
|
11
|
+
["routing.instrumentation"]: instrumentationName,
|
|
12
|
+
["routing.route.name"]: route.name,
|
|
13
|
+
},
|
|
14
|
+
data: {
|
|
15
|
+
route,
|
|
16
|
+
previousRoute,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
class NativeReactRouterV6Instrumentation extends RoutingInstrumentation {
|
|
20
|
+
static instrumentationName = "react-router-v6";
|
|
21
|
+
useEffect;
|
|
22
|
+
useLocation;
|
|
23
|
+
matchRoutes;
|
|
24
|
+
transformLocation;
|
|
25
|
+
prevRoute;
|
|
26
|
+
recentRouteKeys = [];
|
|
27
|
+
latestTransaction;
|
|
28
|
+
maxRecentRouteLen = 200;
|
|
29
|
+
constructor({ useEffect, useLocation, matchRoutes, transformLocation = stripFirstSlugFromLocation, }) {
|
|
30
|
+
super();
|
|
31
|
+
this.useEffect = useEffect;
|
|
32
|
+
this.useLocation = useLocation;
|
|
33
|
+
this.matchRoutes = matchRoutes;
|
|
34
|
+
this.transformLocation = transformLocation;
|
|
35
|
+
}
|
|
36
|
+
registerRoutingInstrumentation(listener, beforeNavigate, onConfirmRoute) {
|
|
37
|
+
super.registerRoutingInstrumentation(listener, beforeNavigate, onConfirmRoute);
|
|
38
|
+
this.latestTransaction = this.onRouteWillChange(INITIAL_TRANSACTION_CONTEXT);
|
|
39
|
+
}
|
|
40
|
+
onRouteChange(location, routes, updateLatestTransaction = false) {
|
|
41
|
+
const currentRoute = this.currentRouteFromLocation(location, routes);
|
|
42
|
+
if (!currentRoute || (this.prevRoute && currentRoute.key === this.prevRoute.key)) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const originalContext = transactionContext({
|
|
46
|
+
instrumentationName: NativeReactRouterV6Instrumentation.instrumentationName,
|
|
47
|
+
route: currentRoute,
|
|
48
|
+
previousRoute: this.prevRoute,
|
|
49
|
+
});
|
|
50
|
+
let finalContext = this._beforeNavigate?.(originalContext);
|
|
51
|
+
if (!finalContext) {
|
|
52
|
+
logger.error(`[ReactRouterV6Instrumentation] beforeNavigate returned ${finalContext}, return context.sampled = false to not send transaction.`);
|
|
53
|
+
finalContext = { ...originalContext, sampled: false };
|
|
54
|
+
}
|
|
55
|
+
if (finalContext.sampled === false) {
|
|
56
|
+
this.onBeforeNavigateNotSampled(finalContext.name);
|
|
57
|
+
}
|
|
58
|
+
if (updateLatestTransaction && this.latestTransaction) {
|
|
59
|
+
this.latestTransaction.updateWithContext(finalContext);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
this.latestTransaction = this.onRouteWillChange(finalContext);
|
|
63
|
+
}
|
|
64
|
+
this.pushRecentRouteKey(currentRoute.key);
|
|
65
|
+
this.prevRoute = currentRoute;
|
|
66
|
+
}
|
|
67
|
+
currentRouteFromLocation(location, routes) {
|
|
68
|
+
const normalizedLocation = this.transformLocation(location);
|
|
69
|
+
const branches = this.matchRoutes(routes, normalizedLocation);
|
|
70
|
+
if (!branches) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
const [normalizedName, match] = normalizedNameAndMatchForLocation({
|
|
74
|
+
location: normalizedLocation,
|
|
75
|
+
routes,
|
|
76
|
+
branches,
|
|
77
|
+
});
|
|
78
|
+
return {
|
|
79
|
+
name: normalizedName,
|
|
80
|
+
key: normalizedName,
|
|
81
|
+
params: match?.params ?? {},
|
|
82
|
+
hasBeenSeen: this.recentRouteKeys.includes(normalizedName),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
pushRecentRouteKey(key) {
|
|
86
|
+
this.recentRouteKeys.push(key);
|
|
87
|
+
if (this.recentRouteKeys.length > this.maxRecentRouteLen) {
|
|
88
|
+
this.recentRouteKeys = this.recentRouteKeys.slice(this.recentRouteKeys.length - this.maxRecentRouteLen);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
onBeforeNavigateNotSampled(transactionName) {
|
|
92
|
+
logger.log(`[ReactRouterV6Instrumentation] Will not send transaction "${transactionName}" due to beforeNavigate.`);
|
|
93
|
+
}
|
|
94
|
+
wrapUseRoutes = (origUseRoutes) => {
|
|
95
|
+
if (!this.useEffect || !this.useLocation || !this.matchRoutes) {
|
|
96
|
+
logger.warn("ReactRouterV6Instrumentation was unable to wrap `useRoutes` because of one or more missing parameters.");
|
|
97
|
+
return origUseRoutes;
|
|
98
|
+
}
|
|
99
|
+
let isMountRenderPass = true;
|
|
100
|
+
const useRoutes = (routes, locationArg) => {
|
|
101
|
+
const SentryRoutes = () => {
|
|
102
|
+
const Routes = origUseRoutes(routes, locationArg);
|
|
103
|
+
const location = this.useLocation();
|
|
104
|
+
const stableLocationParam = typeof locationArg === "string" || (locationArg && locationArg.pathname)
|
|
105
|
+
? locationArg
|
|
106
|
+
: location;
|
|
107
|
+
this.useEffect(() => {
|
|
108
|
+
const normalizedLocation = typeof stableLocationParam === "string" ? { pathname: stableLocationParam } : stableLocationParam;
|
|
109
|
+
if (isMountRenderPass) {
|
|
110
|
+
this.onRouteChange(normalizedLocation, routes, true);
|
|
111
|
+
isMountRenderPass = false;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
this.onRouteChange(normalizedLocation, routes);
|
|
115
|
+
}
|
|
116
|
+
}, [stableLocationParam]);
|
|
117
|
+
return Routes;
|
|
118
|
+
};
|
|
119
|
+
return React.createElement(SentryRoutes, null);
|
|
120
|
+
};
|
|
121
|
+
return useRoutes;
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
const INITIAL_TRANSACTION_CONTEXT = {
|
|
125
|
+
name: "App Launch",
|
|
126
|
+
op: "navigation",
|
|
127
|
+
tags: {
|
|
128
|
+
["routing.instrumentation"]: NativeReactRouterV6Instrumentation.instrumentationName,
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
export { NativeReactRouterV6Instrumentation };
|
|
@@ -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 };
|
package/dist/shared/logging/reactRouterV6Instrumentation/normalizedNameAndMatchForLocation.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RouteMatch, RouteObject } from "react-router-native";
|
|
2
|
+
import { Location } from "../types";
|
|
3
|
+
interface NormalizedNameAndMatchForLocationFunctionArgs {
|
|
4
|
+
readonly routes?: RouteObject[];
|
|
5
|
+
readonly location: Location;
|
|
6
|
+
readonly branches: RouteMatch[];
|
|
7
|
+
}
|
|
8
|
+
interface NormalizedNameAndMatchForLocationFunction {
|
|
9
|
+
(args: NormalizedNameAndMatchForLocationFunctionArgs): [string, RouteMatch | null];
|
|
10
|
+
}
|
|
11
|
+
declare const normalizedNameAndMatchForLocation: NormalizedNameAndMatchForLocationFunction;
|
|
12
|
+
export { normalizedNameAndMatchForLocation };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { getNumberOfUrlSegments } from "@sentry/utils";
|
|
2
|
+
const normalizedNameAndMatchForLocation = ({ routes, location, branches, }) => {
|
|
3
|
+
if (!routes || routes.length === 0) {
|
|
4
|
+
return [location.pathname, null];
|
|
5
|
+
}
|
|
6
|
+
let pathBuilder = "";
|
|
7
|
+
if (branches) {
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
9
|
+
for (let x = 0; x < branches.length; x++) {
|
|
10
|
+
const branch = branches[x];
|
|
11
|
+
const route = branch.route;
|
|
12
|
+
if (route) {
|
|
13
|
+
// Early return if index route
|
|
14
|
+
if (route.index) {
|
|
15
|
+
return [branch.pathname, branch];
|
|
16
|
+
}
|
|
17
|
+
const path = route.path;
|
|
18
|
+
if (path) {
|
|
19
|
+
const newPath = path[0] === "/" || pathBuilder[pathBuilder.length - 1] === "/" ? path : `/${path}`;
|
|
20
|
+
pathBuilder += newPath;
|
|
21
|
+
if (branch.pathname === location.pathname) {
|
|
22
|
+
if (getNumberOfUrlSegments(pathBuilder) !== getNumberOfUrlSegments(branch.pathname) &&
|
|
23
|
+
pathBuilder.slice(-2) !== "/*") {
|
|
24
|
+
return [newPath, branch];
|
|
25
|
+
}
|
|
26
|
+
return [pathBuilder, branch];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return [location.pathname, null];
|
|
33
|
+
};
|
|
34
|
+
export { normalizedNameAndMatchForLocation };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Transaction, TransactionContext } from "@sentry/types";
|
|
2
|
+
import { Location, MatchRoutes, UseEffect, UseLocation, UseNavigationType, WrapUseRoutes } from "../types";
|
|
3
|
+
interface ReactRouterV6InstrumentationFunctionArgs {
|
|
4
|
+
readonly useEffect: UseEffect;
|
|
5
|
+
readonly useLocation: UseLocation;
|
|
6
|
+
readonly useNavigationType: UseNavigationType;
|
|
7
|
+
readonly matchRoutes: MatchRoutes;
|
|
8
|
+
readonly transformLocation?: (location: Location) => Location;
|
|
9
|
+
}
|
|
10
|
+
interface ReactRouterV6InstrumentationFunction {
|
|
11
|
+
(args: ReactRouterV6InstrumentationFunctionArgs): (customStartTransaction: (context: TransactionContext) => Transaction | undefined, startTransactionOnPageLoad?: boolean, startTransactionOnLocationChange?: boolean) => void;
|
|
12
|
+
}
|
|
13
|
+
declare const reactRouterV6Instrumentation: ReactRouterV6InstrumentationFunction;
|
|
14
|
+
declare const wrapUseRoutes: WrapUseRoutes;
|
|
15
|
+
export { reactRouterV6Instrumentation, wrapUseRoutes };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { WINDOW } from "@sentry/browser";
|
|
2
|
+
import { logger } from "@sentry/utils";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { stripFirstSlugFromLocation } from "./location";
|
|
5
|
+
import { normalizedNameAndMatchForLocation } from "./normalizedNameAndMatchForLocation";
|
|
6
|
+
const transactionContext = ({ instrumentationName, op, routeName, source, }) => ({
|
|
7
|
+
name: routeName,
|
|
8
|
+
op,
|
|
9
|
+
tags: {
|
|
10
|
+
["routing.instrumentation"]: instrumentationName,
|
|
11
|
+
["routing.route.name"]: routeName,
|
|
12
|
+
},
|
|
13
|
+
metadata: {
|
|
14
|
+
source,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
const instrumentationName = "react-router-v6";
|
|
18
|
+
let activeTransaction;
|
|
19
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
20
|
+
let _useEffect;
|
|
21
|
+
let _useLocation;
|
|
22
|
+
let _useNavigationType;
|
|
23
|
+
let _matchRoutes;
|
|
24
|
+
let _customStartTransaction;
|
|
25
|
+
let _startTransactionOnLocationChange;
|
|
26
|
+
let _transformLocation;
|
|
27
|
+
const reactRouterV6Instrumentation = ({ useEffect, useLocation, useNavigationType, matchRoutes, transformLocation = stripFirstSlugFromLocation, }) => {
|
|
28
|
+
return (customStartTransaction, startTransactionOnPageLoad = true, startTransactionOnLocationChange = true) => {
|
|
29
|
+
const initPathName = WINDOW && WINDOW.location && WINDOW.location.pathname;
|
|
30
|
+
if (startTransactionOnPageLoad && initPathName) {
|
|
31
|
+
activeTransaction = customStartTransaction(transactionContext({ instrumentationName, op: "pageload", routeName: initPathName, source: "url" }));
|
|
32
|
+
}
|
|
33
|
+
_useEffect = useEffect;
|
|
34
|
+
_useLocation = useLocation;
|
|
35
|
+
_useNavigationType = useNavigationType;
|
|
36
|
+
_matchRoutes = matchRoutes;
|
|
37
|
+
_customStartTransaction = customStartTransaction;
|
|
38
|
+
_startTransactionOnLocationChange = startTransactionOnLocationChange;
|
|
39
|
+
_transformLocation = transformLocation;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
const updatePageloadTransaction = (location, routes) => {
|
|
43
|
+
const branches = _matchRoutes(routes, location);
|
|
44
|
+
if (activeTransaction && branches) {
|
|
45
|
+
const [name, match] = normalizedNameAndMatchForLocation({ routes, location, branches });
|
|
46
|
+
const source = match ? "route" : "url";
|
|
47
|
+
activeTransaction.setName(name, source);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const handleNavigation = (location, routes, navigationType) => {
|
|
51
|
+
const branches = _matchRoutes(routes, location);
|
|
52
|
+
if (_startTransactionOnLocationChange && (navigationType === "PUSH" || navigationType === "POP") && branches) {
|
|
53
|
+
if (activeTransaction) {
|
|
54
|
+
activeTransaction.finish();
|
|
55
|
+
}
|
|
56
|
+
const [name, match] = normalizedNameAndMatchForLocation({ routes, location, branches });
|
|
57
|
+
const source = match ? "route" : "url";
|
|
58
|
+
activeTransaction = _customStartTransaction(transactionContext({ instrumentationName, op: "navigation", routeName: name, source }));
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const wrapUseRoutes = (origUseRoutes) => {
|
|
62
|
+
if (!_useEffect || !_useLocation || !_useNavigationType || !_matchRoutes || !_customStartTransaction) {
|
|
63
|
+
logger.warn("reactRouterV6Instrumentation was unable to wrap `useRoutes` because of one or more missing parameters.");
|
|
64
|
+
return origUseRoutes;
|
|
65
|
+
}
|
|
66
|
+
let isMountRenderPass = true;
|
|
67
|
+
// eslint-disable-next-line react/display-name
|
|
68
|
+
return (routes, locationArg) => {
|
|
69
|
+
const SentryRoutes = () => {
|
|
70
|
+
const Routes = origUseRoutes(routes, locationArg);
|
|
71
|
+
const location = _useLocation();
|
|
72
|
+
const navigationType = _useNavigationType();
|
|
73
|
+
// A value with stable identity to either pick `locationArg` if available or `location` if not
|
|
74
|
+
const stableLocationParam = typeof locationArg === "string" || (locationArg && locationArg.pathname)
|
|
75
|
+
? locationArg
|
|
76
|
+
: location;
|
|
77
|
+
_useEffect(() => {
|
|
78
|
+
const normalizedLocation = typeof stableLocationParam === "string" ? { pathname: stableLocationParam } : stableLocationParam;
|
|
79
|
+
if (isMountRenderPass) {
|
|
80
|
+
updatePageloadTransaction(_transformLocation(normalizedLocation), routes);
|
|
81
|
+
isMountRenderPass = false;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
handleNavigation(_transformLocation(normalizedLocation), routes, navigationType);
|
|
85
|
+
}
|
|
86
|
+
}, [navigationType, stableLocationParam]);
|
|
87
|
+
return Routes;
|
|
88
|
+
};
|
|
89
|
+
return React.createElement(SentryRoutes, null);
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
export { reactRouterV6Instrumentation, wrapUseRoutes };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface NavigationRoute {
|
|
2
|
+
readonly name: string;
|
|
3
|
+
readonly key: string;
|
|
4
|
+
readonly params: Record<string, unknown>;
|
|
5
|
+
}
|
|
6
|
+
interface NavigationCurrentRoute extends NavigationRoute {
|
|
7
|
+
readonly hasBeenSeen: boolean;
|
|
8
|
+
}
|
|
9
|
+
export type { NavigationRoute, NavigationCurrentRoute };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Integration } from "@sentry/types";
|
|
2
|
+
import { ComponentType, useEffect } from "react";
|
|
3
|
+
import { matchRoutes, RouteObject, useLocation } from "react-router-native";
|
|
4
|
+
interface Location {
|
|
5
|
+
readonly pathname: string;
|
|
6
|
+
}
|
|
7
|
+
type UseEffect = typeof useEffect;
|
|
8
|
+
type UseLocation = typeof useLocation;
|
|
9
|
+
type MatchRoutes = typeof matchRoutes;
|
|
10
|
+
type NavigationType = "PUSH" | "REPLACE" | "POP";
|
|
11
|
+
type UseNavigationType = () => NavigationType;
|
|
12
|
+
type UseRoutes = (routes: RouteObject[], locationArg?: Partial<Location> | string) => React.ReactElement | null;
|
|
13
|
+
interface WrapUseRoutes {
|
|
14
|
+
(useRoutes: UseRoutes): UseRoutes;
|
|
15
|
+
}
|
|
16
|
+
interface WrapComponent {
|
|
17
|
+
<P>(Component: ComponentType<P>): ComponentType<P>;
|
|
18
|
+
}
|
|
19
|
+
interface Integrations {
|
|
20
|
+
(): Integration[];
|
|
21
|
+
}
|
|
22
|
+
export type { Location, Integrations, UseEffect, UseLocation, NavigationType, UseNavigationType, MatchRoutes, UseRoutes, WrapUseRoutes, WrapComponent, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -4,22 +4,14 @@ import React from "react";
|
|
|
4
4
|
import { View } from "react-native";
|
|
5
5
|
import { theme } from "../../../../../infrastructure/ui/theme/theme";
|
|
6
6
|
import { style } from "./Field.style";
|
|
7
|
-
const { spaceM } = theme();
|
|
7
|
+
const { spaceM, spaceXL } = theme();
|
|
8
8
|
const Field = ({ label, isFocused = false, style: customStyle }) => {
|
|
9
|
-
const springs = useSpring(isFocused
|
|
9
|
+
const springs = useSpring(isFocused
|
|
10
|
+
? { scale: 0.75, translateY: -14, translateX: -spaceXL }
|
|
11
|
+
: { scale: 1, translateY: spaceM, translateX: 0 });
|
|
10
12
|
return (React.createElement(animated.View, { pointerEvents: "none", style: [
|
|
11
13
|
{
|
|
12
|
-
transform: [
|
|
13
|
-
{
|
|
14
|
-
scale: springs.scale,
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
translateY: springs.translateY,
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
translateX: springs.translateX,
|
|
21
|
-
},
|
|
22
|
-
],
|
|
14
|
+
transform: [{ scale: springs.scale }, { translateY: springs.translateY }, { translateX: springs.translateX }],
|
|
23
15
|
},
|
|
24
16
|
customStyle?.field,
|
|
25
17
|
] },
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StyleSheet } from "react-native";
|
|
2
2
|
import { theme } from "../../../../../infrastructure/ui/theme/theme";
|
|
3
|
-
const { colorBase,
|
|
3
|
+
const { colorBase, spaceM } = theme();
|
|
4
4
|
const style = StyleSheet.create({
|
|
5
5
|
fieldBackground: {
|
|
6
6
|
backgroundColor: colorBase,
|
|
@@ -12,7 +12,7 @@ const style = StyleSheet.create({
|
|
|
12
12
|
fieldText: {
|
|
13
13
|
flexWrap: "nowrap",
|
|
14
14
|
overflow: "hidden",
|
|
15
|
-
paddingHorizontal:
|
|
15
|
+
paddingHorizontal: spaceM,
|
|
16
16
|
zIndex: 1,
|
|
17
17
|
},
|
|
18
18
|
});
|
|
@@ -7,8 +7,8 @@ import { Icon } from "../../atoms/icon/Icon";
|
|
|
7
7
|
import { Input } from "../../atoms/input/Input";
|
|
8
8
|
import { style } from "./InputField.style";
|
|
9
9
|
const { colorBase, colorContent, colorGrayscaleL, colorPrimary, spaceM, iconSize } = theme();
|
|
10
|
-
const inputPaddingRightWithIcon = iconSize + spaceM
|
|
11
|
-
const inputPaddingRightWithoutIcon = spaceM
|
|
10
|
+
const inputPaddingRightWithIcon = iconSize + spaceM;
|
|
11
|
+
const inputPaddingRightWithoutIcon = spaceM;
|
|
12
12
|
const InputField = ({ label, placeholder, value, multiline = false, minHeight, error, style: customStyle, onChange = () => void 0, icon, ...inputRestProps }) => {
|
|
13
13
|
const [isFocused, setIsFocused] = useState(false);
|
|
14
14
|
const handleOnChange = useCallback((text) => onChange(text), [onChange]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lookiero/checkout",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -33,6 +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
37
|
"inline-style-prefixer": "6.0.1",
|
|
37
38
|
"react-native-safe-area-context": "^4.4.1",
|
|
38
39
|
"react-native-svg": "^12.1.1",
|