@depup/sentry__react 10.48.0-depup.0 → 10.67.0-depup.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.
Files changed (122) hide show
  1. package/README.md +9 -3
  2. package/build/cjs/constants.js +3 -5
  3. package/build/cjs/constants.js.map +1 -1
  4. package/build/cjs/debug-build.js +0 -5
  5. package/build/cjs/debug-build.js.map +1 -1
  6. package/build/cjs/error.js +14 -77
  7. package/build/cjs/error.js.map +1 -1
  8. package/build/cjs/errorboundary.js +22 -77
  9. package/build/cjs/errorboundary.js.map +1 -1
  10. package/build/cjs/hoist-non-react-statics.js +16 -84
  11. package/build/cjs/hoist-non-react-statics.js.map +1 -1
  12. package/build/cjs/index.js +6 -0
  13. package/build/cjs/index.js.map +1 -1
  14. package/build/cjs/isSyntheticEvent.js +10 -0
  15. package/build/cjs/isSyntheticEvent.js.map +1 -0
  16. package/build/cjs/profiler.js +35 -110
  17. package/build/cjs/profiler.js.map +1 -1
  18. package/build/cjs/reactrouter-compat-utils/instrumentation.js +236 -692
  19. package/build/cjs/reactrouter-compat-utils/instrumentation.js.map +1 -1
  20. package/build/cjs/reactrouter-compat-utils/lazy-routes.js +24 -85
  21. package/build/cjs/reactrouter-compat-utils/lazy-routes.js.map +1 -1
  22. package/build/cjs/reactrouter-compat-utils/route-manifest.js +18 -96
  23. package/build/cjs/reactrouter-compat-utils/route-manifest.js.map +1 -1
  24. package/build/cjs/reactrouter-compat-utils/utils.js +82 -193
  25. package/build/cjs/reactrouter-compat-utils/utils.js.map +1 -1
  26. package/build/cjs/reactrouter.compat.js +29 -0
  27. package/build/cjs/reactrouter.compat.js.map +1 -0
  28. package/build/cjs/reactrouter.js +34 -111
  29. package/build/cjs/reactrouter.js.map +1 -1
  30. package/build/cjs/reactrouterv3.js +31 -60
  31. package/build/cjs/reactrouterv3.js.map +1 -1
  32. package/build/cjs/reactrouterv6.js +10 -42
  33. package/build/cjs/reactrouterv6.js.map +1 -1
  34. package/build/cjs/reactrouterv7.js +10 -42
  35. package/build/cjs/reactrouterv7.js.map +1 -1
  36. package/build/cjs/redux.js +61 -90
  37. package/build/cjs/redux.js.map +1 -1
  38. package/build/cjs/sdk.js +15 -10
  39. package/build/cjs/sdk.js.map +1 -1
  40. package/build/cjs/tanstackrouter.js +90 -92
  41. package/build/cjs/tanstackrouter.js.map +1 -1
  42. package/build/esm/constants.js +3 -5
  43. package/build/esm/constants.js.map +1 -1
  44. package/build/esm/debug-build.js +0 -5
  45. package/build/esm/debug-build.js.map +1 -1
  46. package/build/esm/error.js +13 -76
  47. package/build/esm/error.js.map +1 -1
  48. package/build/esm/errorboundary.js +22 -77
  49. package/build/esm/errorboundary.js.map +1 -1
  50. package/build/esm/hoist-non-react-statics.js +16 -84
  51. package/build/esm/hoist-non-react-statics.js.map +1 -1
  52. package/build/esm/index.js +1 -0
  53. package/build/esm/index.js.map +1 -1
  54. package/build/esm/isSyntheticEvent.js +8 -0
  55. package/build/esm/isSyntheticEvent.js.map +1 -0
  56. package/build/esm/package.json +1 -1
  57. package/build/esm/profiler.js +35 -110
  58. package/build/esm/profiler.js.map +1 -1
  59. package/build/esm/reactrouter-compat-utils/instrumentation.js +237 -693
  60. package/build/esm/reactrouter-compat-utils/instrumentation.js.map +1 -1
  61. package/build/esm/reactrouter-compat-utils/lazy-routes.js +24 -85
  62. package/build/esm/reactrouter-compat-utils/lazy-routes.js.map +1 -1
  63. package/build/esm/reactrouter-compat-utils/route-manifest.js +18 -96
  64. package/build/esm/reactrouter-compat-utils/route-manifest.js.map +1 -1
  65. package/build/esm/reactrouter-compat-utils/utils.js +80 -191
  66. package/build/esm/reactrouter-compat-utils/utils.js.map +1 -1
  67. package/build/esm/reactrouter.compat.js +23 -0
  68. package/build/esm/reactrouter.compat.js.map +1 -0
  69. package/build/esm/reactrouter.js +34 -111
  70. package/build/esm/reactrouter.js.map +1 -1
  71. package/build/esm/reactrouterv3.js +29 -58
  72. package/build/esm/reactrouterv3.js.map +1 -1
  73. package/build/esm/reactrouterv6.js +10 -42
  74. package/build/esm/reactrouterv6.js.map +1 -1
  75. package/build/esm/reactrouterv7.js +10 -42
  76. package/build/esm/reactrouterv7.js.map +1 -1
  77. package/build/esm/redux.js +61 -90
  78. package/build/esm/redux.js.map +1 -1
  79. package/build/esm/sdk.js +15 -10
  80. package/build/esm/sdk.js.map +1 -1
  81. package/build/esm/tanstackrouter.js +91 -93
  82. package/build/esm/tanstackrouter.js.map +1 -1
  83. package/build/types/error.d.ts.map +1 -1
  84. package/build/types/index.d.ts +1 -0
  85. package/build/types/index.d.ts.map +1 -1
  86. package/build/types/isSyntheticEvent.d.ts +10 -0
  87. package/build/types/isSyntheticEvent.d.ts.map +1 -0
  88. package/build/types/reactrouter-compat-utils/instrumentation.d.ts +1 -1
  89. package/build/types/reactrouter-compat-utils/instrumentation.d.ts.map +1 -1
  90. package/build/types/reactrouter-compat-utils/utils.d.ts +1 -1
  91. package/build/types/reactrouter-compat-utils/utils.d.ts.map +1 -1
  92. package/build/types/reactrouter.compat.d.ts +42 -0
  93. package/build/types/reactrouter.compat.d.ts.map +1 -0
  94. package/build/types/reactrouter.d.ts.map +1 -1
  95. package/build/types/reactrouterv3.d.ts +1 -1
  96. package/build/types/reactrouterv3.d.ts.map +1 -1
  97. package/build/types/reactrouterv6.d.ts +10 -0
  98. package/build/types/reactrouterv6.d.ts.map +1 -1
  99. package/build/types/reactrouterv7.d.ts +10 -0
  100. package/build/types/reactrouterv7.d.ts.map +1 -1
  101. package/build/types/redux.d.ts +1 -1
  102. package/build/types/redux.d.ts.map +1 -1
  103. package/build/types/sdk.d.ts +1 -1
  104. package/build/types/sdk.d.ts.map +1 -1
  105. package/build/types/tanstackrouter.d.ts +1 -1
  106. package/build/types/tanstackrouter.d.ts.map +1 -1
  107. package/build/types/vendor/tanstackrouter-types.d.ts +2 -1
  108. package/build/types/vendor/tanstackrouter-types.d.ts.map +1 -1
  109. package/build/types-ts3.8/index.d.ts +1 -0
  110. package/build/types-ts3.8/isSyntheticEvent.d.ts +10 -0
  111. package/build/types-ts3.8/reactrouter-compat-utils/instrumentation.d.ts +1 -1
  112. package/build/types-ts3.8/reactrouter-compat-utils/utils.d.ts +1 -1
  113. package/build/types-ts3.8/reactrouter.compat.d.ts +42 -0
  114. package/build/types-ts3.8/reactrouterv3.d.ts +1 -1
  115. package/build/types-ts3.8/reactrouterv6.d.ts +10 -0
  116. package/build/types-ts3.8/reactrouterv7.d.ts +10 -0
  117. package/build/types-ts3.8/redux.d.ts +1 -1
  118. package/build/types-ts3.8/sdk.d.ts +1 -1
  119. package/build/types-ts3.8/tanstackrouter.d.ts +1 -1
  120. package/build/types-ts3.8/vendor/tanstackrouter-types.d.ts +2 -1
  121. package/changes.json +8 -3
  122. package/package.json +18 -8
@@ -1,186 +1,132 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
- const core = require('@sentry/core');
3
+ const browser = require('@sentry/core/browser');
4
4
  const debugBuild = require('../debug-build.js');
5
5
  const routeManifest = require('./route-manifest.js');
6
6
 
7
- // Global variables that these utilities depend on
8
7
  let _matchRoutes;
9
8
  let _stripBasename = false;
10
-
11
- // Navigation context stack for nested/concurrent patchRoutesOnNavigation calls.
12
- // Required because window.location hasn't updated yet when handlers are invoked.
13
-
14
9
  const _navigationContextStack = [];
15
10
  const MAX_CONTEXT_STACK_SIZE = 10;
16
-
17
- /**
18
- * Pushes a navigation context and returns a unique token for cleanup.
19
- * The token uses object identity for uniqueness (no counter needed).
20
- */
21
11
  function setNavigationContext(targetPath, span) {
22
12
  const token = {};
23
- // Prevent unbounded stack growth - oldest (likely stale) contexts are evicted first
24
13
  if (_navigationContextStack.length >= MAX_CONTEXT_STACK_SIZE) {
25
- debugBuild.DEBUG_BUILD && core.debug.warn('[React Router] Navigation context stack overflow - removing oldest context');
14
+ debugBuild.DEBUG_BUILD && browser.debug.warn("[React Router] Navigation context stack overflow - removing oldest context");
26
15
  _navigationContextStack.shift();
27
16
  }
28
17
  _navigationContextStack.push({ token, targetPath, span });
29
18
  return token;
30
19
  }
31
-
32
- /**
33
- * Clears the navigation context if it's on top of the stack (LIFO).
34
- * If our context is not on top (out-of-order completion), we leave it -
35
- * it will be cleaned up by overflow protection when the stack fills up.
36
- */
37
20
  function clearNavigationContext(token) {
38
21
  const top = _navigationContextStack[_navigationContextStack.length - 1];
39
22
  if (top?.token === token) {
40
23
  _navigationContextStack.pop();
41
24
  }
42
25
  }
43
-
44
- /** Gets the current (most recent) navigation context if inside a patchRoutesOnNavigation call. */
45
26
  function getNavigationContext() {
46
27
  const length = _navigationContextStack.length;
47
- // The `?? null` converts undefined (from array access) to null to match return type
48
- return length > 0 ? (_navigationContextStack[length - 1] ?? null) : null;
28
+ return length > 0 ? _navigationContextStack[length - 1] ?? null : null;
49
29
  }
50
-
51
- /**
52
- * Initialize function to set dependencies that the router utilities need.
53
- * Must be called before using any of the exported utility functions.
54
- */
55
30
  function initializeRouterUtils(matchRoutes, stripBasename = false) {
56
31
  _matchRoutes = matchRoutes;
57
32
  _stripBasename = stripBasename;
58
33
  }
59
-
60
- // Helper functions
61
34
  function pickPath(match) {
62
- return trimWildcard(match.route.path || '');
35
+ return trimWildcard(match.route.path || "");
63
36
  }
64
-
65
37
  function pickSplat(match) {
66
- return match.params['*'] || '';
38
+ return match.params["*"] || "";
67
39
  }
68
-
69
40
  function trimWildcard(path) {
70
- return path[path.length - 1] === '*' ? path.slice(0, -1) : path;
41
+ return path[path.length - 1] === "*" ? path.slice(0, -1) : path;
71
42
  }
72
-
73
43
  function trimSlash(path) {
74
- return path[path.length - 1] === '/' ? path.slice(0, -1) : path;
44
+ return path[path.length - 1] === "/" ? path.slice(0, -1) : path;
75
45
  }
76
-
77
- /**
78
- * Checks if a path ends with a wildcard character (*).
79
- */
80
46
  function pathEndsWithWildcard(path) {
81
- return path.endsWith('*');
47
+ return path.endsWith("*");
82
48
  }
83
-
84
- /** Checks if transaction name has wildcard (/* or ends with *). */
85
49
  function transactionNameHasWildcard(name) {
86
- return name.includes('/*') || name.endsWith('*');
50
+ return name.includes("/*") || name.endsWith("*");
87
51
  }
88
-
89
- /**
90
- * Checks if a path is a wildcard and has child routes.
91
- */
92
52
  function pathIsWildcardAndHasChildren(path, branch) {
93
- return (pathEndsWithWildcard(path) && !!branch.route.children?.length) || false;
53
+ return pathEndsWithWildcard(path) && !!branch.route.children?.length || false;
94
54
  }
95
-
96
- /** Check if route is in descendant route (<Routes> within <Routes>) */
97
55
  function routeIsDescendant(route) {
98
- return !!(!route.children && route.element && route.path?.endsWith('/*'));
56
+ return !!(!route.children && route.element && route.path?.endsWith("/*"));
99
57
  }
100
-
101
58
  function sendIndexPath(pathBuilder, pathname, basename) {
102
- const reconstructedPath =
103
- pathBuilder && pathBuilder.length > 0
104
- ? pathBuilder
105
- : _stripBasename
106
- ? routeManifest.stripBasenameFromPathname(pathname, basename)
107
- : pathname;
108
-
109
- let formattedPath =
59
+ const reconstructedPath = pathBuilder && pathBuilder.length > 0 ? pathBuilder : _stripBasename ? routeManifest.stripBasenameFromPathname(pathname, basename) : pathname;
60
+ let formattedPath = (
110
61
  // If the path ends with a wildcard suffix, remove both the slash and the asterisk
111
- reconstructedPath.slice(-2) === '/*' ? reconstructedPath.slice(0, -2) : reconstructedPath;
112
-
113
- // If the path ends with a slash, remove it (but keep single '/')
114
- if (formattedPath.length > 1 && formattedPath[formattedPath.length - 1] === '/') {
62
+ reconstructedPath.slice(-2) === "/*" ? reconstructedPath.slice(0, -2) : reconstructedPath
63
+ );
64
+ if (formattedPath.length > 1 && formattedPath[formattedPath.length - 1] === "/") {
115
65
  formattedPath = formattedPath.slice(0, -1);
116
66
  }
117
-
118
- return [formattedPath, 'route'];
67
+ return [formattedPath, "route"];
119
68
  }
120
-
121
- /**
122
- * Returns the number of URL segments in the given URL string.
123
- * Splits at '/' or '\/' to handle regex URLs correctly.
124
- *
125
- * @param url - The URL string to segment.
126
- * @returns The number of segments in the URL.
127
- */
128
69
  function getNumberOfUrlSegments(url) {
129
- // split at '/' or at '\/' to split regex urls correctly
130
- return url.split(/\\?\//).filter(s => s.length > 0 && s !== ',').length;
70
+ return url.split(/\\?\//).filter((s) => s.length > 0 && s !== ",").length;
131
71
  }
132
-
133
- // Exported utility functions
134
-
135
- /**
136
- * Ensures a path string starts with a forward slash.
137
- */
138
72
  function prefixWithSlash(path) {
139
- return path[0] === '/' ? path : `/${path}`;
73
+ return path[0] === "/" ? path : `/${path}`;
140
74
  }
141
-
142
- /**
143
- * Rebuilds the route path from all available routes by matching against the current location.
144
- */
145
75
  function rebuildRoutePathFromAllRoutes(allRoutes, location) {
146
- const matchedRoutes = _matchRoutes(allRoutes, location) ;
147
-
76
+ const matchedRoutes = _matchRoutes(allRoutes, location);
148
77
  if (!matchedRoutes || matchedRoutes.length === 0) {
149
- return '';
78
+ return "";
150
79
  }
151
-
152
80
  for (const match of matchedRoutes) {
153
- if (match.route.path && match.route.path !== '*') {
81
+ if (match.route.path && match.route.path !== "*") {
154
82
  const path = pickPath(match);
155
83
  const strippedPath = routeManifest.stripBasenameFromPathname(location.pathname, prefixWithSlash(match.pathnameBase));
156
-
157
84
  if (location.pathname === strippedPath) {
158
85
  return trimSlash(strippedPath);
159
86
  }
160
-
161
87
  return trimSlash(
162
- trimSlash(path || '') +
163
- prefixWithSlash(
164
- rebuildRoutePathFromAllRoutes(
165
- allRoutes.filter(route => route !== match.route),
166
- {
167
- pathname: strippedPath,
168
- },
169
- ),
170
- ),
88
+ trimSlash(path || "") + prefixWithSlash(
89
+ rebuildRoutePathFromAllRoutes(
90
+ allRoutes.filter((route) => route !== match.route),
91
+ {
92
+ pathname: strippedPath
93
+ }
94
+ )
95
+ )
171
96
  );
172
97
  }
173
98
  }
174
-
175
- return '';
99
+ return "";
100
+ }
101
+ function reconstructNameFromDescendantParent(location, allRoutes, currentName) {
102
+ const descendantParents = allRoutes.filter(routeIsDescendant);
103
+ if (!descendantParents.length) {
104
+ return void 0;
105
+ }
106
+ const matchedParents = _matchRoutes(descendantParents, location);
107
+ const parentMatch = matchedParents?.[matchedParents.length - 1];
108
+ if (!parentMatch || !pickSplat(parentMatch)) {
109
+ return void 0;
110
+ }
111
+ const parentTemplate = trimSlash(trimWildcard(parentMatch.route.path || ""));
112
+ if (!parentTemplate) {
113
+ return void 0;
114
+ }
115
+ const expectedPrefix = prefixWithSlash(parentTemplate);
116
+ const firstElement = parentTemplate.split("/")[0];
117
+ const hasDynamicLead = firstElement?.startsWith(":") && currentName?.split("/").includes(firstElement);
118
+ if (currentName === expectedPrefix || currentName?.startsWith(`${expectedPrefix}/`) || hasDynamicLead) {
119
+ return void 0;
120
+ }
121
+ const remainingPathname = routeManifest.stripBasenameFromPathname(location.pathname, prefixWithSlash(parentMatch.pathnameBase)) || "/";
122
+ const remainingName = rebuildRoutePathFromAllRoutes(
123
+ allRoutes.filter((route) => route !== parentMatch.route),
124
+ { pathname: remainingPathname }
125
+ );
126
+ return remainingName ? prefixWithSlash(`${parentTemplate}${prefixWithSlash(remainingName)}`) : void 0;
176
127
  }
177
-
178
- /**
179
- * Checks if the current location is inside a descendant route (route with splat parameter).
180
- */
181
128
  function locationIsInsideDescendantRoute(location, routes) {
182
- const matchedRoutes = _matchRoutes(routes, location) ;
183
-
129
+ const matchedRoutes = _matchRoutes(routes, location);
184
130
  if (matchedRoutes) {
185
131
  for (const match of matchedRoutes) {
186
132
  if (routeIsDescendant(match.route) && pickSplat(match)) {
@@ -188,134 +134,77 @@ function locationIsInsideDescendantRoute(location, routes) {
188
134
  }
189
135
  }
190
136
  }
191
-
192
137
  return false;
193
138
  }
194
-
195
- /**
196
- * Returns a fallback transaction name from location pathname.
197
- */
198
139
  function getFallbackTransactionName(location, basename) {
199
- return _stripBasename ? routeManifest.stripBasenameFromPathname(location.pathname, basename) : location.pathname || '';
140
+ return _stripBasename ? routeManifest.stripBasenameFromPathname(location.pathname, basename) : location.pathname || "";
200
141
  }
201
-
202
- /**
203
- * Gets a normalized route name and transaction source from the current routes and location.
204
- */
205
- function getNormalizedName(
206
- routes,
207
- location,
208
- branches,
209
- basename = '',
210
- ) {
142
+ function getNormalizedName(routes, location, branches, basename = "") {
211
143
  if (!routes || routes.length === 0) {
212
- return [_stripBasename ? routeManifest.stripBasenameFromPathname(location.pathname, basename) : location.pathname, 'url'];
144
+ return [_stripBasename ? routeManifest.stripBasenameFromPathname(location.pathname, basename) : location.pathname, "url"];
213
145
  }
214
-
215
146
  if (!branches) {
216
- return [getFallbackTransactionName(location, basename), 'url'];
147
+ return [getFallbackTransactionName(location, basename), "url"];
217
148
  }
218
-
219
- let pathBuilder = '';
220
-
149
+ let pathBuilder = "";
221
150
  for (const branch of branches) {
222
151
  const route = branch.route;
223
152
  if (!route) {
224
153
  continue;
225
154
  }
226
-
227
- // Early return for index routes
228
155
  if (route.index) {
229
156
  return sendIndexPath(pathBuilder, branch.pathname, basename);
230
157
  }
231
-
232
158
  const path = route.path;
233
159
  if (!path || pathIsWildcardAndHasChildren(path, branch)) {
234
160
  continue;
235
161
  }
236
-
237
- // Build the route path
238
- const newPath = path[0] === '/' || pathBuilder[pathBuilder.length - 1] === '/' ? path : `/${path}`;
162
+ const newPath = path[0] === "/" || pathBuilder[pathBuilder.length - 1] === "/" ? path : `/${path}`;
239
163
  pathBuilder = trimSlash(pathBuilder) + prefixWithSlash(newPath);
240
-
241
- // Check if this path matches the current location
242
164
  if (trimSlash(location.pathname) !== trimSlash(basename + branch.pathname)) {
243
165
  continue;
244
166
  }
245
-
246
- // Check if this is a parameterized route like /stores/:storeId/products/:productId
247
- if (
248
- getNumberOfUrlSegments(pathBuilder) !== getNumberOfUrlSegments(branch.pathname) &&
249
- !pathEndsWithWildcard(pathBuilder)
250
- ) {
251
- return [(_stripBasename ? '' : basename) + newPath, 'route'];
167
+ if (getNumberOfUrlSegments(pathBuilder) !== getNumberOfUrlSegments(branch.pathname) && !pathEndsWithWildcard(pathBuilder)) {
168
+ return [(_stripBasename ? "" : basename) + newPath, "route"];
252
169
  }
253
-
254
- // Handle wildcard routes with children - strip trailing wildcard
255
170
  if (pathIsWildcardAndHasChildren(pathBuilder, branch)) {
256
171
  pathBuilder = pathBuilder.slice(0, -1);
257
172
  }
258
-
259
- return [(_stripBasename ? '' : basename) + pathBuilder, 'route'];
173
+ return [(_stripBasename ? "" : basename) + pathBuilder, "route"];
260
174
  }
261
-
262
- // Fallback when no matching route found
263
- return [getFallbackTransactionName(location, basename), 'url'];
175
+ return [getFallbackTransactionName(location, basename), "url"];
264
176
  }
265
-
266
- /**
267
- * Shared helper function to resolve route name and source
268
- */
269
- function resolveRouteNameAndSource(
270
- location,
271
- routes,
272
- allRoutes,
273
- branches,
274
- basename = '',
275
- lazyRouteManifest,
276
- enableAsyncRouteHandlers,
277
- ) {
278
- // When lazy route manifest is provided, use it as the primary source for transaction names
177
+ function resolveRouteNameAndSource(location, routes, allRoutes, branches, basename = "", lazyRouteManifest, enableAsyncRouteHandlers) {
279
178
  if (enableAsyncRouteHandlers && lazyRouteManifest && lazyRouteManifest.length > 0) {
280
179
  const manifestMatch = routeManifest.matchRouteManifest(location.pathname, lazyRouteManifest, basename);
281
180
  if (manifestMatch) {
282
- return [(_stripBasename ? '' : basename) + manifestMatch, 'route'];
181
+ return [(_stripBasename ? "" : basename) + manifestMatch, "route"];
283
182
  }
284
183
  }
285
-
286
- // Fall back to React Router route matching
287
184
  let name;
288
- let source = 'url';
289
-
185
+ let source = "url";
290
186
  const isInDescendantRoute = locationIsInsideDescendantRoute(location, allRoutes);
291
-
292
187
  if (isInDescendantRoute) {
293
188
  name = prefixWithSlash(rebuildRoutePathFromAllRoutes(allRoutes, location));
294
- source = 'route';
189
+ source = "route";
295
190
  }
296
-
297
191
  if (!isInDescendantRoute || !name) {
298
192
  [name, source] = getNormalizedName(routes, location, branches, basename);
299
193
  }
300
-
194
+ const anchoredName = reconstructNameFromDescendantParent(location, allRoutes, name);
195
+ if (anchoredName) {
196
+ return [anchoredName, "route"];
197
+ }
301
198
  return [name || location.pathname, source];
302
199
  }
303
-
304
- /**
305
- * Gets the active root span if it's a pageload or navigation span.
306
- */
307
200
  function getActiveRootSpan() {
308
- const span = core.getActiveSpan();
309
- const rootSpan = span ? core.getRootSpan(span) : undefined;
310
-
201
+ const span = browser.getActiveSpan();
202
+ const rootSpan = span ? browser.getRootSpan(span) : void 0;
311
203
  if (!rootSpan) {
312
- return undefined;
204
+ return void 0;
313
205
  }
314
-
315
- const op = core.spanToJSON(rootSpan).op;
316
-
317
- // Only use this root span if it is a pageload or navigation span
318
- return op === 'navigation' || op === 'pageload' ? rootSpan : undefined;
206
+ const op = browser.spanToJSON(rootSpan).op;
207
+ return op === "navigation" || op === "pageload" ? rootSpan : void 0;
319
208
  }
320
209
 
321
210
  exports.clearNavigationContext = clearNavigationContext;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../src/reactrouter-compat-utils/utils.ts"],"sourcesContent":["import type { Span, TransactionSource } from '@sentry/core';\nimport { debug, getActiveSpan, getRootSpan, spanToJSON } from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { Location, MatchRoutes, RouteMatch, RouteObject } from '../types';\nimport { matchRouteManifest, stripBasenameFromPathname } from './route-manifest';\n\n// Global variables that these utilities depend on\nlet _matchRoutes: MatchRoutes;\nlet _stripBasename: boolean = false;\n\n// Navigation context stack for nested/concurrent patchRoutesOnNavigation calls.\n// Required because window.location hasn't updated yet when handlers are invoked.\ninterface NavigationContext {\n token: object;\n targetPath: string | undefined;\n span: Span | undefined;\n}\n\nconst _navigationContextStack: NavigationContext[] = [];\nconst MAX_CONTEXT_STACK_SIZE = 10;\n\n/**\n * Pushes a navigation context and returns a unique token for cleanup.\n * The token uses object identity for uniqueness (no counter needed).\n */\nexport function setNavigationContext(targetPath: string | undefined, span: Span | undefined): object {\n const token = {};\n // Prevent unbounded stack growth - oldest (likely stale) contexts are evicted first\n if (_navigationContextStack.length >= MAX_CONTEXT_STACK_SIZE) {\n DEBUG_BUILD && debug.warn('[React Router] Navigation context stack overflow - removing oldest context');\n _navigationContextStack.shift();\n }\n _navigationContextStack.push({ token, targetPath, span });\n return token;\n}\n\n/**\n * Clears the navigation context if it's on top of the stack (LIFO).\n * If our context is not on top (out-of-order completion), we leave it -\n * it will be cleaned up by overflow protection when the stack fills up.\n */\nexport function clearNavigationContext(token: object): void {\n const top = _navigationContextStack[_navigationContextStack.length - 1];\n if (top?.token === token) {\n _navigationContextStack.pop();\n }\n}\n\n/** Gets the current (most recent) navigation context if inside a patchRoutesOnNavigation call. */\nexport function getNavigationContext(): NavigationContext | null {\n const length = _navigationContextStack.length;\n // The `?? null` converts undefined (from array access) to null to match return type\n return length > 0 ? (_navigationContextStack[length - 1] ?? null) : null;\n}\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// 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/** Checks if transaction name has wildcard (/* or ends with *). */\nexport function transactionNameHasWildcard(name: string): boolean {\n return name.includes('/*') || name.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\n/** Check if route is in descendant route (<Routes> within <Routes>) */\nexport function 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 =\n pathBuilder && pathBuilder.length > 0\n ? pathBuilder\n : _stripBasename\n ? stripBasenameFromPathname(pathname, basename)\n : pathname;\n\n let formattedPath =\n // If the path ends with a wildcard suffix, remove both the slash and the asterisk\n reconstructedPath.slice(-2) === '/*' ? reconstructedPath.slice(0, -2) : reconstructedPath;\n\n // If the path ends with a slash, remove it (but keep single '/')\n if (formattedPath.length > 1 && formattedPath[formattedPath.length - 1] === '/') {\n formattedPath = formattedPath.slice(0, -1);\n }\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// 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 * Returns a fallback transaction name from location pathname.\n */\nfunction getFallbackTransactionName(location: Location, basename: string): string {\n return _stripBasename ? stripBasenameFromPathname(location.pathname, basename) : location.pathname || '';\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 if (!branches) {\n return [getFallbackTransactionName(location, basename), 'url'];\n }\n\n let pathBuilder = '';\n\n for (const branch of branches) {\n const route = branch.route;\n if (!route) {\n continue;\n }\n\n // Early return for index routes\n if (route.index) {\n return sendIndexPath(pathBuilder, branch.pathname, basename);\n }\n\n const path = route.path;\n if (!path || pathIsWildcardAndHasChildren(path, branch)) {\n continue;\n }\n\n // Build the route path\n const newPath = path[0] === '/' || pathBuilder[pathBuilder.length - 1] === '/' ? path : `/${path}`;\n pathBuilder = trimSlash(pathBuilder) + prefixWithSlash(newPath);\n\n // Check if this path matches the current location\n if (trimSlash(location.pathname) !== trimSlash(basename + branch.pathname)) {\n continue;\n }\n\n // Check if this is a parameterized route like /stores/:storeId/products/:productId\n if (\n getNumberOfUrlSegments(pathBuilder) !== getNumberOfUrlSegments(branch.pathname) &&\n !pathEndsWithWildcard(pathBuilder)\n ) {\n return [(_stripBasename ? '' : basename) + newPath, 'route'];\n }\n\n // Handle wildcard routes with children - strip trailing wildcard\n if (pathIsWildcardAndHasChildren(pathBuilder, branch)) {\n pathBuilder = pathBuilder.slice(0, -1);\n }\n\n return [(_stripBasename ? '' : basename) + pathBuilder, 'route'];\n }\n\n // Fallback when no matching route found\n return [getFallbackTransactionName(location, basename), '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 lazyRouteManifest?: string[],\n enableAsyncRouteHandlers?: boolean,\n): [string, TransactionSource] {\n // When lazy route manifest is provided, use it as the primary source for transaction names\n if (enableAsyncRouteHandlers && lazyRouteManifest && lazyRouteManifest.length > 0) {\n const manifestMatch = matchRouteManifest(location.pathname, lazyRouteManifest, basename);\n if (manifestMatch) {\n return [(_stripBasename ? '' : basename) + manifestMatch, 'route'];\n }\n }\n\n // Fall back to React Router route matching\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.pathname, source];\n}\n\n/**\n * Gets the active root span if it's a pageload or navigation span.\n */\nexport function 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"],"names":["DEBUG_BUILD","debug","stripBasenameFromPathname","matchRouteManifest","getActiveSpan","getRootSpan","spanToJSON"],"mappings":";;;;;;AAMA;AACA,IAAI,YAAY;AAChB,IAAI,cAAc,GAAY,KAAK;;AAEnC;AACA;;AAOA,MAAM,uBAAuB,GAAwB,EAAE;AACvD,MAAM,sBAAA,GAAyB,EAAE;;AAEjC;AACA;AACA;AACA;AACO,SAAS,oBAAoB,CAAC,UA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AAA,EAAA,SAAA,CAAA;;AAEA,EAAA,IAAA,mBAAA,EAAA;AACA,IAAA,IAAA,GAAA,eAAA,CAAA,6BAAA,CAAA,SAAA,EAAA,QAAA,CAAA,CAAA;AACA,IAAA,MAAA,GAAA,OAAA;AACA,EAAA;;AAEA,EAAA,IAAA,CAAA,mBAAA,IAAA,CAAA,IAAA,EAAA;AACA,IAAA,CAAA,IAAA,EAAA,MAAA,CAAA,GAAA,iBAAA,CAAA,MAAA,EAAA,QAAA,EAAA,QAAA,EAAA,QAAA,CAAA;AACA,EAAA;;AAEA,EAAA,OAAA,CAAA,IAAA,IAAA,QAAA,CAAA,QAAA,EAAA,MAAA,CAAA;AACA;;AAEA;AACA;AACA;AACA,SAAA,iBAAA,GAAA;AACA,EAAA,MAAA,IAAA,GAAAC,kBAAA,EAAA;AACA,EAAA,MAAA,QAAA,GAAA,IAAA,GAAAC,gBAAA,CAAA,IAAA,CAAA,GAAA,SAAA;;AAEA,EAAA,IAAA,CAAA,QAAA,EAAA;AACA,IAAA,OAAA,SAAA;AACA,EAAA;;AAEA,EAAA,MAAA,EAAA,GAAAC,eAAA,CAAA,QAAA,CAAA,CAAA,EAAA;;AAEA;AACA,EAAA,OAAA,EAAA,KAAA,YAAA,IAAA,EAAA,KAAA,UAAA,GAAA,QAAA,GAAA,SAAA;AACA;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"utils.js","sources":["../../../src/reactrouter-compat-utils/utils.ts"],"sourcesContent":["import type { Span, TransactionSource } from '@sentry/core/browser';\nimport { debug, getActiveSpan, getRootSpan, spanToJSON } from '@sentry/core/browser';\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { Location, MatchRoutes, RouteMatch, RouteObject } from '../types';\nimport { matchRouteManifest, stripBasenameFromPathname } from './route-manifest';\n\n// Global variables that these utilities depend on\nlet _matchRoutes: MatchRoutes;\nlet _stripBasename: boolean = false;\n\n// Navigation context stack for nested/concurrent patchRoutesOnNavigation calls.\n// Required because window.location hasn't updated yet when handlers are invoked.\ninterface NavigationContext {\n token: object;\n targetPath: string | undefined;\n span: Span | undefined;\n}\n\nconst _navigationContextStack: NavigationContext[] = [];\nconst MAX_CONTEXT_STACK_SIZE = 10;\n\n/**\n * Pushes a navigation context and returns a unique token for cleanup.\n * The token uses object identity for uniqueness (no counter needed).\n */\nexport function setNavigationContext(targetPath: string | undefined, span: Span | undefined): object {\n const token = {};\n // Prevent unbounded stack growth - oldest (likely stale) contexts are evicted first\n if (_navigationContextStack.length >= MAX_CONTEXT_STACK_SIZE) {\n DEBUG_BUILD && debug.warn('[React Router] Navigation context stack overflow - removing oldest context');\n _navigationContextStack.shift();\n }\n _navigationContextStack.push({ token, targetPath, span });\n return token;\n}\n\n/**\n * Clears the navigation context if it's on top of the stack (LIFO).\n * If our context is not on top (out-of-order completion), we leave it -\n * it will be cleaned up by overflow protection when the stack fills up.\n */\nexport function clearNavigationContext(token: object): void {\n const top = _navigationContextStack[_navigationContextStack.length - 1];\n if (top?.token === token) {\n _navigationContextStack.pop();\n }\n}\n\n/** Gets the current (most recent) navigation context if inside a patchRoutesOnNavigation call. */\nexport function getNavigationContext(): NavigationContext | null {\n const length = _navigationContextStack.length;\n // The `?? null` converts undefined (from array access) to null to match return type\n return length > 0 ? (_navigationContextStack[length - 1] ?? null) : null;\n}\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// 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/** Checks if transaction name has wildcard (/* or ends with *). */\nexport function transactionNameHasWildcard(name: string): boolean {\n return name.includes('/*') || name.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\n/** Check if route is in descendant route (<Routes> within <Routes>) */\nexport function 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 =\n pathBuilder && pathBuilder.length > 0\n ? pathBuilder\n : _stripBasename\n ? stripBasenameFromPathname(pathname, basename)\n : pathname;\n\n let formattedPath =\n // If the path ends with a wildcard suffix, remove both the slash and the asterisk\n reconstructedPath.slice(-2) === '/*' ? reconstructedPath.slice(0, -2) : reconstructedPath;\n\n // If the path ends with a slash, remove it (but keep single '/')\n if (formattedPath.length > 1 && formattedPath[formattedPath.length - 1] === '/') {\n formattedPath = formattedPath.slice(0, -1);\n }\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// 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 * Recovers the parent prefix for descendant `<Routes>` names.\n *\n * `allRoutes` flattens every mounted `<Routes>` into one set, so an orphaned descendant subtree can\n * outscore the `.../*` route that anchors the location and drop its prefix (e.g. `/:id/:sub` instead of `/child/:id`).\n * Matching only the descendant-parent routes recovers the true anchor.\n */\nfunction reconstructNameFromDescendantParent(\n location: Location,\n allRoutes: RouteObject[],\n currentName: string | undefined,\n): string | undefined {\n const descendantParents = allRoutes.filter(routeIsDescendant);\n if (!descendantParents.length) {\n return undefined;\n }\n\n const matchedParents = _matchRoutes(descendantParents, location) as RouteMatch[] | null;\n const parentMatch = matchedParents?.[matchedParents.length - 1];\n if (!parentMatch || !pickSplat(parentMatch)) {\n return undefined;\n }\n\n const parentTemplate = trimSlash(trimWildcard(parentMatch.route.path || ''));\n\n if (!parentTemplate) {\n return undefined;\n }\n\n const expectedPrefix = prefixWithSlash(parentTemplate);\n\n // Child `<Routes>` resolve against the matched parent, but flattened route matching can already retain\n // a dynamic leading parameter. Adding the parent again would duplicate it (e.g. `/:id/:id`)\n const firstElement = parentTemplate.split('/')[0];\n const hasDynamicLead = firstElement?.startsWith(':') && currentName?.split('/').includes(firstElement);\n\n // Rebuild only when matching the descendant subtree discarded its parent route template\n if (currentName === expectedPrefix || currentName?.startsWith(`${expectedPrefix}/`) || hasDynamicLead) {\n return undefined;\n }\n\n const remainingPathname =\n stripBasenameFromPathname(location.pathname, prefixWithSlash(parentMatch.pathnameBase)) || '/';\n const remainingName = rebuildRoutePathFromAllRoutes(\n allRoutes.filter(route => route !== parentMatch.route),\n { pathname: remainingPathname },\n );\n\n return remainingName ? prefixWithSlash(`${parentTemplate}${prefixWithSlash(remainingName)}`) : undefined;\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 * Returns a fallback transaction name from location pathname.\n */\nfunction getFallbackTransactionName(location: Location, basename: string): string {\n return _stripBasename ? stripBasenameFromPathname(location.pathname, basename) : location.pathname || '';\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 if (!branches) {\n return [getFallbackTransactionName(location, basename), 'url'];\n }\n\n let pathBuilder = '';\n\n for (const branch of branches) {\n const route = branch.route;\n if (!route) {\n continue;\n }\n\n // Early return for index routes\n if (route.index) {\n return sendIndexPath(pathBuilder, branch.pathname, basename);\n }\n\n const path = route.path;\n if (!path || pathIsWildcardAndHasChildren(path, branch)) {\n continue;\n }\n\n // Build the route path\n const newPath = path[0] === '/' || pathBuilder[pathBuilder.length - 1] === '/' ? path : `/${path}`;\n pathBuilder = trimSlash(pathBuilder) + prefixWithSlash(newPath);\n\n // Check if this path matches the current location\n if (trimSlash(location.pathname) !== trimSlash(basename + branch.pathname)) {\n continue;\n }\n\n // Check if this is a parameterized route like /stores/:storeId/products/:productId\n if (\n getNumberOfUrlSegments(pathBuilder) !== getNumberOfUrlSegments(branch.pathname) &&\n !pathEndsWithWildcard(pathBuilder)\n ) {\n return [(_stripBasename ? '' : basename) + newPath, 'route'];\n }\n\n // Handle wildcard routes with children - strip trailing wildcard\n if (pathIsWildcardAndHasChildren(pathBuilder, branch)) {\n pathBuilder = pathBuilder.slice(0, -1);\n }\n\n return [(_stripBasename ? '' : basename) + pathBuilder, 'route'];\n }\n\n // Fallback when no matching route found\n return [getFallbackTransactionName(location, basename), '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 lazyRouteManifest?: string[],\n enableAsyncRouteHandlers?: boolean,\n): [string, TransactionSource] {\n // When lazy route manifest is provided, use it as the primary source for transaction names\n if (enableAsyncRouteHandlers && lazyRouteManifest && lazyRouteManifest.length > 0) {\n const manifestMatch = matchRouteManifest(location.pathname, lazyRouteManifest, basename);\n if (manifestMatch) {\n return [(_stripBasename ? '' : basename) + manifestMatch, 'route'];\n }\n }\n\n // Fall back to React Router route matching\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 // Guard against orphaned descendant subtrees stealing the transaction name: if the location is\n // anchored by a descendant-parent route (`.../*`) whose prefix was dropped, reconstruct with it.\n const anchoredName = reconstructNameFromDescendantParent(location, allRoutes, name);\n if (anchoredName) {\n return [anchoredName, 'route'];\n }\n\n return [name || location.pathname, source];\n}\n\n/**\n * Gets the active root span if it's a pageload or navigation span.\n */\nexport function 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"],"names":["DEBUG_BUILD","debug","stripBasenameFromPathname","matchRouteManifest","getActiveSpan","getRootSpan","spanToJSON"],"mappings":";;;;;;AAOA,IAAI,YAAA;AACJ,IAAI,cAAA,GAA0B,KAAA;AAU9B,MAAM,0BAA+C,EAAC;AACtD,MAAM,sBAAA,GAAyB,EAAA;AAMxB,SAAS,oBAAA,CAAqB,YAAgC,IAAA,EAAgC;AACnG,EAAA,MAAM,QAAQ,EAAC;AAEf,EAAA,IAAI,uBAAA,CAAwB,UAAU,sBAAA,EAAwB;AAC5D,IAAAA,sBAAA,IAAeC,aAAA,CAAM,KAAK,4EAA4E,CAAA;AACtG,IAAA,uBAAA,CAAwB,KAAA,EAAM;AAAA,EAChC;AACA,EAAA,uBAAA,CAAwB,IAAA,CAAK,EAAE,KAAA,EAAO,UAAA,EAAY,MAAM,CAAA;AACxD,EAAA,OAAO,KAAA;AACT;AAOO,SAAS,uBAAuB,KAAA,EAAqB;AAC1D,EAAA,MAAM,GAAA,GAAM,uBAAA,CAAwB,uBAAA,CAAwB,MAAA,GAAS,CAAC,CAAA;AACtE,EAAA,IAAI,GAAA,EAAK,UAAU,KAAA,EAAO;AACxB,IAAA,uBAAA,CAAwB,GAAA,EAAI;AAAA,EAC9B;AACF;AAGO,SAAS,oBAAA,GAAiD;AAC/D,EAAA,MAAM,SAAS,uBAAA,CAAwB,MAAA;AAEvC,EAAA,OAAO,SAAS,CAAA,GAAK,uBAAA,CAAwB,MAAA,GAAS,CAAC,KAAK,IAAA,GAAQ,IAAA;AACtE;AAMO,SAAS,qBAAA,CAAsB,WAAA,EAA0B,aAAA,GAAyB,KAAA,EAAa;AACpG,EAAA,YAAA,GAAe,WAAA;AACf,EAAA,cAAA,GAAiB,aAAA;AACnB;AAGA,SAAS,SAAS,KAAA,EAA2B;AAC3C,EAAA,OAAO,YAAA,CAAa,KAAA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AS,OAAA;AAAA,EACX;AAEA,EAAA,IAAI,CAAC,mBAAA,IAAuB,CAAC,IAAA,EAAM;AACjC,IAAA,CAAC,MAAM,MAAM,CAAA,GAAI,kBAAkB,MAAA,EAAQ,QAAA,EAAU,UAAU,QAAQ,CAAA;AAAA,EACzE;AAIA,EAAA,MAAM,YAAA,GAAe,mCAAA,CAAoC,QAAA,EAAU,SAAA,EAAW,IAAI,CAAA;AAClF,EAAA,IAAI,YAAA,EAAc;AAChB,IAAA,OAAO,CAAC,cAAc,OAAO,CAAA;AAAA,EAC/B;AAEA,EAAA,OAAO,CAAC,IAAA,IAAQ,QAAA,CAAS,QAAA,EAAU,MAAM,CAAA;AAC3C;AAKO,SAAS,iBAAA,GAAsC;AACpD,EAAA,MAAM,OAAOC,qBAAA,EAAc;AAC3B,EAAA,MAAM,QAAA,GAAW,IAAA,GAAOC,mBAAA,CAAY,IAAI,CAAA,GAAI,MAAA;AAE5C,EAAA,IAAI,CAAC,QAAA,EAAU;AACb,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,MAAM,EAAA,GAAKC,kBAAA,CAAW,QAAQ,CAAA,CAAE,EAAA;AAGhC,EAAA,OAAO,EAAA,KAAO,YAAA,IAAgB,EAAA,KAAO,UAAA,GAAa,QAAA,GAAW,MAAA;AAC/D;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,29 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const instrumentation = require('./reactrouter-compat-utils/instrumentation.js');
4
+ require('@sentry/core/browser');
5
+ require('@sentry/browser');
6
+ require('@sentry/core');
7
+
8
+ function reactRouterBrowserTracingIntegration(options) {
9
+ return instrumentation.createReactRouterV6CompatibleTracingIntegration(options, "");
10
+ }
11
+ function wrapReactRouterRouting(routes) {
12
+ return instrumentation.createV6CompatibleWithSentryReactRouterRouting(routes, "");
13
+ }
14
+ function wrapCreateBrowserRouter(createRouterFunction) {
15
+ return instrumentation.createV6CompatibleWrapCreateBrowserRouter(createRouterFunction, "");
16
+ }
17
+ function wrapCreateMemoryRouter(createMemoryRouterFunction) {
18
+ return instrumentation.createV6CompatibleWrapCreateMemoryRouter(createMemoryRouterFunction, "");
19
+ }
20
+ function wrapUseRoutes(origUseRoutes) {
21
+ return instrumentation.createV6CompatibleWrapUseRoutes(origUseRoutes, "");
22
+ }
23
+
24
+ exports.reactRouterBrowserTracingIntegration = reactRouterBrowserTracingIntegration;
25
+ exports.wrapCreateBrowserRouter = wrapCreateBrowserRouter;
26
+ exports.wrapCreateMemoryRouter = wrapCreateMemoryRouter;
27
+ exports.wrapReactRouterRouting = wrapReactRouterRouting;
28
+ exports.wrapUseRoutes = wrapUseRoutes;
29
+ //# sourceMappingURL=reactrouter.compat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactrouter.compat.js","sources":["../../src/reactrouter.compat.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 to instrument navigations.\n * Expects `useEffect`, `useLocation`, `useNavigationType`, `createRoutesFromChildren` and `matchRoutes` to be passed as options.\n *\n * Works with React Router v6+.\n */\nexport function reactRouterBrowserTracingIntegration(\n options: Parameters<typeof browserTracingIntegration>[0] & ReactRouterOptions,\n): Integration {\n return createReactRouterV6CompatibleTracingIntegration(options, '');\n}\n\n/**\n * A higher-order component that adds Sentry routing instrumentation to a React Router Route component.\n * This is used to automatically capture route changes as transactions.\n *\n * Works with React Router v6+.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function wrapReactRouterRouting<P extends Record<string, any>, R extends React.FC<P>>(routes: R): R {\n return createV6CompatibleWithSentryReactRouterRouting<P, R>(routes, '');\n}\n\n/**\n * A wrapper function that adds Sentry routing instrumentation to a React Router createBrowserRouter function.\n * This is used to automatically capture route changes as transactions when using the createBrowserRouter API.\n *\n * Works with React Router v6+.\n */\nexport function wrapCreateBrowserRouter<\n TState extends RouterState = RouterState,\n TRouter extends Router<TState> = Router<TState>,\n>(createRouterFunction: CreateRouterFunction<TState, TRouter>): CreateRouterFunction<TState, TRouter> {\n return createV6CompatibleWrapCreateBrowserRouter(createRouterFunction, '');\n}\n\n/**\n * A wrapper function that adds Sentry routing instrumentation to a React Router 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 *\n * Works with React Router v6+.\n */\nexport function wrapCreateMemoryRouter<\n TState extends RouterState = RouterState,\n TRouter extends Router<TState> = Router<TState>,\n>(createMemoryRouterFunction: CreateRouterFunction<TState, TRouter>): CreateRouterFunction<TState, TRouter> {\n return createV6CompatibleWrapCreateMemoryRouter(createMemoryRouterFunction, '');\n}\n\n/**\n * A wrapper function that adds Sentry routing instrumentation to a React Router useRoutes hook.\n * This is used to automatically capture route changes as transactions when using the useRoutes hook.\n *\n * Works with React Router v6+.\n */\nexport function wrapUseRoutes(origUseRoutes: UseRoutes): UseRoutes {\n return createV6CompatibleWrapUseRoutes(origUseRoutes, '');\n}\n"],"names":["createReactRouterV6CompatibleTracingIntegration","createV6CompatibleWithSentryReactRouterRouting","createV6CompatibleWrapCreateBrowserRouter","createV6CompatibleWrapCreateMemoryRouter","createV6CompatibleWrapUseRoutes"],"mappings":";;;;;;;AAkBO,SAAS,qCACd,OAAA,EACa;AACb,EAAA,OAAOA,+DAAA,CAAgD,SAAS,EAAE,CAAA;AACpE;AASO,SAAS,uBAA6E,MAAA,EAAc;AACzG,EAAA,OAAOC,8DAAA,CAAqD,QAAQ,EAAE,CAAA;AACxE;AAQO,SAAS,wBAGd,oBAAA,EAAoG;AACpG,EAAA,OAAOC,yDAAA,CAA0C,sBAAsB,EAAE,CAAA;AAC3E;AAUO,SAAS,uBAGd,0BAAA,EAA0G;AAC1G,EAAA,OAAOC,wDAAA,CAAyC,4BAA4B,EAAE,CAAA;AAChF;AAQO,SAAS,cAAc,aAAA,EAAqC;AACjE,EAAA,OAAOC,+CAAA,CAAgC,eAAe,EAAE,CAAA;AAC1D;;;;;;;;"}