Skip to content

Commit 6d8a543

Browse files
fix(react): revert matchRoutes API changes
1 parent 67bb292 commit 6d8a543

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

packages/react/src/tanstackrouter.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ import {
77

88
import { browserTracingIntegration as originalBrowserTracingIntegration } from '@sentry/browser';
99
import type { Integration } from '@sentry/types';
10-
import type {
11-
VendoredTanstackRouter,
12-
VendoredTanstackRouterLocation,
13-
VendoredTanstackRouterRouteMatch,
14-
} from './vendor/tanstackrouter-types';
10+
import type { VendoredTanstackRouter, VendoredTanstackRouterRouteMatch } from './vendor/tanstackrouter-types';
1511

1612
/**
1713
* A custom browser tracing integration for TanStack Router.
@@ -44,10 +40,8 @@ export function tanstackRouterBrowserTracingIntegration(
4440
const initialWindowLocation = WINDOW.location;
4541
if (instrumentPageLoad && initialWindowLocation) {
4642
const matchedRoutes = castRouterInstance.matchRoutes(
47-
{
48-
pathname: initialWindowLocation.pathname,
49-
search: castRouterInstance.options.parseSearch(initialWindowLocation.search),
50-
} as VendoredTanstackRouterLocation,
43+
initialWindowLocation.pathname,
44+
castRouterInstance.options.parseSearch(initialWindowLocation.search),
5145
{ preload: false, throwOnError: false },
5246
);
5347

@@ -72,10 +66,11 @@ export function tanstackRouterBrowserTracingIntegration(
7266
return;
7367
}
7468

75-
const onResolvedMatchedRoutes = castRouterInstance.matchRoutes(onBeforeNavigateArgs.toLocation, {
76-
preload: false,
77-
throwOnError: false,
78-
});
69+
const onResolvedMatchedRoutes = castRouterInstance.matchRoutes(
70+
onBeforeNavigateArgs.toLocation.pathname,
71+
onBeforeNavigateArgs.toLocation.search,
72+
{ preload: false, throwOnError: false },
73+
);
7974

8075
const onBeforeNavigateLastMatch = onResolvedMatchedRoutes[onResolvedMatchedRoutes.length - 1];
8176

@@ -93,10 +88,11 @@ export function tanstackRouterBrowserTracingIntegration(
9388
const unsubscribeOnResolved = castRouterInstance.subscribe('onResolved', onResolvedArgs => {
9489
unsubscribeOnResolved();
9590
if (navigationSpan) {
96-
const onResolvedMatchedRoutes = castRouterInstance.matchRoutes(onResolvedArgs.toLocation, {
97-
preload: false,
98-
throwOnError: false,
99-
});
91+
const onResolvedMatchedRoutes = castRouterInstance.matchRoutes(
92+
onResolvedArgs.toLocation.pathname,
93+
onResolvedArgs.toLocation.search,
94+
{ preload: false, throwOnError: false },
95+
);
10096

10197
const onResolvedLastMatch = onResolvedMatchedRoutes[onResolvedMatchedRoutes.length - 1];
10298

packages/react/src/vendor/tanstackrouter-types.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,13 @@ export interface VendoredTanstackRouter {
3434
parseSearch: (search: string) => Record<string, any>;
3535
};
3636
matchRoutes: (
37-
location: VendoredTanstackRouterLocation,
38-
opts?: { preload?: boolean; throwOnError?: boolean },
37+
pathname: string,
38+
// eslint-disable-next-line @typescript-eslint/ban-types
39+
locationSearch: {},
40+
opts?: {
41+
preload?: boolean;
42+
throwOnError?: boolean;
43+
},
3944
) => Array<VendoredTanstackRouterRouteMatch>;
4045
subscribe(
4146
eventType: 'onResolved' | 'onBeforeNavigate',
@@ -46,7 +51,7 @@ export interface VendoredTanstackRouter {
4651
): () => void;
4752
}
4853

49-
export interface VendoredTanstackRouterLocation {
54+
interface VendoredTanstackRouterLocation {
5055
pathname: string;
5156
// eslint-disable-next-line @typescript-eslint/ban-types
5257
search: {};

0 commit comments

Comments
 (0)