@sentry/react 10.6.0 → 10.8.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/build/cjs/{reactrouterv6-compat-utils.js → reactrouter-compat-utils/instrumentation.js} +271 -310
- package/build/cjs/reactrouter-compat-utils/instrumentation.js.map +1 -0
- package/build/cjs/reactrouter-compat-utils/lazy-routes.js +80 -0
- package/build/cjs/reactrouter-compat-utils/lazy-routes.js.map +1 -0
- package/build/cjs/reactrouter-compat-utils/utils.js +297 -0
- package/build/cjs/reactrouter-compat-utils/utils.js.map +1 -0
- package/build/cjs/reactrouterv6.js +7 -6
- package/build/cjs/reactrouterv6.js.map +1 -1
- package/build/cjs/reactrouterv7.js +7 -6
- package/build/cjs/reactrouterv7.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/{reactrouterv6-compat-utils.js → reactrouter-compat-utils/instrumentation.js} +265 -307
- package/build/esm/reactrouter-compat-utils/instrumentation.js.map +1 -0
- package/build/esm/reactrouter-compat-utils/lazy-routes.js +76 -0
- package/build/esm/reactrouter-compat-utils/lazy-routes.js.map +1 -0
- package/build/esm/reactrouter-compat-utils/utils.js +286 -0
- package/build/esm/reactrouter-compat-utils/utils.js.map +1 -0
- package/build/esm/reactrouterv6.js +2 -1
- package/build/esm/reactrouterv6.js.map +1 -1
- package/build/esm/reactrouterv7.js +2 -1
- package/build/esm/reactrouterv7.js.map +1 -1
- package/build/types/reactrouter-compat-utils/index.d.ts +5 -0
- package/build/types/reactrouter-compat-utils/index.d.ts.map +1 -0
- package/build/types/{reactrouterv6-compat-utils.d.ts → reactrouter-compat-utils/instrumentation.d.ts} +21 -7
- package/build/types/reactrouter-compat-utils/instrumentation.d.ts.map +1 -0
- package/build/types/reactrouter-compat-utils/lazy-routes.d.ts +14 -0
- package/build/types/reactrouter-compat-utils/lazy-routes.d.ts.map +1 -0
- package/build/types/reactrouter-compat-utils/utils.d.ts +50 -0
- package/build/types/reactrouter-compat-utils/utils.d.ts.map +1 -0
- package/build/types/reactrouterv6.d.ts +1 -1
- package/build/types/reactrouterv6.d.ts.map +1 -1
- package/build/types/reactrouterv7.d.ts +1 -1
- package/build/types/reactrouterv7.d.ts.map +1 -1
- package/build/types-ts3.8/reactrouter-compat-utils/index.d.ts +5 -0
- package/build/types-ts3.8/{reactrouterv6-compat-utils.d.ts → reactrouter-compat-utils/instrumentation.d.ts} +21 -7
- package/build/types-ts3.8/reactrouter-compat-utils/lazy-routes.d.ts +14 -0
- package/build/types-ts3.8/reactrouter-compat-utils/utils.d.ts +56 -0
- package/build/types-ts3.8/reactrouterv6.d.ts +1 -1
- package/build/types-ts3.8/reactrouterv7.d.ts +1 -1
- package/package.json +3 -3
- package/build/cjs/reactrouterv6-compat-utils.js.map +0 -1
- package/build/esm/reactrouterv6-compat-utils.js.map +0 -1
- package/build/types/reactrouterv6-compat-utils.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentation.js","sources":["../../../src/reactrouter-compat-utils/instrumentation.tsx"],"sourcesContent":["/* eslint-disable max-lines */\n// Inspired from Donnie McNeal's solution:\n// https://gist.github.com/wontondon/e8c4bdf2888875e4c755712e99279536\n\nimport {\n browserTracingIntegration,\n startBrowserTracingNavigationSpan,\n startBrowserTracingPageLoadSpan,\n WINDOW,\n} from '@sentry/browser';\nimport type { Client, Integration, Span, TransactionSource } from '@sentry/core';\nimport {\n addNonEnumerableProperty,\n debug,\n getActiveSpan,\n getClient,\n getCurrentScope,\n getRootSpan,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n spanToJSON,\n} from '@sentry/core';\nimport * as React from 'react';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { hoistNonReactStatics } from '../hoist-non-react-statics';\nimport type {\n Action,\n AgnosticDataRouteMatch,\n CreateRouterFunction,\n CreateRoutesFromChildren,\n Location,\n MatchRoutes,\n RouteMatch,\n RouteObject,\n Router,\n RouterState,\n UseEffect,\n UseLocation,\n UseNavigationType,\n UseRoutes,\n} from '../types';\nimport { checkRouteForAsyncHandler } from './lazy-routes';\nimport {\n getNormalizedName,\n initializeRouterUtils,\n isLikelyLazyRouteContext,\n locationIsInsideDescendantRoute,\n prefixWithSlash,\n rebuildRoutePathFromAllRoutes,\n resolveRouteNameAndSource,\n} from './utils';\n\nlet _useEffect: UseEffect;\nlet _useLocation: UseLocation;\nlet _useNavigationType: UseNavigationType;\nlet _createRoutesFromChildren: CreateRoutesFromChildren;\nlet _matchRoutes: MatchRoutes;\nlet _enableAsyncRouteHandlers: boolean = false;\n\nconst CLIENTS_WITH_INSTRUMENT_NAVIGATION = new WeakSet<Client>();\n\n/**\n * Adds resolved routes as children to the parent route.\n * Prevents duplicate routes by checking if they already exist.\n */\nexport function addResolvedRoutesToParent(resolvedRoutes: RouteObject[], parentRoute: RouteObject): void {\n const existingChildren = parentRoute.children || [];\n\n const newRoutes = resolvedRoutes.filter(\n newRoute =>\n !existingChildren.some(\n existing =>\n existing === newRoute ||\n (newRoute.path && existing.path === newRoute.path) ||\n (newRoute.id && existing.id === newRoute.id),\n ),\n );\n\n if (newRoutes.length > 0) {\n parentRoute.children = [...existingChildren, ...newRoutes];\n }\n}\n\nexport interface ReactRouterOptions {\n useEffect: UseEffect;\n useLocation: UseLocation;\n useNavigationType: UseNavigationType;\n createRoutesFromChildren: CreateRoutesFromChildren;\n matchRoutes: MatchRoutes;\n /**\n * Whether to strip the basename from the pathname when creating transactions.\n *\n * This is useful for applications that use a basename in their routing setup.\n * @default false\n */\n stripBasename?: boolean;\n /**\n * Enables support for async route handlers.\n *\n * This allows Sentry to track and instrument routes dynamically resolved from async handlers.\n * @default false\n */\n enableAsyncRouteHandlers?: boolean;\n}\n\ntype V6CompatibleVersion = '6' | '7';\n\n// Keeping as a global variable for cross-usage in multiple functions\nconst allRoutes = new Set<RouteObject>();\n\n/**\n * Processes resolved routes by adding them to allRoutes and checking for nested async handlers.\n */\nexport function processResolvedRoutes(\n resolvedRoutes: RouteObject[],\n parentRoute?: RouteObject,\n currentLocation: Location | null = null,\n): void {\n resolvedRoutes.forEach(child => {\n allRoutes.add(child);\n // Only check for async handlers if the feature is enabled\n if (_enableAsyncRouteHandlers) {\n checkRouteForAsyncHandler(child, processResolvedRoutes);\n }\n });\n\n if (parentRoute) {\n // If a parent route is provided, add the resolved routes as children to the parent route\n addResolvedRoutesToParent(resolvedRoutes, parentRoute);\n }\n\n // After processing lazy routes, check if we need to update an active transaction\n const activeRootSpan = getActiveRootSpan();\n if (activeRootSpan) {\n const spanOp = spanToJSON(activeRootSpan).op;\n\n // Try to use the provided location first, then fall back to global window location if needed\n let location = currentLocation;\n if (!location) {\n if (typeof WINDOW !== 'undefined') {\n const globalLocation = WINDOW.location;\n if (globalLocation) {\n location = { pathname: globalLocation.pathname };\n }\n }\n }\n\n if (location) {\n if (spanOp === 'pageload') {\n // Re-run the pageload transaction update with the newly loaded routes\n updatePageloadTransaction({\n activeRootSpan,\n location: { pathname: location.pathname },\n routes: Array.from(allRoutes),\n allRoutes: Array.from(allRoutes),\n });\n } else if (spanOp === 'navigation') {\n // For navigation spans, update the name with the newly loaded routes\n updateNavigationSpan(activeRootSpan, location, Array.from(allRoutes), false, _matchRoutes);\n }\n }\n }\n}\n\n/**\n * Updates a navigation span with the correct route name after lazy routes have been loaded.\n */\nexport function updateNavigationSpan(\n activeRootSpan: Span,\n location: Location,\n allRoutes: RouteObject[],\n forceUpdate = false,\n matchRoutes: MatchRoutes,\n): void {\n // Check if this span has already been named to avoid multiple updates\n // But allow updates if this is a forced update (e.g., when lazy routes are loaded)\n const hasBeenNamed =\n !forceUpdate &&\n (\n activeRootSpan as {\n __sentry_navigation_name_set__?: boolean;\n }\n )?.__sentry_navigation_name_set__;\n\n if (!hasBeenNamed) {\n // Get fresh branches for the current location with all loaded routes\n const currentBranches = matchRoutes(allRoutes, location);\n const [name, source] = resolveRouteNameAndSource(\n location,\n allRoutes,\n allRoutes,\n (currentBranches as RouteMatch[]) || [],\n '',\n );\n\n // Only update if we have a valid name and the span hasn't finished\n const spanJson = spanToJSON(activeRootSpan);\n if (name && !spanJson.timestamp) {\n activeRootSpan.updateName(name);\n activeRootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, source);\n\n // Mark this span as having its name set to prevent future updates\n addNonEnumerableProperty(\n activeRootSpan as { __sentry_navigation_name_set__?: boolean },\n '__sentry_navigation_name_set__',\n true,\n );\n }\n }\n}\n\n/**\n * Creates a wrapCreateBrowserRouter function that can be used with all React Router v6 compatible versions.\n */\nexport function createV6CompatibleWrapCreateBrowserRouter<\n TState extends RouterState = RouterState,\n TRouter extends Router<TState> = Router<TState>,\n>(\n createRouterFunction: CreateRouterFunction<TState, TRouter>,\n version: V6CompatibleVersion,\n): CreateRouterFunction<TState, TRouter> {\n if (!_useEffect || !_useLocation || !_useNavigationType || !_matchRoutes) {\n DEBUG_BUILD &&\n debug.warn(\n `reactRouterV${version}Instrumentation was unable to wrap the \\`createRouter\\` function because of one or more missing parameters.`,\n );\n\n return createRouterFunction;\n }\n\n return function (routes: RouteObject[], opts?: Record<string, unknown> & { basename?: string }): TRouter {\n addRoutesToAllRoutes(routes);\n\n // Check for async handlers that might contain sub-route declarations (only if enabled)\n if (_enableAsyncRouteHandlers) {\n for (const route of routes) {\n checkRouteForAsyncHandler(route, processResolvedRoutes);\n }\n }\n\n // Wrap patchRoutesOnNavigation to detect when lazy routes are loaded\n const wrappedOpts = wrapPatchRoutesOnNavigation(opts);\n\n const router = createRouterFunction(routes, wrappedOpts);\n const basename = opts?.basename;\n\n const activeRootSpan = getActiveRootSpan();\n\n // The initial load ends when `createBrowserRouter` is called.\n // This is the earliest convenient time to update the transaction name.\n // Callbacks to `router.subscribe` are not called for the initial load.\n if (router.state.historyAction === 'POP' && activeRootSpan) {\n updatePageloadTransaction({\n activeRootSpan,\n location: router.state.location,\n routes,\n basename,\n allRoutes: Array.from(allRoutes),\n });\n }\n\n router.subscribe((state: RouterState) => {\n if (state.historyAction === 'PUSH' || state.historyAction === 'POP') {\n // Wait for the next render if loading an unsettled route\n if (state.navigation.state !== 'idle') {\n requestAnimationFrame(() => {\n handleNavigation({\n location: state.location,\n routes,\n navigationType: state.historyAction,\n version,\n basename,\n allRoutes: Array.from(allRoutes),\n });\n });\n } else {\n handleNavigation({\n location: state.location,\n routes,\n navigationType: state.historyAction,\n version,\n basename,\n allRoutes: Array.from(allRoutes),\n });\n }\n }\n });\n\n return router;\n };\n}\n\n/**\n * Creates a wrapCreateMemoryRouter function that can be used with all React Router v6 compatible versions.\n */\nexport function createV6CompatibleWrapCreateMemoryRouter<\n TState extends RouterState = RouterState,\n TRouter extends Router<TState> = Router<TState>,\n>(\n createRouterFunction: CreateRouterFunction<TState, TRouter>,\n version: V6CompatibleVersion,\n): CreateRouterFunction<TState, TRouter> {\n if (!_useEffect || !_useLocation || !_useNavigationType || !_matchRoutes) {\n DEBUG_BUILD &&\n debug.warn(\n `reactRouterV${version}Instrumentation was unable to wrap the \\`createMemoryRouter\\` function because of one or more missing parameters.`,\n );\n\n return createRouterFunction;\n }\n\n return function (\n routes: RouteObject[],\n opts?: Record<string, unknown> & {\n basename?: string;\n initialEntries?: (string | { pathname: string })[];\n initialIndex?: number;\n },\n ): TRouter {\n addRoutesToAllRoutes(routes);\n\n // Check for async handlers that might contain sub-route declarations (only if enabled)\n if (_enableAsyncRouteHandlers) {\n for (const route of routes) {\n checkRouteForAsyncHandler(route, processResolvedRoutes);\n }\n }\n\n // Wrap patchRoutesOnNavigation to detect when lazy routes are loaded\n const wrappedOpts = wrapPatchRoutesOnNavigation(opts, true);\n\n const router = createRouterFunction(routes, wrappedOpts);\n const basename = opts?.basename;\n\n const activeRootSpan = getActiveRootSpan();\n let initialEntry = undefined;\n\n const initialEntries = opts?.initialEntries;\n const initialIndex = opts?.initialIndex;\n\n const hasOnlyOneInitialEntry = initialEntries && initialEntries.length === 1;\n const hasIndexedEntry = initialIndex !== undefined && initialEntries && initialEntries[initialIndex];\n\n initialEntry = hasOnlyOneInitialEntry\n ? initialEntries[0]\n : hasIndexedEntry\n ? initialEntries[initialIndex]\n : undefined;\n\n const location = initialEntry\n ? typeof initialEntry === 'string'\n ? { pathname: initialEntry }\n : initialEntry\n : router.state.location;\n\n if (router.state.historyAction === 'POP' && activeRootSpan) {\n updatePageloadTransaction({\n activeRootSpan,\n location,\n routes,\n basename,\n allRoutes: Array.from(allRoutes),\n });\n }\n\n router.subscribe((state: RouterState) => {\n const location = state.location;\n if (state.historyAction === 'PUSH' || state.historyAction === 'POP') {\n handleNavigation({\n location,\n routes,\n navigationType: state.historyAction,\n version,\n basename,\n allRoutes: Array.from(allRoutes),\n });\n }\n });\n\n return router;\n };\n}\n\n/**\n * Creates a browser tracing integration that can be used with all React Router v6 compatible versions.\n */\nexport function createReactRouterV6CompatibleTracingIntegration(\n options: Parameters<typeof browserTracingIntegration>[0] & ReactRouterOptions,\n version: V6CompatibleVersion,\n): Integration {\n const integration = browserTracingIntegration({\n ...options,\n instrumentPageLoad: false,\n instrumentNavigation: false,\n });\n\n const {\n useEffect,\n useLocation,\n useNavigationType,\n createRoutesFromChildren,\n matchRoutes,\n stripBasename,\n enableAsyncRouteHandlers = false,\n instrumentPageLoad = true,\n instrumentNavigation = true,\n } = options;\n\n return {\n ...integration,\n setup(client) {\n integration.setup(client);\n\n _useEffect = useEffect;\n _useLocation = useLocation;\n _useNavigationType = useNavigationType;\n _matchRoutes = matchRoutes;\n _createRoutesFromChildren = createRoutesFromChildren;\n _enableAsyncRouteHandlers = enableAsyncRouteHandlers;\n\n // Initialize the router utils with the required dependencies\n initializeRouterUtils(matchRoutes, stripBasename || false);\n },\n afterAllSetup(client) {\n integration.afterAllSetup(client);\n\n const initPathName = WINDOW.location?.pathname;\n if (instrumentPageLoad && initPathName) {\n startBrowserTracingPageLoadSpan(client, {\n name: initPathName,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'pageload',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: `auto.pageload.react.reactrouter_v${version}`,\n },\n });\n }\n\n if (instrumentNavigation) {\n CLIENTS_WITH_INSTRUMENT_NAVIGATION.add(client);\n }\n },\n };\n}\n\nexport function createV6CompatibleWrapUseRoutes(origUseRoutes: UseRoutes, version: V6CompatibleVersion): UseRoutes {\n if (!_useEffect || !_useLocation || !_useNavigationType || !_matchRoutes) {\n DEBUG_BUILD &&\n debug.warn(\n 'reactRouterV6Instrumentation was unable to wrap `useRoutes` because of one or more missing parameters.',\n );\n\n return origUseRoutes;\n }\n\n const SentryRoutes: React.FC<{\n children?: React.ReactNode;\n routes: RouteObject[];\n locationArg?: Partial<Location> | string;\n }> = (props: { children?: React.ReactNode; routes: RouteObject[]; locationArg?: Partial<Location> | string }) => {\n const isMountRenderPass = React.useRef(true);\n const { routes, locationArg } = props;\n\n const Routes = origUseRoutes(routes, locationArg);\n\n const location = _useLocation();\n const navigationType = _useNavigationType();\n\n // A value with stable identity to either pick `locationArg` if available or `location` if not\n const stableLocationParam =\n typeof locationArg === 'string' || locationArg?.pathname ? (locationArg as { pathname: string }) : location;\n\n _useEffect(() => {\n const normalizedLocation =\n typeof stableLocationParam === 'string' ? { pathname: stableLocationParam } : stableLocationParam;\n\n if (isMountRenderPass.current) {\n addRoutesToAllRoutes(routes);\n\n updatePageloadTransaction({\n activeRootSpan: getActiveRootSpan(),\n location: normalizedLocation,\n routes,\n allRoutes: Array.from(allRoutes),\n });\n isMountRenderPass.current = false;\n } else {\n handleNavigation({\n location: normalizedLocation,\n routes,\n navigationType,\n version,\n allRoutes: Array.from(allRoutes),\n });\n }\n }, [navigationType, stableLocationParam]);\n\n return Routes;\n };\n\n // eslint-disable-next-line react/display-name\n return (routes: RouteObject[], locationArg?: Partial<Location> | string): React.ReactElement | null => {\n return <SentryRoutes routes={routes} locationArg={locationArg} />;\n };\n}\n\nfunction wrapPatchRoutesOnNavigation(\n opts: Record<string, unknown> | undefined,\n isMemoryRouter = false,\n): Record<string, unknown> {\n if (!opts || !('patchRoutesOnNavigation' in opts) || typeof opts.patchRoutesOnNavigation !== 'function') {\n return opts || {};\n }\n\n const originalPatchRoutes = opts.patchRoutesOnNavigation;\n return {\n ...opts,\n patchRoutesOnNavigation: async (args: unknown) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n const targetPath = (args as any)?.path;\n\n // For browser router, wrap the patch function to update span during patching\n if (!isMemoryRouter) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n const originalPatch = (args as any)?.patch;\n if (originalPatch) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n (args as any).patch = (routeId: string, children: RouteObject[]) => {\n addRoutesToAllRoutes(children);\n const activeRootSpan = getActiveRootSpan();\n if (activeRootSpan && (spanToJSON(activeRootSpan) as { op?: string }).op === 'navigation') {\n updateNavigationSpan(\n activeRootSpan,\n {\n pathname: targetPath,\n search: '',\n hash: '',\n state: null,\n key: 'default',\n },\n Array.from(allRoutes),\n true, // forceUpdate = true since we're loading lazy routes\n _matchRoutes,\n );\n }\n return originalPatch(routeId, children);\n };\n }\n }\n\n const result = await originalPatchRoutes(args);\n\n // Update navigation span after routes are patched\n const activeRootSpan = getActiveRootSpan();\n if (activeRootSpan && (spanToJSON(activeRootSpan) as { op?: string }).op === 'navigation') {\n // For memory routers, we should not access window.location; use targetPath only\n const pathname = isMemoryRouter ? targetPath : targetPath || WINDOW.location?.pathname;\n if (pathname) {\n updateNavigationSpan(\n activeRootSpan,\n {\n pathname,\n search: '',\n hash: '',\n state: null,\n key: 'default',\n },\n Array.from(allRoutes),\n false, // forceUpdate = false since this is after lazy routes are loaded\n _matchRoutes,\n );\n }\n }\n\n return result;\n },\n };\n}\n\nexport function handleNavigation(opts: {\n location: Location;\n routes: RouteObject[];\n navigationType: Action;\n version: V6CompatibleVersion;\n matches?: AgnosticDataRouteMatch;\n basename?: string;\n allRoutes?: RouteObject[];\n}): void {\n const { location, routes, navigationType, version, matches, basename, allRoutes } = opts;\n const branches = Array.isArray(matches) ? matches : _matchRoutes(routes, location, basename);\n\n const client = getClient();\n if (!client || !CLIENTS_WITH_INSTRUMENT_NAVIGATION.has(client)) {\n return;\n }\n\n if ((navigationType === 'PUSH' || navigationType === 'POP') && branches) {\n const [name, source] = resolveRouteNameAndSource(\n location,\n routes,\n allRoutes || routes,\n branches as RouteMatch[],\n basename,\n );\n\n // Check if this might be a lazy route context\n const isLazyRouteContext = isLikelyLazyRouteContext(allRoutes || routes, location);\n\n const activeSpan = getActiveSpan();\n const spanJson = activeSpan && spanToJSON(activeSpan);\n const isAlreadyInNavigationSpan = spanJson?.op === 'navigation';\n\n // Cross usage can result in multiple navigation spans being created without this check\n if (isAlreadyInNavigationSpan && activeSpan && spanJson) {\n handleExistingNavigationSpan(activeSpan, spanJson, name, source, isLazyRouteContext);\n } else {\n createNewNavigationSpan(client, name, source, version, isLazyRouteContext);\n }\n }\n}\n\nfunction addRoutesToAllRoutes(routes: RouteObject[]): void {\n routes.forEach(route => {\n const extractedChildRoutes = getChildRoutesRecursively(route);\n\n extractedChildRoutes.forEach(r => {\n allRoutes.add(r);\n });\n });\n}\n\nfunction getChildRoutesRecursively(route: RouteObject, allRoutes: Set<RouteObject> = new Set()): Set<RouteObject> {\n if (!allRoutes.has(route)) {\n allRoutes.add(route);\n\n if (route.children && !route.index) {\n route.children.forEach(child => {\n const childRoutes = getChildRoutesRecursively(child, allRoutes);\n\n childRoutes.forEach(r => {\n allRoutes.add(r);\n });\n });\n }\n }\n\n return allRoutes;\n}\n\nfunction updatePageloadTransaction({\n activeRootSpan,\n location,\n routes,\n matches,\n basename,\n allRoutes,\n}: {\n activeRootSpan: Span | undefined;\n location: Location;\n routes: RouteObject[];\n matches?: AgnosticDataRouteMatch;\n basename?: string;\n allRoutes?: RouteObject[];\n}): void {\n const branches = Array.isArray(matches)\n ? matches\n : (_matchRoutes(allRoutes || routes, location, basename) as unknown as RouteMatch[]);\n\n if (branches) {\n let name,\n source: TransactionSource = 'url';\n\n const isInDescendantRoute = locationIsInsideDescendantRoute(location, allRoutes || routes);\n\n if (isInDescendantRoute) {\n name = prefixWithSlash(rebuildRoutePathFromAllRoutes(allRoutes || routes, location));\n source = 'route';\n }\n\n if (!isInDescendantRoute || !name) {\n [name, source] = getNormalizedName(routes, location, branches, basename);\n }\n\n getCurrentScope().setTransactionName(name || '/');\n\n if (activeRootSpan) {\n activeRootSpan.updateName(name);\n activeRootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, source);\n }\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function createV6CompatibleWithSentryReactRouterRouting<P extends Record<string, any>, R extends React.FC<P>>(\n Routes: R,\n version: V6CompatibleVersion,\n): R {\n if (!_useEffect || !_useLocation || !_useNavigationType || !_createRoutesFromChildren || !_matchRoutes) {\n DEBUG_BUILD &&\n debug.warn(`reactRouterV6Instrumentation was unable to wrap Routes because of one or more missing parameters.\n useEffect: ${_useEffect}. useLocation: ${_useLocation}. useNavigationType: ${_useNavigationType}.\n createRoutesFromChildren: ${_createRoutesFromChildren}. matchRoutes: ${_matchRoutes}.`);\n\n return Routes;\n }\n\n const SentryRoutes: React.FC<P> = (props: P) => {\n const isMountRenderPass = React.useRef(true);\n\n const location = _useLocation();\n const navigationType = _useNavigationType();\n\n _useEffect(\n () => {\n const routes = _createRoutesFromChildren(props.children) as RouteObject[];\n\n if (isMountRenderPass.current) {\n addRoutesToAllRoutes(routes);\n\n updatePageloadTransaction({\n activeRootSpan: getActiveRootSpan(),\n location,\n routes,\n allRoutes: Array.from(allRoutes),\n });\n isMountRenderPass.current = false;\n } else {\n handleNavigation({\n location,\n routes,\n navigationType,\n version,\n allRoutes: Array.from(allRoutes),\n });\n }\n },\n // `props.children` is purposely not included in the dependency array, because we do not want to re-run this effect\n // when the children change. We only want to start transactions when the location or navigation type change.\n [location, navigationType],\n );\n\n // @ts-expect-error Setting more specific React Component typing for `R` generic above\n // will break advanced type inference done by react router params\n return <Routes {...props} />;\n };\n\n hoistNonReactStatics(SentryRoutes, Routes);\n\n // @ts-expect-error Setting more specific React Component typing for `R` generic above\n // will break advanced type inference done by react router params\n return SentryRoutes;\n}\n\nfunction getActiveRootSpan(): Span | undefined {\n const span = getActiveSpan();\n const rootSpan = span ? getRootSpan(span) : undefined;\n\n if (!rootSpan) {\n return undefined;\n }\n\n const op = spanToJSON(rootSpan).op;\n\n // Only use this root span if it is a pageload or navigation span\n return op === 'navigation' || op === 'pageload' ? rootSpan : undefined;\n}\n\n/**\n * Handles updating an existing navigation span\n */\nexport function handleExistingNavigationSpan(\n activeSpan: Span,\n spanJson: ReturnType<typeof spanToJSON>,\n name: string,\n source: TransactionSource,\n isLikelyLazyRoute: boolean,\n): void {\n // Check if we've already set the name for this span using a custom property\n const hasBeenNamed = (\n activeSpan as {\n __sentry_navigation_name_set__?: boolean;\n }\n )?.__sentry_navigation_name_set__;\n\n if (!hasBeenNamed) {\n // This is the first time we're setting the name for this span\n if (!spanJson.timestamp) {\n activeSpan?.updateName(name);\n }\n\n // For lazy routes, don't mark as named yet so it can be updated later\n if (!isLikelyLazyRoute) {\n addNonEnumerableProperty(\n activeSpan as { __sentry_navigation_name_set__?: boolean },\n '__sentry_navigation_name_set__',\n true,\n );\n }\n }\n\n // Always set the source attribute to keep it consistent with the current route\n activeSpan?.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, source);\n}\n\n/**\n * Creates a new navigation span\n */\nexport function createNewNavigationSpan(\n client: Client,\n name: string,\n source: TransactionSource,\n version: string,\n isLikelyLazyRoute: boolean,\n): void {\n const newSpan = startBrowserTracingNavigationSpan(client, {\n name,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: `auto.navigation.react.reactrouter_v${version}`,\n },\n });\n\n // For lazy routes, don't mark as named yet so it can be updated later when the route loads\n if (!isLikelyLazyRoute && newSpan) {\n addNonEnumerableProperty(\n newSpan as { __sentry_navigation_name_set__?: boolean },\n '__sentry_navigation_name_set__',\n true,\n );\n }\n}\n"],"names":["checkRouteForAsyncHandler","spanToJSON","WINDOW","resolveRouteNameAndSource","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","addNonEnumerableProperty","DEBUG_BUILD","debug","browserTracingIntegration","initializeRouterUtils","startBrowserTracingPageLoadSpan","SEMANTIC_ATTRIBUTE_SENTRY_OP","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","getClient","isLikelyLazyRouteContext","getActiveSpan","locationIsInsideDescendantRoute","prefixWithSlash","rebuildRoutePathFromAllRoutes","getNormalizedName","getCurrentScope","hoistNonReactStatics","getRootSpan","startBrowserTracingNavigationSpan"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;;;AAmDA,IAAI,UAAU;AACd,IAAI,YAAY;AAChB,IAAI,kBAAkB;AACtB,IAAI,yBAAyB;AAC7B,IAAI,YAAY;AAChB,IAAI,yBAAyB,GAAY,KAAK;;AAE9C,MAAM,kCAAA,GAAqC,IAAI,OAAO,EAAU;;AAEhE;AACA;AACA;AACA;AACO,SAAS,yBAAyB,CAAC,cAAc,EAAiB,WAAW,EAAqB;AACzG,EAAE,MAAM,mBAAmB,WAAW,CAAC,QAAA,IAAY,EAAE;;AAErD,EAAE,MAAM,SAAA,GAAY,cAAc,CAAC,MAAM;AACzC,IAAI,QAAA;AACJ,MAAM,CAAC,gBAAgB,CAAC,IAAI;AAC5B,QAAQ,QAAA;AACR,UAAU,QAAA,KAAa,QAAA;AACvB,WAAW,QAAQ,CAAC,IAAA,IAAQ,QAAQ,CAAC,IAAA,KAAS,QAAQ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AA;AACA,EAAA,iBAAA;AACA,EAAA;AACA,EAAA,MAAA,OAAA,GAAAmB,yCAAA,CAAA,MAAA,EAAA;AACA,IAAA,IAAA;AACA,IAAA,UAAA,EAAA;AACA,MAAA,CAAAnB,qCAAA,GAAA,MAAA;AACA,MAAA,CAAAO,iCAAA,GAAA,YAAA;AACA,MAAA,CAAAC,qCAAA,GAAA,CAAA,mCAAA,EAAA,OAAA,CAAA,CAAA;AACA,KAAA;AACA,GAAA,CAAA;;AAEA;AACA,EAAA,IAAA,CAAA,iBAAA,IAAA,OAAA,EAAA;AACA,IAAAP,6BAAA;AACA,MAAA,OAAA;AACA,MAAA,gCAAA;AACA,MAAA,IAAA;AACA,KAAA;AACA;AACA;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const core = require('@sentry/core');
|
|
4
|
+
const debugBuild = require('../debug-build.js');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Creates a proxy wrapper for an async handler function.
|
|
8
|
+
*/
|
|
9
|
+
function createAsyncHandlerProxy(
|
|
10
|
+
originalFunction,
|
|
11
|
+
route,
|
|
12
|
+
handlerKey,
|
|
13
|
+
processResolvedRoutes,
|
|
14
|
+
) {
|
|
15
|
+
const proxy = new Proxy(originalFunction, {
|
|
16
|
+
apply(target, thisArg, argArray) {
|
|
17
|
+
const result = target.apply(thisArg, argArray);
|
|
18
|
+
handleAsyncHandlerResult(result, route, handlerKey, processResolvedRoutes);
|
|
19
|
+
return result;
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
core.addNonEnumerableProperty(proxy, '__sentry_proxied__', true);
|
|
24
|
+
|
|
25
|
+
return proxy;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Handles the result of an async handler function call.
|
|
30
|
+
*/
|
|
31
|
+
function handleAsyncHandlerResult(
|
|
32
|
+
result,
|
|
33
|
+
route,
|
|
34
|
+
handlerKey,
|
|
35
|
+
processResolvedRoutes,
|
|
36
|
+
) {
|
|
37
|
+
if (core.isThenable(result)) {
|
|
38
|
+
(result )
|
|
39
|
+
.then((resolvedRoutes) => {
|
|
40
|
+
if (Array.isArray(resolvedRoutes)) {
|
|
41
|
+
processResolvedRoutes(resolvedRoutes, route);
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
.catch((e) => {
|
|
45
|
+
debugBuild.DEBUG_BUILD && core.debug.warn(`Error resolving async handler '${handlerKey}' for route`, route, e);
|
|
46
|
+
});
|
|
47
|
+
} else if (Array.isArray(result)) {
|
|
48
|
+
processResolvedRoutes(result, route);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Recursively checks a route for async handlers and sets up Proxies to add discovered child routes to allRoutes when called.
|
|
54
|
+
*/
|
|
55
|
+
function checkRouteForAsyncHandler(
|
|
56
|
+
route,
|
|
57
|
+
processResolvedRoutes,
|
|
58
|
+
) {
|
|
59
|
+
// Set up proxies for any functions in the route's handle
|
|
60
|
+
if (route.handle && typeof route.handle === 'object') {
|
|
61
|
+
for (const key of Object.keys(route.handle)) {
|
|
62
|
+
const maybeFn = route.handle[key];
|
|
63
|
+
if (typeof maybeFn === 'function' && !(maybeFn ).__sentry_proxied__) {
|
|
64
|
+
route.handle[key] = createAsyncHandlerProxy(maybeFn, route, key, processResolvedRoutes);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Recursively check child routes
|
|
70
|
+
if (Array.isArray(route.children)) {
|
|
71
|
+
for (const child of route.children) {
|
|
72
|
+
checkRouteForAsyncHandler(child, processResolvedRoutes);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
exports.checkRouteForAsyncHandler = checkRouteForAsyncHandler;
|
|
78
|
+
exports.createAsyncHandlerProxy = createAsyncHandlerProxy;
|
|
79
|
+
exports.handleAsyncHandlerResult = handleAsyncHandlerResult;
|
|
80
|
+
//# sourceMappingURL=lazy-routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy-routes.js","sources":["../../../src/reactrouter-compat-utils/lazy-routes.tsx"],"sourcesContent":["import { addNonEnumerableProperty, debug, isThenable } from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { Location, RouteObject } from '../types';\n\n/**\n * Creates a proxy wrapper for an async handler function.\n */\nexport function createAsyncHandlerProxy(\n originalFunction: (...args: unknown[]) => unknown,\n route: RouteObject,\n handlerKey: string,\n processResolvedRoutes: (resolvedRoutes: RouteObject[], parentRoute?: RouteObject, currentLocation?: Location) => void,\n): (...args: unknown[]) => unknown {\n const proxy = new Proxy(originalFunction, {\n apply(target: (...args: unknown[]) => unknown, thisArg, argArray) {\n const result = target.apply(thisArg, argArray);\n handleAsyncHandlerResult(result, route, handlerKey, processResolvedRoutes);\n return result;\n },\n });\n\n addNonEnumerableProperty(proxy, '__sentry_proxied__', true);\n\n return proxy;\n}\n\n/**\n * Handles the result of an async handler function call.\n */\nexport function handleAsyncHandlerResult(\n result: unknown,\n route: RouteObject,\n handlerKey: string,\n processResolvedRoutes: (resolvedRoutes: RouteObject[], parentRoute?: RouteObject, currentLocation?: Location) => void,\n): void {\n if (isThenable(result)) {\n (result as Promise<unknown>)\n .then((resolvedRoutes: unknown) => {\n if (Array.isArray(resolvedRoutes)) {\n processResolvedRoutes(resolvedRoutes, route);\n }\n })\n .catch((e: unknown) => {\n DEBUG_BUILD && debug.warn(`Error resolving async handler '${handlerKey}' for route`, route, e);\n });\n } else if (Array.isArray(result)) {\n processResolvedRoutes(result, route);\n }\n}\n\n/**\n * Recursively checks a route for async handlers and sets up Proxies to add discovered child routes to allRoutes when called.\n */\nexport function checkRouteForAsyncHandler(\n route: RouteObject,\n processResolvedRoutes: (resolvedRoutes: RouteObject[], parentRoute?: RouteObject, currentLocation?: Location) => void,\n): void {\n // Set up proxies for any functions in the route's handle\n if (route.handle && typeof route.handle === 'object') {\n for (const key of Object.keys(route.handle)) {\n const maybeFn = route.handle[key];\n if (typeof maybeFn === 'function' && !(maybeFn as { __sentry_proxied__?: boolean }).__sentry_proxied__) {\n route.handle[key] = createAsyncHandlerProxy(maybeFn, route, key, processResolvedRoutes);\n }\n }\n }\n\n // Recursively check child routes\n if (Array.isArray(route.children)) {\n for (const child of route.children) {\n checkRouteForAsyncHandler(child, processResolvedRoutes);\n }\n }\n}\n"],"names":["addNonEnumerableProperty","isThenable","DEBUG_BUILD","debug"],"mappings":";;;;;AAIA;AACA;AACA;AACO,SAAS,uBAAuB;AACvC,EAAE,gBAAgB;AAClB,EAAE,KAAK;AACP,EAAE,UAAU;AACZ,EAAE,qBAAqB;AACvB,EAAmC;AACnC,EAAE,MAAM,KAAA,GAAQ,IAAI,KAAK,CAAC,gBAAgB,EAAE;AAC5C,IAAI,KAAK,CAAC,MAAM,EAAmC,OAAO,EAAE,QAAQ,EAAE;AACtE,MAAM,MAAM,MAAA,GAAS,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC;AACpD,MAAM,wBAAwB,CAAC,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,qBAAqB,CAAC;AAChF,MAAM,OAAO,MAAM;AACnB,KAAK;AACL,GAAG,CAAC;;AAEJ,EAAEA,6BAAwB,CAAC,KAAK,EAAE,oBAAoB,EAAE,IAAI,CAAC;;AAE7D,EAAE,OAAO,KAAK;AACd;;AAEA;AACA;AACA;AACO,SAAS,wBAAwB;AACxC,EAAE,MAAM;AACR,EAAE,KAAK;AACP,EAAE,UAAU;AACZ,EAAE,qBAAqB;AACvB,EAAQ;AACR,EAAE,IAAIC,eAAU,CAAC,MAAM,CAAC,EAAE;AAC1B,IAAI,CAAC,MAAA;AACL,OAAO,IAAI,CAAC,CAAC,cAAc,KAAc;AACzC,QAAQ,IAAI,KA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ports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
// Global variables that these utilities depend on
|
|
4
|
+
let _matchRoutes;
|
|
5
|
+
let _stripBasename = false;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Initialize function to set dependencies that the router utilities need.
|
|
9
|
+
* Must be called before using any of the exported utility functions.
|
|
10
|
+
*/
|
|
11
|
+
function initializeRouterUtils(matchRoutes, stripBasename = false) {
|
|
12
|
+
_matchRoutes = matchRoutes;
|
|
13
|
+
_stripBasename = stripBasename;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Checks if the given routes or location context suggests this might be a lazy route scenario.
|
|
18
|
+
* This helps determine if we should delay marking navigation spans as "named" to allow for updates
|
|
19
|
+
* when lazy routes are loaded.
|
|
20
|
+
*/
|
|
21
|
+
function isLikelyLazyRouteContext(routes, location) {
|
|
22
|
+
// Check if any route in the current match has lazy properties
|
|
23
|
+
const hasLazyRoute = routes.some(route => {
|
|
24
|
+
return (
|
|
25
|
+
// React Router lazy() route
|
|
26
|
+
route.lazy ||
|
|
27
|
+
// Route with async handlers that might load child routes
|
|
28
|
+
(route.handle &&
|
|
29
|
+
typeof route.handle === 'object' &&
|
|
30
|
+
Object.values(route.handle).some(handler => typeof handler === 'function'))
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
if (hasLazyRoute) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Check if current route is unmatched, which might indicate a lazy route that hasn't loaded yet
|
|
39
|
+
const currentMatches = _matchRoutes(routes, location);
|
|
40
|
+
if (!currentMatches || currentMatches.length === 0) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Helper functions
|
|
48
|
+
function pickPath(match) {
|
|
49
|
+
return trimWildcard(match.route.path || '');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function pickSplat(match) {
|
|
53
|
+
return match.params['*'] || '';
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function trimWildcard(path) {
|
|
57
|
+
return path[path.length - 1] === '*' ? path.slice(0, -1) : path;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function trimSlash(path) {
|
|
61
|
+
return path[path.length - 1] === '/' ? path.slice(0, -1) : path;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Checks if a path ends with a wildcard character (*).
|
|
66
|
+
*/
|
|
67
|
+
function pathEndsWithWildcard(path) {
|
|
68
|
+
return path.endsWith('*');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Checks if a path is a wildcard and has child routes.
|
|
73
|
+
*/
|
|
74
|
+
function pathIsWildcardAndHasChildren(path, branch) {
|
|
75
|
+
return (pathEndsWithWildcard(path) && !!branch.route.children?.length) || false;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function routeIsDescendant(route) {
|
|
79
|
+
return !!(!route.children && route.element && route.path?.endsWith('/*'));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function sendIndexPath(pathBuilder, pathname, basename) {
|
|
83
|
+
const reconstructedPath = pathBuilder || _stripBasename ? stripBasenameFromPathname(pathname, basename) : pathname;
|
|
84
|
+
|
|
85
|
+
const formattedPath =
|
|
86
|
+
// If the path ends with a slash, remove it
|
|
87
|
+
reconstructedPath[reconstructedPath.length - 1] === '/'
|
|
88
|
+
? reconstructedPath.slice(0, -1)
|
|
89
|
+
: // If the path ends with a wildcard, remove it
|
|
90
|
+
reconstructedPath.slice(-2) === '/*'
|
|
91
|
+
? reconstructedPath.slice(0, -1)
|
|
92
|
+
: reconstructedPath;
|
|
93
|
+
|
|
94
|
+
return [formattedPath, 'route'];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Returns the number of URL segments in the given URL string.
|
|
99
|
+
* Splits at '/' or '\/' to handle regex URLs correctly.
|
|
100
|
+
*
|
|
101
|
+
* @param url - The URL string to segment.
|
|
102
|
+
* @returns The number of segments in the URL.
|
|
103
|
+
*/
|
|
104
|
+
function getNumberOfUrlSegments(url) {
|
|
105
|
+
// split at '/' or at '\/' to split regex urls correctly
|
|
106
|
+
return url.split(/\\?\//).filter(s => s.length > 0 && s !== ',').length;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Strip the basename from a pathname if exists.
|
|
111
|
+
*
|
|
112
|
+
* Vendored and modified from `react-router`
|
|
113
|
+
* https://github.com/remix-run/react-router/blob/462bb712156a3f739d6139a0f14810b76b002df6/packages/router/utils.ts#L1038
|
|
114
|
+
*/
|
|
115
|
+
function stripBasenameFromPathname(pathname, basename) {
|
|
116
|
+
if (!basename || basename === '/') {
|
|
117
|
+
return pathname;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) {
|
|
121
|
+
return pathname;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// We want to leave trailing slash behavior in the user's control, so if they
|
|
125
|
+
// specify a basename with a trailing slash, we should support it
|
|
126
|
+
const startIndex = basename.endsWith('/') ? basename.length - 1 : basename.length;
|
|
127
|
+
const nextChar = pathname.charAt(startIndex);
|
|
128
|
+
if (nextChar && nextChar !== '/') {
|
|
129
|
+
// pathname does not start with basename/
|
|
130
|
+
return pathname;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return pathname.slice(startIndex) || '/';
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Exported utility functions
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Ensures a path string starts with a forward slash.
|
|
140
|
+
*/
|
|
141
|
+
function prefixWithSlash(path) {
|
|
142
|
+
return path[0] === '/' ? path : `/${path}`;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Rebuilds the route path from all available routes by matching against the current location.
|
|
147
|
+
*/
|
|
148
|
+
function rebuildRoutePathFromAllRoutes(allRoutes, location) {
|
|
149
|
+
const matchedRoutes = _matchRoutes(allRoutes, location) ;
|
|
150
|
+
|
|
151
|
+
if (!matchedRoutes || matchedRoutes.length === 0) {
|
|
152
|
+
return '';
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
for (const match of matchedRoutes) {
|
|
156
|
+
if (match.route.path && match.route.path !== '*') {
|
|
157
|
+
const path = pickPath(match);
|
|
158
|
+
const strippedPath = stripBasenameFromPathname(location.pathname, prefixWithSlash(match.pathnameBase));
|
|
159
|
+
|
|
160
|
+
if (location.pathname === strippedPath) {
|
|
161
|
+
return trimSlash(strippedPath);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return trimSlash(
|
|
165
|
+
trimSlash(path || '') +
|
|
166
|
+
prefixWithSlash(
|
|
167
|
+
rebuildRoutePathFromAllRoutes(
|
|
168
|
+
allRoutes.filter(route => route !== match.route),
|
|
169
|
+
{
|
|
170
|
+
pathname: strippedPath,
|
|
171
|
+
},
|
|
172
|
+
),
|
|
173
|
+
),
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return '';
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Checks if the current location is inside a descendant route (route with splat parameter).
|
|
183
|
+
*/
|
|
184
|
+
function locationIsInsideDescendantRoute(location, routes) {
|
|
185
|
+
const matchedRoutes = _matchRoutes(routes, location) ;
|
|
186
|
+
|
|
187
|
+
if (matchedRoutes) {
|
|
188
|
+
for (const match of matchedRoutes) {
|
|
189
|
+
if (routeIsDescendant(match.route) && pickSplat(match)) {
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Gets a normalized route name and transaction source from the current routes and location.
|
|
200
|
+
*/
|
|
201
|
+
function getNormalizedName(
|
|
202
|
+
routes,
|
|
203
|
+
location,
|
|
204
|
+
branches,
|
|
205
|
+
basename = '',
|
|
206
|
+
) {
|
|
207
|
+
if (!routes || routes.length === 0) {
|
|
208
|
+
return [_stripBasename ? stripBasenameFromPathname(location.pathname, basename) : location.pathname, 'url'];
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
let pathBuilder = '';
|
|
212
|
+
|
|
213
|
+
if (branches) {
|
|
214
|
+
for (const branch of branches) {
|
|
215
|
+
const route = branch.route;
|
|
216
|
+
if (route) {
|
|
217
|
+
// Early return if index route
|
|
218
|
+
if (route.index) {
|
|
219
|
+
return sendIndexPath(pathBuilder, branch.pathname, basename);
|
|
220
|
+
}
|
|
221
|
+
const path = route.path;
|
|
222
|
+
|
|
223
|
+
// If path is not a wildcard and has no child routes, append the path
|
|
224
|
+
if (path && !pathIsWildcardAndHasChildren(path, branch)) {
|
|
225
|
+
const newPath = path[0] === '/' || pathBuilder[pathBuilder.length - 1] === '/' ? path : `/${path}`;
|
|
226
|
+
pathBuilder = trimSlash(pathBuilder) + prefixWithSlash(newPath);
|
|
227
|
+
|
|
228
|
+
// If the path matches the current location, return the path
|
|
229
|
+
if (trimSlash(location.pathname) === trimSlash(basename + branch.pathname)) {
|
|
230
|
+
if (
|
|
231
|
+
// If the route defined on the element is something like
|
|
232
|
+
// <Route path="/stores/:storeId/products/:productId" element={<div>Product</div>} />
|
|
233
|
+
// We should check against the branch.pathname for the number of / separators
|
|
234
|
+
getNumberOfUrlSegments(pathBuilder) !== getNumberOfUrlSegments(branch.pathname) &&
|
|
235
|
+
// We should not count wildcard operators in the url segments calculation
|
|
236
|
+
!pathEndsWithWildcard(pathBuilder)
|
|
237
|
+
) {
|
|
238
|
+
return [(_stripBasename ? '' : basename) + newPath, 'route'];
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// if the last character of the pathbuilder is a wildcard and there are children, remove the wildcard
|
|
242
|
+
if (pathIsWildcardAndHasChildren(pathBuilder, branch)) {
|
|
243
|
+
pathBuilder = pathBuilder.slice(0, -1);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return [(_stripBasename ? '' : basename) + pathBuilder, 'route'];
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const fallbackTransactionName = _stripBasename
|
|
254
|
+
? stripBasenameFromPathname(location.pathname, basename)
|
|
255
|
+
: location.pathname || '';
|
|
256
|
+
|
|
257
|
+
return [fallbackTransactionName, 'url'];
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Shared helper function to resolve route name and source
|
|
262
|
+
*/
|
|
263
|
+
function resolveRouteNameAndSource(
|
|
264
|
+
location,
|
|
265
|
+
routes,
|
|
266
|
+
allRoutes,
|
|
267
|
+
branches,
|
|
268
|
+
basename = '',
|
|
269
|
+
) {
|
|
270
|
+
let name;
|
|
271
|
+
let source = 'url';
|
|
272
|
+
|
|
273
|
+
const isInDescendantRoute = locationIsInsideDescendantRoute(location, allRoutes);
|
|
274
|
+
|
|
275
|
+
if (isInDescendantRoute) {
|
|
276
|
+
name = prefixWithSlash(rebuildRoutePathFromAllRoutes(allRoutes, location));
|
|
277
|
+
source = 'route';
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
if (!isInDescendantRoute || !name) {
|
|
281
|
+
[name, source] = getNormalizedName(routes, location, branches, basename);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return [name || location.pathname, source];
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
exports.getNormalizedName = getNormalizedName;
|
|
288
|
+
exports.getNumberOfUrlSegments = getNumberOfUrlSegments;
|
|
289
|
+
exports.initializeRouterUtils = initializeRouterUtils;
|
|
290
|
+
exports.isLikelyLazyRouteContext = isLikelyLazyRouteContext;
|
|
291
|
+
exports.locationIsInsideDescendantRoute = locationIsInsideDescendantRoute;
|
|
292
|
+
exports.pathEndsWithWildcard = pathEndsWithWildcard;
|
|
293
|
+
exports.pathIsWildcardAndHasChildren = pathIsWildcardAndHasChildren;
|
|
294
|
+
exports.prefixWithSlash = prefixWithSlash;
|
|
295
|
+
exports.rebuildRoutePathFromAllRoutes = rebuildRoutePathFromAllRoutes;
|
|
296
|
+
exports.resolveRouteNameAndSource = resolveRouteNameAndSource;
|
|
297
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../src/reactrouter-compat-utils/utils.ts"],"sourcesContent":["import type { TransactionSource } from '@sentry/core';\nimport type { Location, MatchRoutes, RouteMatch, RouteObject } from '../types';\n\n// Global variables that these utilities depend on\nlet _matchRoutes: MatchRoutes;\nlet _stripBasename: boolean = false;\n\n/**\n * Initialize function to set dependencies that the router utilities need.\n * Must be called before using any of the exported utility functions.\n */\nexport function initializeRouterUtils(matchRoutes: MatchRoutes, stripBasename: boolean = false): void {\n _matchRoutes = matchRoutes;\n _stripBasename = stripBasename;\n}\n\n/**\n * Checks if the given routes or location context suggests this might be a lazy route scenario.\n * This helps determine if we should delay marking navigation spans as \"named\" to allow for updates\n * when lazy routes are loaded.\n */\nexport function isLikelyLazyRouteContext(routes: RouteObject[], location: Location): boolean {\n // Check if any route in the current match has lazy properties\n const hasLazyRoute = routes.some(route => {\n return (\n // React Router lazy() route\n route.lazy ||\n // Route with async handlers that might load child routes\n (route.handle &&\n typeof route.handle === 'object' &&\n Object.values(route.handle).some(handler => typeof handler === 'function'))\n );\n });\n\n if (hasLazyRoute) {\n return true;\n }\n\n // Check if current route is unmatched, which might indicate a lazy route that hasn't loaded yet\n const currentMatches = _matchRoutes(routes, location);\n if (!currentMatches || currentMatches.length === 0) {\n return true;\n }\n\n return false;\n}\n\n// Helper functions\nfunction pickPath(match: RouteMatch): string {\n return trimWildcard(match.route.path || '');\n}\n\nfunction pickSplat(match: RouteMatch): string {\n return match.params['*'] || '';\n}\n\nfunction trimWildcard(path: string): string {\n return path[path.length - 1] === '*' ? path.slice(0, -1) : path;\n}\n\nfunction trimSlash(path: string): string {\n return path[path.length - 1] === '/' ? path.slice(0, -1) : path;\n}\n\n/**\n * Checks if a path ends with a wildcard character (*).\n */\nexport function pathEndsWithWildcard(path: string): boolean {\n return path.endsWith('*');\n}\n\n/**\n * Checks if a path is a wildcard and has child routes.\n */\nexport function pathIsWildcardAndHasChildren(path: string, branch: RouteMatch<string>): boolean {\n return (pathEndsWithWildcard(path) && !!branch.route.children?.length) || false;\n}\n\nfunction routeIsDescendant(route: RouteObject): boolean {\n return !!(!route.children && route.element && route.path?.endsWith('/*'));\n}\n\nfunction sendIndexPath(pathBuilder: string, pathname: string, basename: string): [string, TransactionSource] {\n const reconstructedPath = pathBuilder || _stripBasename ? stripBasenameFromPathname(pathname, basename) : pathname;\n\n const formattedPath =\n // If the path ends with a slash, remove it\n reconstructedPath[reconstructedPath.length - 1] === '/'\n ? reconstructedPath.slice(0, -1)\n : // If the path ends with a wildcard, remove it\n reconstructedPath.slice(-2) === '/*'\n ? reconstructedPath.slice(0, -1)\n : reconstructedPath;\n\n return [formattedPath, 'route'];\n}\n\n/**\n * Returns the number of URL segments in the given URL string.\n * Splits at '/' or '\\/' to handle regex URLs correctly.\n *\n * @param url - The URL string to segment.\n * @returns The number of segments in the URL.\n */\nexport function getNumberOfUrlSegments(url: string): number {\n // split at '/' or at '\\/' to split regex urls correctly\n return url.split(/\\\\?\\//).filter(s => s.length > 0 && s !== ',').length;\n}\n\n/**\n * Strip the basename from a pathname if exists.\n *\n * Vendored and modified from `react-router`\n * https://github.com/remix-run/react-router/blob/462bb712156a3f739d6139a0f14810b76b002df6/packages/router/utils.ts#L1038\n */\nfunction stripBasenameFromPathname(pathname: string, basename: string): string {\n if (!basename || basename === '/') {\n return pathname;\n }\n\n if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) {\n return pathname;\n }\n\n // We want to leave trailing slash behavior in the user's control, so if they\n // specify a basename with a trailing slash, we should support it\n const startIndex = basename.endsWith('/') ? basename.length - 1 : basename.length;\n const nextChar = pathname.charAt(startIndex);\n if (nextChar && nextChar !== '/') {\n // pathname does not start with basename/\n return pathname;\n }\n\n return pathname.slice(startIndex) || '/';\n}\n\n// Exported utility functions\n\n/**\n * Ensures a path string starts with a forward slash.\n */\nexport function prefixWithSlash(path: string): string {\n return path[0] === '/' ? path : `/${path}`;\n}\n\n/**\n * Rebuilds the route path from all available routes by matching against the current location.\n */\nexport function rebuildRoutePathFromAllRoutes(allRoutes: RouteObject[], location: Location): string {\n const matchedRoutes = _matchRoutes(allRoutes, location) as RouteMatch[];\n\n if (!matchedRoutes || matchedRoutes.length === 0) {\n return '';\n }\n\n for (const match of matchedRoutes) {\n if (match.route.path && match.route.path !== '*') {\n const path = pickPath(match);\n const strippedPath = stripBasenameFromPathname(location.pathname, prefixWithSlash(match.pathnameBase));\n\n if (location.pathname === strippedPath) {\n return trimSlash(strippedPath);\n }\n\n return trimSlash(\n trimSlash(path || '') +\n prefixWithSlash(\n rebuildRoutePathFromAllRoutes(\n allRoutes.filter(route => route !== match.route),\n {\n pathname: strippedPath,\n },\n ),\n ),\n );\n }\n }\n\n return '';\n}\n\n/**\n * Checks if the current location is inside a descendant route (route with splat parameter).\n */\nexport function locationIsInsideDescendantRoute(location: Location, routes: RouteObject[]): boolean {\n const matchedRoutes = _matchRoutes(routes, location) as RouteMatch[];\n\n if (matchedRoutes) {\n for (const match of matchedRoutes) {\n if (routeIsDescendant(match.route) && pickSplat(match)) {\n return true;\n }\n }\n }\n\n return false;\n}\n\n/**\n * Gets a normalized route name and transaction source from the current routes and location.\n */\nexport function getNormalizedName(\n routes: RouteObject[],\n location: Location,\n branches: RouteMatch[],\n basename: string = '',\n): [string, TransactionSource] {\n if (!routes || routes.length === 0) {\n return [_stripBasename ? stripBasenameFromPathname(location.pathname, basename) : location.pathname, 'url'];\n }\n\n let pathBuilder = '';\n\n if (branches) {\n for (const branch of branches) {\n const route = branch.route;\n if (route) {\n // Early return if index route\n if (route.index) {\n return sendIndexPath(pathBuilder, branch.pathname, basename);\n }\n const path = route.path;\n\n // If path is not a wildcard and has no child routes, append the path\n if (path && !pathIsWildcardAndHasChildren(path, branch)) {\n const newPath = path[0] === '/' || pathBuilder[pathBuilder.length - 1] === '/' ? path : `/${path}`;\n pathBuilder = trimSlash(pathBuilder) + prefixWithSlash(newPath);\n\n // If the path matches the current location, return the path\n if (trimSlash(location.pathname) === trimSlash(basename + branch.pathname)) {\n if (\n // If the route defined on the element is something like\n // <Route path=\"/stores/:storeId/products/:productId\" element={<div>Product</div>} />\n // We should check against the branch.pathname for the number of / separators\n getNumberOfUrlSegments(pathBuilder) !== getNumberOfUrlSegments(branch.pathname) &&\n // We should not count wildcard operators in the url segments calculation\n !pathEndsWithWildcard(pathBuilder)\n ) {\n return [(_stripBasename ? '' : basename) + newPath, 'route'];\n }\n\n // if the last character of the pathbuilder is a wildcard and there are children, remove the wildcard\n if (pathIsWildcardAndHasChildren(pathBuilder, branch)) {\n pathBuilder = pathBuilder.slice(0, -1);\n }\n\n return [(_stripBasename ? '' : basename) + pathBuilder, 'route'];\n }\n }\n }\n }\n }\n\n const fallbackTransactionName = _stripBasename\n ? stripBasenameFromPathname(location.pathname, basename)\n : location.pathname || '';\n\n return [fallbackTransactionName, 'url'];\n}\n\n/**\n * Shared helper function to resolve route name and source\n */\nexport function resolveRouteNameAndSource(\n location: Location,\n routes: RouteObject[],\n allRoutes: RouteObject[],\n branches: RouteMatch[],\n basename: string = '',\n): [string, TransactionSource] {\n let name: string | undefined;\n let source: TransactionSource = 'url';\n\n const isInDescendantRoute = locationIsInsideDescendantRoute(location, allRoutes);\n\n if (isInDescendantRoute) {\n name = prefixWithSlash(rebuildRoutePathFromAllRoutes(allRoutes, location));\n source = 'route';\n }\n\n if (!isInDescendantRoute || !name) {\n [name, source] = getNormalizedName(routes, location, branches, basename);\n }\n\n return [name || location.path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;AAEA,EAAA,OAAA,CAAA,IAAA,IAAA,QAAA,CAAA,QAAA,EAAA,MAAA,CAAA;AACA;;;;;;;;;;;;;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const instrumentation = require('./reactrouter-compat-utils/instrumentation.js');
|
|
4
|
+
require('@sentry/core');
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* A browser tracing integration that uses React Router v6 to instrument navigations.
|
|
@@ -9,7 +10,7 @@ const reactrouterv6CompatUtils = require('./reactrouterv6-compat-utils.js');
|
|
|
9
10
|
function reactRouterV6BrowserTracingIntegration(
|
|
10
11
|
options,
|
|
11
12
|
) {
|
|
12
|
-
return
|
|
13
|
+
return instrumentation.createReactRouterV6CompatibleTracingIntegration(options, '6');
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -17,7 +18,7 @@ function reactRouterV6BrowserTracingIntegration(
|
|
|
17
18
|
* This is used to automatically capture route changes as transactions when using the useRoutes hook.
|
|
18
19
|
*/
|
|
19
20
|
function wrapUseRoutesV6(origUseRoutes) {
|
|
20
|
-
return
|
|
21
|
+
return instrumentation.createV6CompatibleWrapUseRoutes(origUseRoutes, '6');
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
/**
|
|
@@ -27,7 +28,7 @@ function wrapUseRoutesV6(origUseRoutes) {
|
|
|
27
28
|
function wrapCreateBrowserRouterV6
|
|
28
29
|
|
|
29
30
|
(createRouterFunction) {
|
|
30
|
-
return
|
|
31
|
+
return instrumentation.createV6CompatibleWrapCreateBrowserRouter(createRouterFunction, '6');
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
/**
|
|
@@ -39,7 +40,7 @@ function wrapCreateBrowserRouterV6
|
|
|
39
40
|
function wrapCreateMemoryRouterV6
|
|
40
41
|
|
|
41
42
|
(createMemoryRouterFunction) {
|
|
42
|
-
return
|
|
43
|
+
return instrumentation.createV6CompatibleWrapCreateMemoryRouter(createMemoryRouterFunction, '6');
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
/**
|
|
@@ -48,7 +49,7 @@ function wrapCreateMemoryRouterV6
|
|
|
48
49
|
*/
|
|
49
50
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
51
|
function withSentryReactRouterV6Routing(routes) {
|
|
51
|
-
return
|
|
52
|
+
return instrumentation.createV6CompatibleWithSentryReactRouterRouting(routes, '6');
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
exports.reactRouterV6BrowserTracingIntegration = reactRouterV6BrowserTracingIntegration;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactrouterv6.js","sources":["../../src/reactrouterv6.tsx"],"sourcesContent":["import type { browserTracingIntegration } from '@sentry/browser';\nimport type { Integration } from '@sentry/core';\nimport type { ReactRouterOptions } from './
|
|
1
|
+
{"version":3,"file":"reactrouterv6.js","sources":["../../src/reactrouterv6.tsx"],"sourcesContent":["import type { browserTracingIntegration } from '@sentry/browser';\nimport type { Integration } from '@sentry/core';\nimport type { ReactRouterOptions } from './reactrouter-compat-utils';\nimport {\n createReactRouterV6CompatibleTracingIntegration,\n createV6CompatibleWithSentryReactRouterRouting,\n createV6CompatibleWrapCreateBrowserRouter,\n createV6CompatibleWrapCreateMemoryRouter,\n createV6CompatibleWrapUseRoutes,\n} from './reactrouter-compat-utils';\nimport type { CreateRouterFunction, Router, RouterState, UseRoutes } from './types';\n\n/**\n * A browser tracing integration that uses React Router v6 to instrument navigations.\n * Expects `useEffect`, `useLocation`, `useNavigationType`, `createRoutesFromChildren` and `matchRoutes` to be passed as options.\n */\nexport function reactRouterV6BrowserTracingIntegration(\n options: Parameters<typeof browserTracingIntegration>[0] & ReactRouterOptions,\n): Integration {\n return createReactRouterV6CompatibleTracingIntegration(options, '6');\n}\n\n/**\n * A wrapper function that adds Sentry routing instrumentation to a React Router v6 useRoutes hook.\n * This is used to automatically capture route changes as transactions when using the useRoutes hook.\n */\nexport function wrapUseRoutesV6(origUseRoutes: UseRoutes): UseRoutes {\n return createV6CompatibleWrapUseRoutes(origUseRoutes, '6');\n}\n\n/**\n * A wrapper function that adds Sentry routing instrumentation to a React Router v6 createBrowserRouter function.\n * This is used to automatically capture route changes as transactions when using the createBrowserRouter API.\n */\nexport function wrapCreateBrowserRouterV6<\n TState extends RouterState = RouterState,\n TRouter extends Router<TState> = Router<TState>,\n>(createRouterFunction: CreateRouterFunction<TState, TRouter>): CreateRouterFunction<TState, TRouter> {\n return createV6CompatibleWrapCreateBrowserRouter(createRouterFunction, '6');\n}\n\n/**\n * A wrapper function that adds Sentry routing instrumentation to a React Router v6 createMemoryRouter function.\n * This is used to automatically capture route changes as transactions when using the createMemoryRouter API.\n * The difference between createBrowserRouter and createMemoryRouter is that with createMemoryRouter,\n * optional `initialEntries` are also taken into account.\n */\nexport function wrapCreateMemoryRouterV6<\n TState extends RouterState = RouterState,\n TRouter extends Router<TState> = Router<TState>,\n>(createMemoryRouterFunction: CreateRouterFunction<TState, TRouter>): CreateRouterFunction<TState, TRouter> {\n return createV6CompatibleWrapCreateMemoryRouter(createMemoryRouterFunction, '6');\n}\n\n/**\n * A higher-order component that adds Sentry routing instrumentation to a React Router v6 Route component.\n * This is used to automatically capture route changes as transactions.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function withSentryReactRouterV6Routing<P extends Record<string, any>, R extends React.FC<P>>(routes: R): R {\n return createV6CompatibleWithSentryReactRouterRouting<P, R>(routes, '6');\n}\n"],"names":["createReactRouterV6CompatibleTracingIntegration","createV6CompatibleWrapUseRoutes","createV6CompatibleWrapCreateBrowserRouter","createV6CompatibleWrapCreateMemoryRouter","createV6CompatibleWithSentryReactRouterRouting"],"mappings":";;;;;AAYA;AACA;AACA;AACA;AACO,SAAS,sCAAsC;AACtD,EAAE,OAAO;AACT,EAAe;AACf,EAAE,OAAOA,+DAA+C,CAAC,OAAO,EAAE,GAAG,CAAC;AACtE;;AAEA;AACA;AACA;AACA;AACO,SAAS,eAAe,CAAC,aAAa,EAAwB;AACrE,EAAE,OAAOC,+CAA+B,CAAC,aAAa,EAAE,GAAG,CAAC;AAC5D;;AAEA;AACA;AACA;AACA;AACO,SAAS;;AAGhB,CAAE,oBAAoB,EAAgF;AACtG,EAAE,OAAOC,yDAAyC,CAAC,oBAAoB,EAAE,GAAG,CAAC;AAC7E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS;;AAGhB,CAAE,0BAA0B,EAAgF;AAC5G,EAAE,OAAOC,wDAAwC,CAAC,0BAA0B,EAAE,GAAG,CAAC;AAClF;;AAEA;AACA;AACA;AACA;AACA;AACO,SAAS,8BAA8B,CAAuD,MAAM,EAAQ;AACnH,EAAE,OAAOC,8DAA8C,CAAO,MAAM,EAAE,GAAG,CAAC;AAC1E;;;;;;;;"}
|