@lookiero/checkout 0.6.0-beta.34 → 0.6.0-beta.36

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,10 +1,10 @@
1
1
  import { BrowserClient, Hub } from "@sentry/browser";
2
2
  import { ErrorBoundary } from "@sentry/react";
3
3
  import { ReactNativeTransportOptions } from "@sentry/react-native/dist/js/options";
4
- import { Transport, Integration } from "@sentry/types";
5
- import { WrapComponent, WrapUseRoutes } from "./types";
4
+ import { Transport } from "@sentry/types";
5
+ import { Integrations, WrapComponent, WrapUseRoutes } from "./types";
6
6
  declare const transport: (options: ReactNativeTransportOptions) => Transport;
7
- declare const integrations: Integration[];
7
+ declare const integrations: Integrations;
8
8
  declare const wrapComponent: WrapComponent;
9
9
  declare const wrapUseRoutes: WrapUseRoutes;
10
10
  export { BrowserClient as Client, Hub, ErrorBoundary, transport, integrations, wrapComponent, wrapUseRoutes };
@@ -7,7 +7,7 @@ import { useEffect } from "react";
7
7
  import { createRoutesFromChildren, useLocation, useNavigationType } from "react-router-native";
8
8
  import { matchRoutes } from "./matchRoutes";
9
9
  const transport = (options, nativeFetch) => makeFetchTransport(options, nativeFetch);
10
- const integrations = [
10
+ const integrations = () => [
11
11
  ...defaultIntegrations,
12
12
  new BrowserTracing({
13
13
  routingInstrumentation: reactRouterV6Instrumentation(useEffect, useLocation, useNavigationType, createRoutesFromChildren, matchRoutes),
@@ -1,9 +1,9 @@
1
1
  import { ReactNativeClient, Hub, ErrorBoundary } from "@sentry/react-native";
2
2
  import { ReactNativeTransportOptions } from "@sentry/react-native/dist/js/options";
3
- import { Transport, Integration } from "@sentry/types";
4
- import { WrapComponent, WrapUseRoutes } from "./types";
3
+ import { Transport } from "@sentry/types";
4
+ import { Integrations, WrapComponent, WrapUseRoutes } from "./types";
5
5
  declare const transport: (options: ReactNativeTransportOptions) => Transport;
6
- declare const integrations: Integration[];
6
+ declare const integrations: Integrations;
7
7
  declare const wrapComponent: WrapComponent;
8
8
  declare const wrapUseRoutes: WrapUseRoutes;
9
9
  export { ReactNativeClient as Client, Hub, ErrorBoundary, transport, integrations, wrapComponent, wrapUseRoutes };
@@ -7,7 +7,7 @@ import { useLocation } from "react-router-native";
7
7
  import { matchRoutes } from "./matchRoutes";
8
8
  import { ReactRouterV6Instrumentation } from "./reactRouterV6Instrumentation/reactRouterV6Instrumentation.native";
9
9
  const transport = (options, nativeFetch) => {
10
- console.log("NATIVE.isNativeTransportAvailable()", NATIVE.isNativeTransportAvailable());
10
+ console.log("NATIVE.isNativeTransportAvailable()", NATIVE.isNativeTransportAvailable(), options, nativeFetch);
11
11
  console.log(makeReactNativeTransport(options));
12
12
  console.log(makeFetchTransport(options, nativeFetch));
13
13
  return NATIVE.isNativeTransportAvailable()
@@ -15,7 +15,7 @@ const transport = (options, nativeFetch) => {
15
15
  : makeFetchTransport(options, nativeFetch);
16
16
  };
17
17
  const routingInstrumentation = new ReactRouterV6Instrumentation(useEffect, useLocation, matchRoutes);
18
- const integrations = [new ReactNativeTracing({ routingInstrumentation })];
18
+ const integrations = () => [new ReactNativeTracing({ routingInstrumentation })];
19
19
  const wrapComponent = (Component) => sentryWrap(Component);
20
20
  const wrapUseRoutes = routingInstrumentation.wrapUseRoutes.bind(routingInstrumentation);
21
21
  export { ReactNativeClient as Client, Hub, ErrorBoundary, transport, integrations, wrapComponent, wrapUseRoutes };
@@ -4,85 +4,95 @@ import React, { useEffect } from "react";
4
4
  import { Platform } from "react-native";
5
5
  import { useRoutes as reactRouterUseRoutes } from "react-router-native";
6
6
  import { Client, Hub, ErrorBoundary, transport, integrations, wrapComponent, wrapUseRoutes, } 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
+ ];
7
54
  const sentryLogger = ({ publicKey, environment, release, project }) => {
8
- let mainHub;
9
- const client = new Client({
10
- environment,
11
- release,
12
- dsn: `https://${publicKey}@o179049.ingest.sentry.io/${project}`,
13
- integrations,
14
- tracesSampleRate: 1.0,
15
- debug: true,
16
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
17
- // @ts-ignore
18
- enableNative: Platform.OS !== "web",
19
- autoInitializeNativeSdk: Platform.OS !== "web",
20
- stackParser: defaultStackParser,
21
- transport,
22
- // This configuration is obtained from
23
- // https://docs.sentry.io/clients/javascript/tips/#decluttering-sentry
24
- ignoreErrors: [
25
- // Random plugins/extensions
26
- "top.GLOBALS",
27
- // See: http://blog.errorception.com/2012/03/tale-of-unfindable-js-error.html
28
- "originalCreateNotification",
29
- "canvas.contentDocument",
30
- "MyApp_RemoveAllHighlights",
31
- "http://tt.epicplay.com",
32
- "Can't find variable: ZiteReader",
33
- "jigsaw is not defined",
34
- "ComboSearch is not defined",
35
- "http://loading.retry.widdit.com/",
36
- "atomicFindClose",
37
- // Facebook borked
38
- "fb_xd_fragment",
39
- // ISP "optimizing" proxy - `Cache-Control: no-transform` seems to reduce this. (thanks @acdha)
40
- // See http://stackoverflow.com/questions/4113268/how-to-stop-javascript-injection-from-vodafone-proxy
41
- "bmi_SafeAddOnload",
42
- "EBCallBackMessageReceived",
43
- // See http://toolbar.conduit.com/Developer/HtmlAndGadget/Methods/JSInjection.aspx
44
- "conduitPage",
45
- // Generic error code from errors outside the security sandbox
46
- // You can delete this if using raven.js > 1.0, which ignores these automatically.
47
- "Script error.",
48
- // Avast extension error
49
- "_avast_submit",
50
- ],
51
- denyUrls: [
52
- // Google Adsense
53
- /pagead\/js/i,
54
- // Facebook flakiness
55
- /graph\.facebook\.com/i,
56
- // Facebook blocked
57
- /connect\.facebook\.net\/en_US\/all\.js/i,
58
- // Woopra flakiness
59
- /eatdifferent\.com\.woopra-ns\.com/i,
60
- /static\.woopra\.com\/js\/woopra\.js/i,
61
- // Chrome extensions
62
- /extensions\//i,
63
- /^chrome:\/\//i,
64
- // Other plugins
65
- /127\.0\.0\.1:4001\/isrunning/i,
66
- /webappstoolbarba\.texthelp\.com\//i,
67
- /metrics\.itunes\.apple\.com\.edgesuite\.net\//i,
68
- ],
69
- beforeSendTransaction: (event, hint) => {
70
- console.log(event, hint);
71
- return event;
72
- },
73
- });
74
- const hub = new Hub(client);
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: 1.0,
64
+ debug: true,
65
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
66
+ // @ts-ignore
67
+ enableNative: Platform.OS !== "web",
68
+ autoInitializeNativeSdk: Platform.OS !== "web",
69
+ stackParser: defaultStackParser,
70
+ transport,
71
+ ignoreErrors: IGNORED_ERRORS,
72
+ denyUrls: DENIED_URLS,
73
+ });
74
+ return new Hub(client);
75
+ };
75
76
  const onMount = (customerId) => {
76
- if (!mainHub) {
77
- hub.setUser({ id: customerId });
78
- hub.startSession();
79
- mainHub = makeMain(hub);
77
+ if (!currentHub) {
78
+ currentHub = initHub();
79
+ currentHub.setUser({ id: customerId });
80
+ currentHub.startSession();
81
+ }
82
+ if (!globalHub) {
83
+ globalHub = makeMain(currentHub);
80
84
  }
81
85
  };
82
86
  const onUnMount = () => {
83
- hub.setUser(null);
84
- hub.endSession();
85
- makeMain(mainHub);
87
+ if (currentHub) {
88
+ currentHub.setUser(null);
89
+ currentHub.endSession();
90
+ currentHub = null;
91
+ }
92
+ if (globalHub) {
93
+ makeMain(globalHub);
94
+ globalHub = null;
95
+ }
86
96
  };
87
97
  const useRoutes = wrapUseRoutes(reactRouterUseRoutes);
88
98
  return (Component) => {
@@ -92,7 +102,8 @@ const sentryLogger = ({ publicKey, environment, release, project }) => {
92
102
  useEffect(() => {
93
103
  onMount(customer?.customerId);
94
104
  return onUnMount;
95
- }, [customer?.customerId]);
105
+ // eslint-disable-next-line react-hooks/exhaustive-deps
106
+ }, []);
96
107
  return (React.createElement(ErrorBoundary, null,
97
108
  React.createElement(WrappedComponent, { ...props, useRoutes: useRoutes })));
98
109
  };
@@ -2,6 +2,13 @@ import { RoutingInstrumentation } from "@sentry/react-native";
2
2
  import { OnConfirmRoute, TransactionCreator } from "@sentry/react-native/dist/js/tracing/routingInstrumentation";
3
3
  import { BeforeNavigate } from "@sentry/react-native/dist/js/tracing/types";
4
4
  import { MatchRoutes, UseEffect, UseLocation, WrapUseRoutes } from "../types";
5
+ /**
6
+ * This instrumentation has been built following the actual
7
+ * ReactNavigationV4Instrumentation implementation as suggested in the documentation.
8
+ *
9
+ * (https://docs.sentry.io/platforms/react-native/performance/instrumentation/automatic-instrumentation/#custom-instrumentation)
10
+ * (https://github.com/getsentry/sentry-react-native/blob/211ec081b6bf8d7d29541afe9d800040f61e3c4e/src/js/tracing/reactnavigationv4.ts)
11
+ */
5
12
  declare class ReactRouterV6Instrumentation extends RoutingInstrumentation {
6
13
  static instrumentationName: string;
7
14
  private useEffect;
@@ -4,6 +4,13 @@ import { logger } from "@sentry/utils";
4
4
  import React from "react";
5
5
  import { normalizedNameAndMatchForLocation } from "./normalizedNameAndMatchForLocation";
6
6
  import { transactionContext } from "./transactionContext";
7
+ /**
8
+ * This instrumentation has been built following 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
+ */
7
14
  class ReactRouterV6Instrumentation extends RoutingInstrumentation {
8
15
  static instrumentationName = "react-router-v6";
9
16
  useEffect;
@@ -1,3 +1,4 @@
1
+ import { Integration } from "@sentry/types";
1
2
  import { ComponentType, useEffect } from "react";
2
3
  import { matchRoutes, RouteObject, useLocation } from "react-router-native";
3
4
  interface Location {
@@ -13,4 +14,7 @@ interface WrapUseRoutes {
13
14
  interface WrapComponent {
14
15
  <P>(Component: ComponentType<P>): ComponentType<P>;
15
16
  }
16
- export type { Location, UseEffect, UseLocation, MatchRoutes, UseRoutes, WrapUseRoutes, WrapComponent };
17
+ interface Integrations {
18
+ (): Integration[];
19
+ }
20
+ export type { Location, Integrations, UseEffect, UseLocation, MatchRoutes, UseRoutes, WrapUseRoutes, WrapComponent };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.6.0-beta.34",
3
+ "version": "0.6.0-beta.36",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [