@sentry/react 10.37.0 → 10.39.0-alpha.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/hoist-non-react-statics.js +4 -4
- package/build/cjs/hoist-non-react-statics.js.map +1 -1
- package/build/cjs/reactrouter-compat-utils/instrumentation.js +67 -35
- package/build/cjs/reactrouter-compat-utils/instrumentation.js.map +1 -1
- package/build/cjs/reactrouter-compat-utils/lazy-routes.js +19 -10
- package/build/cjs/reactrouter-compat-utils/lazy-routes.js.map +1 -1
- package/build/cjs/reactrouter-compat-utils/route-manifest.js +194 -0
- package/build/cjs/reactrouter-compat-utils/route-manifest.js.map +1 -0
- package/build/cjs/reactrouter-compat-utils/utils.js +16 -31
- package/build/cjs/reactrouter-compat-utils/utils.js.map +1 -1
- package/build/esm/hoist-non-react-statics.js +4 -4
- package/build/esm/hoist-non-react-statics.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/reactrouter-compat-utils/instrumentation.js +68 -36
- package/build/esm/reactrouter-compat-utils/instrumentation.js.map +1 -1
- package/build/esm/reactrouter-compat-utils/lazy-routes.js +20 -11
- package/build/esm/reactrouter-compat-utils/lazy-routes.js.map +1 -1
- package/build/esm/reactrouter-compat-utils/route-manifest.js +191 -0
- package/build/esm/reactrouter-compat-utils/route-manifest.js.map +1 -0
- package/build/esm/reactrouter-compat-utils/utils.js +12 -27
- package/build/esm/reactrouter-compat-utils/utils.js.map +1 -1
- package/build/esm/reactrouter.js +1 -1
- package/build/esm/reactrouterv6.js +1 -1
- package/build/types/reactrouter-compat-utils/instrumentation.d.ts +18 -0
- package/build/types/reactrouter-compat-utils/instrumentation.d.ts.map +1 -1
- package/build/types/reactrouter-compat-utils/lazy-routes.d.ts.map +1 -1
- package/build/types/reactrouter-compat-utils/route-manifest.d.ts +13 -0
- package/build/types/reactrouter-compat-utils/route-manifest.d.ts.map +1 -0
- package/build/types/reactrouter-compat-utils/utils.d.ts +1 -1
- package/build/types/reactrouter-compat-utils/utils.d.ts.map +1 -1
- package/build/types-ts3.8/reactrouter-compat-utils/instrumentation.d.ts +18 -0
- package/build/types-ts3.8/reactrouter-compat-utils/route-manifest.d.ts +13 -0
- package/build/types-ts3.8/reactrouter-compat-utils/utils.d.ts +1 -1
- package/package.json +5 -5
|
@@ -130,12 +130,12 @@ function hoistNonReactStatics
|
|
|
130
130
|
const sourceStatics = getStatics(sourceComponent);
|
|
131
131
|
|
|
132
132
|
for (const key of keys) {
|
|
133
|
-
|
|
133
|
+
// Use key directly - String(key) throws for Symbols if minified to '' + key (#18966)
|
|
134
134
|
if (
|
|
135
|
-
!KNOWN_STATICS[
|
|
135
|
+
!KNOWN_STATICS[key ] &&
|
|
136
136
|
true &&
|
|
137
|
-
!sourceStatics?.[
|
|
138
|
-
!targetStatics?.[
|
|
137
|
+
!sourceStatics?.[key ] &&
|
|
138
|
+
!targetStatics?.[key ] &&
|
|
139
139
|
!getOwnPropertyDescriptor(targetComponent, key) // Don't overwrite existing properties
|
|
140
140
|
) {
|
|
141
141
|
const descriptor = getOwnPropertyDescriptor(sourceComponent, key);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hoist-non-react-statics.js","sources":["../../src/hoist-non-react-statics.ts"],"sourcesContent":["/**\n * Inlined implementation of hoist-non-react-statics\n * Original library: https://github.com/mridgway/hoist-non-react-statics\n * License: BSD-3-Clause\n * Copyright 2015, Yahoo! Inc.\n *\n * This is an inlined version to avoid ESM compatibility issues with the original package.\n */\n\nimport type * as React from 'react';\n\n/**\n * React statics that should not be hoisted\n */\nconst REACT_STATICS = {\n childContextTypes: true,\n contextType: true,\n contextTypes: true,\n defaultProps: true,\n displayName: true,\n getDefaultProps: true,\n getDerivedStateFromError: true,\n getDerivedStateFromProps: true,\n mixins: true,\n propTypes: true,\n type: true,\n} as const;\n\n/**\n * Known JavaScript function statics that should not be hoisted\n */\nconst KNOWN_STATICS = {\n name: true,\n length: true,\n prototype: true,\n caller: true,\n callee: true,\n arguments: true,\n arity: true,\n} as const;\n\n/**\n * Statics specific to ForwardRef components\n */\nconst FORWARD_REF_STATICS = {\n $$typeof: true,\n render: true,\n defaultProps: true,\n displayName: true,\n propTypes: true,\n} as const;\n\n/**\n * Statics specific to Memo components\n */\nconst MEMO_STATICS = {\n $$typeof: true,\n compare: true,\n defaultProps: true,\n displayName: true,\n propTypes: true,\n type: true,\n} as const;\n\n/**\n * Inlined react-is utilities\n * We only need to detect ForwardRef and Memo types\n */\nconst ForwardRefType = Symbol.for('react.forward_ref');\nconst MemoType = Symbol.for('react.memo');\n\n/**\n * Check if a component is a Memo component\n */\nfunction isMemo(component: unknown): boolean {\n return (\n typeof component === 'object' && component !== null && (component as { $$typeof?: symbol }).$$typeof === MemoType\n );\n}\n\n/**\n * Map of React component types to their specific statics\n */\nconst TYPE_STATICS: Record<symbol, Record<string, boolean>> = {};\nTYPE_STATICS[ForwardRefType] = FORWARD_REF_STATICS;\nTYPE_STATICS[MemoType] = MEMO_STATICS;\n\n/**\n * Get the appropriate statics object for a given component\n */\nfunction getStatics(component: React.ComponentType<unknown>): Record<string, boolean> {\n // React v16.11 and below\n if (isMemo(component)) {\n return MEMO_STATICS;\n }\n\n // React v16.12 and above\n const componentType = (component as { $$typeof?: symbol }).$$typeof;\n return (componentType && TYPE_STATICS[componentType]) || REACT_STATICS;\n}\n\nconst defineProperty = Object.defineProperty.bind(Object);\nconst getOwnPropertyNames = Object.getOwnPropertyNames.bind(Object);\nconst getOwnPropertySymbols = Object.getOwnPropertySymbols?.bind(Object);\nconst getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor.bind(Object);\nconst getPrototypeOf = Object.getPrototypeOf.bind(Object);\nconst objectPrototype = Object.prototype;\n\n/**\n * Copies non-react specific statics from a child component to a parent component.\n * Similar to Object.assign, but copies all static properties from source to target,\n * excluding React-specific statics and known JavaScript statics.\n *\n * @param targetComponent - The component to copy statics to\n * @param sourceComponent - The component to copy statics from\n * @param excludelist - An optional object of keys to exclude from hoisting\n * @returns The target component with hoisted statics\n */\nexport function hoistNonReactStatics<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends React.ComponentType<any>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n S extends React.ComponentType<any>,\n C extends Record<string, boolean> = Record<string, never>,\n>(targetComponent: T, sourceComponent: S, excludelist?: C): T {\n if (typeof sourceComponent !== 'string') {\n // Don't hoist over string (html) components\n if (objectPrototype) {\n const inheritedComponent = getPrototypeOf(sourceComponent);\n\n if (inheritedComponent && inheritedComponent !== objectPrototype) {\n hoistNonReactStatics(targetComponent, inheritedComponent, excludelist);\n }\n }\n\n let keys: (string | symbol)[] = getOwnPropertyNames(sourceComponent);\n\n if (getOwnPropertySymbols) {\n keys = keys.concat(getOwnPropertySymbols(sourceComponent));\n }\n\n const targetStatics = getStatics(targetComponent);\n const sourceStatics = getStatics(sourceComponent);\n\n for (const key of keys) {\n
|
|
1
|
+
{"version":3,"file":"hoist-non-react-statics.js","sources":["../../src/hoist-non-react-statics.ts"],"sourcesContent":["/**\n * Inlined implementation of hoist-non-react-statics\n * Original library: https://github.com/mridgway/hoist-non-react-statics\n * License: BSD-3-Clause\n * Copyright 2015, Yahoo! Inc.\n *\n * This is an inlined version to avoid ESM compatibility issues with the original package.\n */\n\nimport type * as React from 'react';\n\n/**\n * React statics that should not be hoisted\n */\nconst REACT_STATICS = {\n childContextTypes: true,\n contextType: true,\n contextTypes: true,\n defaultProps: true,\n displayName: true,\n getDefaultProps: true,\n getDerivedStateFromError: true,\n getDerivedStateFromProps: true,\n mixins: true,\n propTypes: true,\n type: true,\n} as const;\n\n/**\n * Known JavaScript function statics that should not be hoisted\n */\nconst KNOWN_STATICS = {\n name: true,\n length: true,\n prototype: true,\n caller: true,\n callee: true,\n arguments: true,\n arity: true,\n} as const;\n\n/**\n * Statics specific to ForwardRef components\n */\nconst FORWARD_REF_STATICS = {\n $$typeof: true,\n render: true,\n defaultProps: true,\n displayName: true,\n propTypes: true,\n} as const;\n\n/**\n * Statics specific to Memo components\n */\nconst MEMO_STATICS = {\n $$typeof: true,\n compare: true,\n defaultProps: true,\n displayName: true,\n propTypes: true,\n type: true,\n} as const;\n\n/**\n * Inlined react-is utilities\n * We only need to detect ForwardRef and Memo types\n */\nconst ForwardRefType = Symbol.for('react.forward_ref');\nconst MemoType = Symbol.for('react.memo');\n\n/**\n * Check if a component is a Memo component\n */\nfunction isMemo(component: unknown): boolean {\n return (\n typeof component === 'object' && component !== null && (component as { $$typeof?: symbol }).$$typeof === MemoType\n );\n}\n\n/**\n * Map of React component types to their specific statics\n */\nconst TYPE_STATICS: Record<symbol, Record<string, boolean>> = {};\nTYPE_STATICS[ForwardRefType] = FORWARD_REF_STATICS;\nTYPE_STATICS[MemoType] = MEMO_STATICS;\n\n/**\n * Get the appropriate statics object for a given component\n */\nfunction getStatics(component: React.ComponentType<unknown>): Record<string, boolean> {\n // React v16.11 and below\n if (isMemo(component)) {\n return MEMO_STATICS;\n }\n\n // React v16.12 and above\n const componentType = (component as { $$typeof?: symbol }).$$typeof;\n return (componentType && TYPE_STATICS[componentType]) || REACT_STATICS;\n}\n\nconst defineProperty = Object.defineProperty.bind(Object);\nconst getOwnPropertyNames = Object.getOwnPropertyNames.bind(Object);\nconst getOwnPropertySymbols = Object.getOwnPropertySymbols?.bind(Object);\nconst getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor.bind(Object);\nconst getPrototypeOf = Object.getPrototypeOf.bind(Object);\nconst objectPrototype = Object.prototype;\n\n/**\n * Copies non-react specific statics from a child component to a parent component.\n * Similar to Object.assign, but copies all static properties from source to target,\n * excluding React-specific statics and known JavaScript statics.\n *\n * @param targetComponent - The component to copy statics to\n * @param sourceComponent - The component to copy statics from\n * @param excludelist - An optional object of keys to exclude from hoisting\n * @returns The target component with hoisted statics\n */\nexport function hoistNonReactStatics<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends React.ComponentType<any>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n S extends React.ComponentType<any>,\n C extends Record<string, boolean> = Record<string, never>,\n>(targetComponent: T, sourceComponent: S, excludelist?: C): T {\n if (typeof sourceComponent !== 'string') {\n // Don't hoist over string (html) components\n if (objectPrototype) {\n const inheritedComponent = getPrototypeOf(sourceComponent);\n\n if (inheritedComponent && inheritedComponent !== objectPrototype) {\n hoistNonReactStatics(targetComponent, inheritedComponent, excludelist);\n }\n }\n\n let keys: (string | symbol)[] = getOwnPropertyNames(sourceComponent);\n\n if (getOwnPropertySymbols) {\n keys = keys.concat(getOwnPropertySymbols(sourceComponent));\n }\n\n const targetStatics = getStatics(targetComponent);\n const sourceStatics = getStatics(sourceComponent);\n\n for (const key of keys) {\n // Use key directly - String(key) throws for Symbols if minified to '' + key (#18966)\n if (\n !KNOWN_STATICS[key as keyof typeof KNOWN_STATICS] &&\n !(excludelist && excludelist[key as keyof C]) &&\n !sourceStatics?.[key as string] &&\n !targetStatics?.[key as string] &&\n !getOwnPropertyDescriptor(targetComponent, key) // Don't overwrite existing properties\n ) {\n const descriptor = getOwnPropertyDescriptor(sourceComponent, key);\n\n if (descriptor) {\n try {\n // Avoid failures from read-only properties\n defineProperty(targetComponent, key, descriptor);\n } catch (e) {\n // Silently ignore errors\n }\n }\n }\n }\n }\n\n return targetComponent;\n}\n"],"names":[],"mappings":";;AAWA;AACA;AACA;AACA,MAAM,gBAAgB;AACtB,EAAE,iBAAiB,EAAE,IAAI;AACzB,EAAE,WAAW,EAAE,IAAI;AACnB,EAAE,YAAY,EAAE,IAAI;AACpB,EAAE,YAAY,EAAE,IAAI;AACpB,EAAE,WAAW,EAAE,IAAI;AACnB,EAAE,eAAe,EAAE,IAAI;AACvB,EAAE,wBAAwB,EAAE,IAAI;AAChC,EAAE,wBAAwB,EAAE,IAAI;AAChC,EAAE,MAAM,EAAE,IAAI;AACd,EAAE,SAAS,EAAE,IAAI;AACjB,EAAE,IAAI,EAAE,IAAI;AACZ,CAAA;;AAEA;AACA;AACA;AACA,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,aAAA,GAAgB,UAAU,CAAC,eAAe,CAAC;;AAErD,IAAI,KAAK,MAAM,GAAA,IAAO,IAAI,EAAE;AAC5B;AACA,MAAM;AACN,QAAQ,CAAC,aAAa,CAAC,GAAA,EAAI;AAC3B,QAAQ,IAA4C;AACpD,QAAQ,CAAC,aAAa,GAAG,KAAI;AAC7B,QAAQ,CAAC,aAAa,GAAG,KAAI;AAC7B,QAAQ,CAAC,wBAAwB,CAAC,eAAe,EAAE,GAAG,CAAA;AACtD,QAAQ;AACR,QAAQ,MAAM,aAAa,wBAAwB,CAAC,eAAe,EAAE,GAAG,CAAC;;AAEzE,QAAQ,IAAI,UAAU,EAAE;AACxB,UAAU,IAAI;AACd;AACA,YAAY,cAAc,CAAC,eAAe,EAAE,GAAG,EAAE,UAAU,CAAC;AAC5D,UAAU,CAAA,CAAE,OAAO,CAAC,EAAE;AACtB;AACA,UAAU;AACV,QAAQ;AACR,MAAM;AACN,IAAI;AACJ,EAAE;;AAEF,EAAE,OAAO,eAAe;AACxB;;;;"}
|
|
@@ -21,6 +21,8 @@ let _matchRoutes;
|
|
|
21
21
|
|
|
22
22
|
let _enableAsyncRouteHandlers = false;
|
|
23
23
|
let _lazyRouteTimeout = 3000;
|
|
24
|
+
let _lazyRouteManifest;
|
|
25
|
+
let _basename = '';
|
|
24
26
|
|
|
25
27
|
const CLIENTS_WITH_INSTRUMENT_NAVIGATION = new WeakSet();
|
|
26
28
|
|
|
@@ -282,7 +284,9 @@ function updateNavigationSpan(
|
|
|
282
284
|
allRoutes,
|
|
283
285
|
allRoutes,
|
|
284
286
|
(currentBranches ) || [],
|
|
285
|
-
|
|
287
|
+
_basename,
|
|
288
|
+
_lazyRouteManifest,
|
|
289
|
+
_enableAsyncRouteHandlers,
|
|
286
290
|
);
|
|
287
291
|
|
|
288
292
|
const currentSource = spanJson.data?.[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];
|
|
@@ -446,6 +450,9 @@ function createV6CompatibleWrapCreateBrowserRouter
|
|
|
446
450
|
});
|
|
447
451
|
}
|
|
448
452
|
|
|
453
|
+
// Store basename for use in updateNavigationSpan
|
|
454
|
+
_basename = basename || '';
|
|
455
|
+
|
|
449
456
|
setupRouterSubscription(router, routes, version, basename, activeRootSpan);
|
|
450
457
|
|
|
451
458
|
return router;
|
|
@@ -537,6 +544,9 @@ function createV6CompatibleWrapCreateMemoryRouter
|
|
|
537
544
|
});
|
|
538
545
|
}
|
|
539
546
|
|
|
547
|
+
// Store basename for use in updateNavigationSpan
|
|
548
|
+
_basename = basename || '';
|
|
549
|
+
|
|
540
550
|
setupRouterSubscription(router, routes, version, basename, memoryActiveRootSpan);
|
|
541
551
|
|
|
542
552
|
return router;
|
|
@@ -563,6 +573,7 @@ function createReactRouterV6CompatibleTracingIntegration(
|
|
|
563
573
|
instrumentPageLoad = true,
|
|
564
574
|
instrumentNavigation = true,
|
|
565
575
|
lazyRouteTimeout,
|
|
576
|
+
lazyRouteManifest,
|
|
566
577
|
} = options;
|
|
567
578
|
|
|
568
579
|
return {
|
|
@@ -606,6 +617,7 @@ function createReactRouterV6CompatibleTracingIntegration(
|
|
|
606
617
|
_matchRoutes = matchRoutes;
|
|
607
618
|
_createRoutesFromChildren = createRoutesFromChildren;
|
|
608
619
|
_enableAsyncRouteHandlers = enableAsyncRouteHandlers;
|
|
620
|
+
_lazyRouteManifest = lazyRouteManifest;
|
|
609
621
|
|
|
610
622
|
// Initialize the router utils with the required dependencies
|
|
611
623
|
utils.initializeRouterUtils(matchRoutes, stripBasename || false);
|
|
@@ -693,33 +705,6 @@ function createV6CompatibleWrapUseRoutes(origUseRoutes, version) {
|
|
|
693
705
|
return React.createElement(SentryRoutes, { routes: routes, locationArg: locationArg,} );
|
|
694
706
|
};
|
|
695
707
|
}
|
|
696
|
-
|
|
697
|
-
/**
|
|
698
|
-
* Helper to update the current span (navigation or pageload) with lazy-loaded route information.
|
|
699
|
-
* Reduces code duplication in patchRoutesOnNavigation wrapper.
|
|
700
|
-
*/
|
|
701
|
-
function updateSpanWithLazyRoutes(pathname, forceUpdate) {
|
|
702
|
-
const currentActiveRootSpan = utils.getActiveRootSpan();
|
|
703
|
-
if (!currentActiveRootSpan) {
|
|
704
|
-
return;
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
const spanOp = (core.spanToJSON(currentActiveRootSpan) ).op;
|
|
708
|
-
const location = { pathname, search: '', hash: '', state: null, key: 'default' };
|
|
709
|
-
const routesArray = Array.from(allRoutes);
|
|
710
|
-
|
|
711
|
-
if (spanOp === 'navigation') {
|
|
712
|
-
updateNavigationSpan(currentActiveRootSpan, location, routesArray, forceUpdate, _matchRoutes);
|
|
713
|
-
} else if (spanOp === 'pageload') {
|
|
714
|
-
updatePageloadTransaction({
|
|
715
|
-
activeRootSpan: currentActiveRootSpan,
|
|
716
|
-
location,
|
|
717
|
-
routes: routesArray,
|
|
718
|
-
allRoutes: routesArray,
|
|
719
|
-
});
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
|
|
723
708
|
function wrapPatchRoutesOnNavigation(
|
|
724
709
|
opts,
|
|
725
710
|
isMemoryRouter = false,
|
|
@@ -774,9 +759,25 @@ function wrapPatchRoutesOnNavigation(
|
|
|
774
759
|
}
|
|
775
760
|
}
|
|
776
761
|
|
|
777
|
-
//
|
|
778
|
-
|
|
779
|
-
|
|
762
|
+
// Use the captured activeRootSpan instead of getActiveRootSpan() to avoid race conditions
|
|
763
|
+
// where user navigates away during lazy route loading and we'd update the wrong span
|
|
764
|
+
const spanJson = activeRootSpan ? core.spanToJSON(activeRootSpan) : undefined;
|
|
765
|
+
// Only update if we have a valid targetPath (patchRoutesOnNavigation can be called without path),
|
|
766
|
+
// the captured span exists, hasn't ended, and is a navigation span
|
|
767
|
+
if (
|
|
768
|
+
targetPath &&
|
|
769
|
+
activeRootSpan &&
|
|
770
|
+
spanJson &&
|
|
771
|
+
!spanJson.timestamp && // Span hasn't ended yet
|
|
772
|
+
spanJson.op === 'navigation'
|
|
773
|
+
) {
|
|
774
|
+
updateNavigationSpan(
|
|
775
|
+
activeRootSpan,
|
|
776
|
+
{ pathname: targetPath, search: '', hash: '', state: null, key: 'default' },
|
|
777
|
+
Array.from(allRoutes),
|
|
778
|
+
true,
|
|
779
|
+
_matchRoutes,
|
|
780
|
+
);
|
|
780
781
|
}
|
|
781
782
|
return originalPatch(routeId, children);
|
|
782
783
|
};
|
|
@@ -798,9 +799,28 @@ function wrapPatchRoutesOnNavigation(
|
|
|
798
799
|
}
|
|
799
800
|
}
|
|
800
801
|
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
802
|
+
// Use the captured activeRootSpan instead of getActiveRootSpan() to avoid race conditions
|
|
803
|
+
// where user navigates away during lazy route loading and we'd update the wrong span
|
|
804
|
+
const spanJson = activeRootSpan ? core.spanToJSON(activeRootSpan) : undefined;
|
|
805
|
+
if (
|
|
806
|
+
activeRootSpan &&
|
|
807
|
+
spanJson &&
|
|
808
|
+
!spanJson.timestamp && // Span hasn't ended yet
|
|
809
|
+
spanJson.op === 'navigation'
|
|
810
|
+
) {
|
|
811
|
+
// Use targetPath consistently - don't fall back to WINDOW.location which may have changed
|
|
812
|
+
// if the user navigated away during async loading
|
|
813
|
+
const pathname = targetPath;
|
|
814
|
+
|
|
815
|
+
if (pathname) {
|
|
816
|
+
updateNavigationSpan(
|
|
817
|
+
activeRootSpan,
|
|
818
|
+
{ pathname, search: '', hash: '', state: null, key: 'default' },
|
|
819
|
+
Array.from(allRoutes),
|
|
820
|
+
false,
|
|
821
|
+
_matchRoutes,
|
|
822
|
+
);
|
|
823
|
+
}
|
|
804
824
|
}
|
|
805
825
|
|
|
806
826
|
return result;
|
|
@@ -839,6 +859,8 @@ function handleNavigation(opts
|
|
|
839
859
|
allRoutes || routes,
|
|
840
860
|
branches ,
|
|
841
861
|
basename,
|
|
862
|
+
_lazyRouteManifest,
|
|
863
|
+
_enableAsyncRouteHandlers,
|
|
842
864
|
);
|
|
843
865
|
|
|
844
866
|
const locationKey = computeLocationKey(location);
|
|
@@ -973,6 +995,8 @@ function updatePageloadTransaction({
|
|
|
973
995
|
allRoutes || routes,
|
|
974
996
|
branches,
|
|
975
997
|
basename,
|
|
998
|
+
_lazyRouteManifest,
|
|
999
|
+
_enableAsyncRouteHandlers,
|
|
976
1000
|
);
|
|
977
1001
|
|
|
978
1002
|
core.getCurrentScope().setTransactionName(name || '/');
|
|
@@ -1060,7 +1084,15 @@ function tryUpdateSpanNameBeforeEnd(
|
|
|
1060
1084
|
return;
|
|
1061
1085
|
}
|
|
1062
1086
|
|
|
1063
|
-
const [name, source] = utils.resolveRouteNameAndSource(
|
|
1087
|
+
const [name, source] = utils.resolveRouteNameAndSource(
|
|
1088
|
+
location,
|
|
1089
|
+
routesToUse,
|
|
1090
|
+
routesToUse,
|
|
1091
|
+
branches,
|
|
1092
|
+
basename,
|
|
1093
|
+
_lazyRouteManifest,
|
|
1094
|
+
_enableAsyncRouteHandlers,
|
|
1095
|
+
);
|
|
1064
1096
|
|
|
1065
1097
|
const isImprovement = shouldUpdateWildcardSpanName(currentName, currentSource, name, source, true);
|
|
1066
1098
|
const spanNotEnded = spanType === 'pageload' || !spanJson.timestamp;
|