@lookiero/checkout 0.6.0-beta.37 → 0.6.0-beta.38

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,9 +1,12 @@
1
+ import { matchRoutes as reactRouterMatchRoutes } from "@remix-run/router";
1
2
  import { BrowserClient, Hub } from "@sentry/browser";
2
3
  import { ErrorBoundary } from "@sentry/react";
3
4
  import { ReactNativeTransportOptions } from "@sentry/react-native/dist/js/options";
4
5
  import { Transport } from "@sentry/types";
5
6
  import { Integrations, WrapComponent, WrapUseRoutes } from "./types";
6
7
  declare const transport: (options: ReactNativeTransportOptions) => Transport;
8
+ declare const matchRoutes: typeof reactRouterMatchRoutes;
9
+ export { matchRoutes };
7
10
  declare const integrations: Integrations;
8
11
  declare const wrapComponent: WrapComponent;
9
12
  declare const wrapUseRoutes: WrapUseRoutes;
@@ -1,3 +1,4 @@
1
+ import { matchRoutes as reactRouterMatchRoutes } from "@remix-run/router";
1
2
  import { BrowserClient, Hub, makeFetchTransport, defaultIntegrations } from "@sentry/browser";
2
3
  import { ErrorBoundary } from "@sentry/react";
3
4
  import { reactRouterV6Instrumentation } from "@sentry/react";
@@ -5,8 +6,11 @@ import { wrapUseRoutes as reactRouterV6WrapUseRoutes } from "@sentry/react";
5
6
  import { BrowserTracing } from "@sentry/tracing";
6
7
  import { useEffect } from "react";
7
8
  import { createRoutesFromChildren, useLocation, useNavigationType } from "react-router-native";
8
- import { matchRoutes } from "./matchRoutes";
9
+ import { stripFirstSlugFromLocation } from "./location";
9
10
  const transport = (options, nativeFetch) => makeFetchTransport(options, nativeFetch);
11
+ // Remove the location's first path ("/checkout"). Otherwise it won't match the proper route.
12
+ const matchRoutes = (routes, locationArg) => reactRouterMatchRoutes(routes, stripFirstSlugFromLocation(locationArg));
13
+ export { matchRoutes };
10
14
  const integrations = () => [
11
15
  ...defaultIntegrations,
12
16
  new BrowserTracing({
@@ -3,8 +3,7 @@ import { ReactNativeClient, Hub, ErrorBoundary, wrap as sentryWrap, ReactNativeT
3
3
  import { makeReactNativeTransport } from "@sentry/react-native/dist/js/transports/native";
4
4
  import { NATIVE } from "@sentry/react-native/dist/js/wrapper";
5
5
  import { useEffect } from "react";
6
- import { useLocation } from "react-router-native";
7
- import { matchRoutes } from "./matchRoutes";
6
+ import { matchRoutes, useLocation } from "react-router-native";
8
7
  import { ReactRouterV6Instrumentation } from "./reactRouterV6Instrumentation/reactRouterV6Instrumentation.native";
9
8
  const transport = (options, nativeFetch) => {
10
9
  console.log("NATIVE.isNativeTransportAvailable()", NATIVE.isNativeTransportAvailable(), options, nativeFetch);
@@ -0,0 +1,3 @@
1
+ import { Location } from "./types";
2
+ declare const stripFirstSlugFromLocation: (locationArg: string | Location) => Location;
3
+ export { stripFirstSlugFromLocation };
@@ -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 };
@@ -2,6 +2,7 @@
2
2
  import { RoutingInstrumentation } from "@sentry/react-native";
3
3
  import { logger } from "@sentry/utils";
4
4
  import React from "react";
5
+ import { stripFirstSlugFromLocation } from "../location";
5
6
  import { normalizedNameAndMatchForLocation } from "./normalizedNameAndMatchForLocation";
6
7
  import { transactionContext } from "./transactionContext";
7
8
  /**
@@ -58,11 +59,16 @@ class ReactRouterV6Instrumentation extends RoutingInstrumentation {
58
59
  this.prevRoute = currentRoute;
59
60
  }
60
61
  currentRouteFromLocation(location, routes) {
61
- const branches = this.matchRoutes(routes, location);
62
+ const normalizedLocation = stripFirstSlugFromLocation(location);
63
+ const branches = this.matchRoutes(routes, normalizedLocation);
62
64
  if (!branches) {
63
65
  return null;
64
66
  }
65
- const [normalizedName, match] = normalizedNameAndMatchForLocation({ location, routes, branches });
67
+ const [normalizedName, match] = normalizedNameAndMatchForLocation({
68
+ location: normalizedLocation,
69
+ routes,
70
+ branches,
71
+ });
66
72
  if (!match) {
67
73
  return {
68
74
  name: normalizedName,
@@ -71,13 +77,11 @@ class ReactRouterV6Instrumentation extends RoutingInstrumentation {
71
77
  hasBeenSeen: this.recentRouteKeys.includes(normalizedName),
72
78
  };
73
79
  }
74
- const name = match.route.path;
75
- const key = match.route.id ?? name;
76
80
  return {
77
- name,
78
- key,
81
+ name: match.route.path,
82
+ key: normalizedName,
79
83
  params: match.params,
80
- hasBeenSeen: this.recentRouteKeys.includes(key),
84
+ hasBeenSeen: this.recentRouteKeys.includes(normalizedName),
81
85
  };
82
86
  }
83
87
  pushRecentRouteKey(key) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.6.0-beta.37",
3
+ "version": "0.6.0-beta.38",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [