@sentry/react 8.41.0-beta.1 → 8.42.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 (74) hide show
  1. package/build/cjs/error.js.map +1 -1
  2. package/build/cjs/errorboundary.js.map +1 -1
  3. package/build/cjs/index.js +7 -0
  4. package/build/cjs/index.js.map +1 -1
  5. package/build/cjs/profiler.js.map +1 -1
  6. package/build/cjs/reactrouter.js +1 -1
  7. package/build/cjs/reactrouter.js.map +1 -1
  8. package/build/cjs/reactrouterv3.js.map +1 -1
  9. package/build/cjs/reactrouterv6-compat-utils.js +415 -0
  10. package/build/cjs/reactrouterv6-compat-utils.js.map +1 -0
  11. package/build/cjs/reactrouterv6.js +31 -373
  12. package/build/cjs/reactrouterv6.js.map +1 -1
  13. package/build/cjs/reactrouterv7.js +46 -0
  14. package/build/cjs/reactrouterv7.js.map +1 -0
  15. package/build/cjs/redux.js +0 -2
  16. package/build/cjs/redux.js.map +1 -1
  17. package/build/cjs/sdk.js.map +1 -1
  18. package/build/cjs/tanstackrouter.js.map +1 -1
  19. package/build/esm/error.js.map +1 -1
  20. package/build/esm/errorboundary.js.map +1 -1
  21. package/build/esm/index.js +2 -1
  22. package/build/esm/index.js.map +1 -1
  23. package/build/esm/package.json +1 -1
  24. package/build/esm/profiler.js.map +1 -1
  25. package/build/esm/reactrouter.js +1 -1
  26. package/build/esm/reactrouter.js.map +1 -1
  27. package/build/esm/reactrouterv3.js.map +1 -1
  28. package/build/esm/reactrouterv6-compat-utils.js +392 -0
  29. package/build/esm/reactrouterv6-compat-utils.js.map +1 -0
  30. package/build/esm/reactrouterv6.js +30 -357
  31. package/build/esm/reactrouterv6.js.map +1 -1
  32. package/build/esm/reactrouterv7.js +41 -0
  33. package/build/esm/reactrouterv7.js.map +1 -0
  34. package/build/esm/redux.js +0 -2
  35. package/build/esm/redux.js.map +1 -1
  36. package/build/esm/sdk.js.map +1 -1
  37. package/build/esm/tanstackrouter.js.map +1 -1
  38. package/build/types/error.d.ts +1 -1
  39. package/build/types/error.d.ts.map +1 -1
  40. package/build/types/errorboundary.d.ts +1 -1
  41. package/build/types/errorboundary.d.ts.map +1 -1
  42. package/build/types/index.d.ts +2 -1
  43. package/build/types/index.d.ts.map +1 -1
  44. package/build/types/profiler.d.ts +1 -1
  45. package/build/types/profiler.d.ts.map +1 -1
  46. package/build/types/reactrouter.d.ts +1 -1
  47. package/build/types/reactrouter.d.ts.map +1 -1
  48. package/build/types/reactrouterv3.d.ts +1 -1
  49. package/build/types/reactrouterv3.d.ts.map +1 -1
  50. package/build/types/reactrouterv6-compat-utils.d.ts +26 -0
  51. package/build/types/reactrouterv6-compat-utils.d.ts.map +1 -0
  52. package/build/types/reactrouterv6.d.ts +30 -16
  53. package/build/types/reactrouterv6.d.ts.map +1 -1
  54. package/build/types/reactrouterv7.d.ts +26 -0
  55. package/build/types/reactrouterv7.d.ts.map +1 -0
  56. package/build/types/redux.d.ts +1 -1
  57. package/build/types/redux.d.ts.map +1 -1
  58. package/build/types/sdk.d.ts +1 -1
  59. package/build/types/sdk.d.ts.map +1 -1
  60. package/build/types/tanstackrouter.d.ts +1 -1
  61. package/build/types/tanstackrouter.d.ts.map +1 -1
  62. package/build/types-ts3.8/error.d.ts +1 -1
  63. package/build/types-ts3.8/errorboundary.d.ts +1 -1
  64. package/build/types-ts3.8/index.d.ts +2 -1
  65. package/build/types-ts3.8/profiler.d.ts +1 -1
  66. package/build/types-ts3.8/reactrouter.d.ts +1 -1
  67. package/build/types-ts3.8/reactrouterv3.d.ts +1 -1
  68. package/build/types-ts3.8/reactrouterv6-compat-utils.d.ts +26 -0
  69. package/build/types-ts3.8/reactrouterv6.d.ts +29 -15
  70. package/build/types-ts3.8/reactrouterv7.d.ts +26 -0
  71. package/build/types-ts3.8/redux.d.ts +1 -1
  72. package/build/types-ts3.8/sdk.d.ts +1 -1
  73. package/build/types-ts3.8/tanstackrouter.d.ts +1 -1
  74. package/package.json +3 -4
@@ -1,41 +1,6 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
2
 
3
- const browser = require('@sentry/browser');
4
- const core = require('@sentry/core');
5
- const hoistNonReactStatics = require('hoist-non-react-statics');
6
- const React = require('react');
7
- const debugBuild = require('./debug-build.js');
8
-
9
- const _interopDefault = e => e && e.__esModule ? e.default : e;
10
-
11
- function _interopNamespace(e) {
12
- if (e && e.__esModule) return e;
13
- const n = Object.create(null);
14
- if (e) {
15
- for (const k in e) {
16
- n[k] = e[k];
17
- }
18
- }
19
- n.default = e;
20
- return n;
21
- }
22
-
23
- const hoistNonReactStatics__default = /*#__PURE__*/_interopDefault(hoistNonReactStatics);
24
- const React__namespace = /*#__PURE__*/_interopNamespace(React);
25
-
26
- /* eslint-disable max-lines */
27
- // Inspired from Donnie McNeal's solution:
28
- // https://gist.github.com/wontondon/e8c4bdf2888875e4c755712e99279536
29
-
30
-
31
- let _useEffect;
32
- let _useLocation;
33
- let _useNavigationType;
34
- let _createRoutesFromChildren;
35
- let _matchRoutes;
36
- let _stripBasename = false;
37
-
38
- const CLIENTS_WITH_INSTRUMENT_NAVIGATION = new WeakSet();
3
+ const reactrouterv6CompatUtils = require('./reactrouterv6-compat-utils.js');
39
4
 
40
5
  /**
41
6
  * A browser tracing integration that uses React Router v6 to instrument navigations.
@@ -44,359 +9,52 @@ const CLIENTS_WITH_INSTRUMENT_NAVIGATION = new WeakSet();
44
9
  function reactRouterV6BrowserTracingIntegration(
45
10
  options,
46
11
  ) {
47
- const integration = browser.browserTracingIntegration({
48
- ...options,
49
- instrumentPageLoad: false,
50
- instrumentNavigation: false,
51
- });
52
-
53
- const {
54
- useEffect,
55
- useLocation,
56
- useNavigationType,
57
- createRoutesFromChildren,
58
- matchRoutes,
59
- stripBasename,
60
- instrumentPageLoad = true,
61
- instrumentNavigation = true,
62
- } = options;
63
-
64
- return {
65
- ...integration,
66
- setup() {
67
- _useEffect = useEffect;
68
- _useLocation = useLocation;
69
- _useNavigationType = useNavigationType;
70
- _matchRoutes = matchRoutes;
71
- _createRoutesFromChildren = createRoutesFromChildren;
72
- _stripBasename = stripBasename || false;
73
- },
74
- afterAllSetup(client) {
75
- integration.afterAllSetup(client);
76
-
77
- const initPathName = browser.WINDOW && browser.WINDOW.location && browser.WINDOW.location.pathname;
78
- if (instrumentPageLoad && initPathName) {
79
- browser.startBrowserTracingPageLoadSpan(client, {
80
- name: initPathName,
81
- attributes: {
82
- [core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',
83
- [core.SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'pageload',
84
- [core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.pageload.react.reactrouter_v6',
85
- },
86
- });
87
- }
88
-
89
- if (instrumentNavigation) {
90
- CLIENTS_WITH_INSTRUMENT_NAVIGATION.add(client);
91
- }
92
- },
93
- };
12
+ return reactrouterv6CompatUtils.createReactRouterV6CompatibleTracingIntegration(options, '6');
94
13
  }
95
14
 
96
15
  /**
97
- * Strip the basename from a pathname if exists.
98
- *
99
- * Vendored and modified from `react-router`
100
- * https://github.com/remix-run/react-router/blob/462bb712156a3f739d6139a0f14810b76b002df6/packages/router/utils.ts#L1038
16
+ * A wrapper function that adds Sentry routing instrumentation to a React Router v6 useRoutes hook.
17
+ * This is used to automatically capture route changes as transactions when using the useRoutes hook.
101
18
  */
102
- function stripBasenameFromPathname(pathname, basename) {
103
- if (!basename || basename === '/') {
104
- return pathname;
105
- }
106
-
107
- if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) {
108
- return pathname;
109
- }
110
-
111
- // We want to leave trailing slash behavior in the user's control, so if they
112
- // specify a basename with a trailing slash, we should support it
113
- const startIndex = basename.endsWith('/') ? basename.length - 1 : basename.length;
114
- const nextChar = pathname.charAt(startIndex);
115
- if (nextChar && nextChar !== '/') {
116
- // pathname does not start with basename/
117
- return pathname;
118
- }
119
-
120
- return pathname.slice(startIndex) || '/';
121
- }
122
-
123
- function sendIndexPath(pathBuilder, pathname, basename) {
124
- const reconstructedPath = pathBuilder || _stripBasename ? stripBasenameFromPathname(pathname, basename) : pathname;
125
-
126
- const formattedPath =
127
- // If the path ends with a slash, remove it
128
- reconstructedPath[reconstructedPath.length - 1] === '/'
129
- ? reconstructedPath.slice(0, -1)
130
- : // If the path ends with a wildcard, remove it
131
- reconstructedPath.slice(-2) === '/*'
132
- ? reconstructedPath.slice(0, -1)
133
- : reconstructedPath;
134
-
135
- return [formattedPath, 'route'];
136
- }
137
-
138
- function pathEndsWithWildcard(path, branch) {
139
- return (path.slice(-2) === '/*' && branch.route.children && branch.route.children.length > 0) || false;
140
- }
141
-
142
- function pathIsWildcardAndHasChildren(path, branch) {
143
- return (path === '*' && branch.route.children && branch.route.children.length > 0) || false;
144
- }
145
-
146
- function getNormalizedName(
147
- routes,
148
- location,
149
- branches,
150
- basename = '',
151
- ) {
152
- if (!routes || routes.length === 0) {
153
- return [_stripBasename ? stripBasenameFromPathname(location.pathname, basename) : location.pathname, 'url'];
154
- }
155
-
156
- let pathBuilder = '';
157
- if (branches) {
158
- for (const branch of branches) {
159
- const route = branch.route;
160
- if (route) {
161
- // Early return if index route
162
- if (route.index) {
163
- return sendIndexPath(pathBuilder, branch.pathname, basename);
164
- }
165
- const path = route.path;
166
-
167
- // If path is not a wildcard and has no child routes, append the path
168
- if (path && !pathIsWildcardAndHasChildren(path, branch)) {
169
- const newPath = path[0] === '/' || pathBuilder[pathBuilder.length - 1] === '/' ? path : `/${path}`;
170
- pathBuilder += newPath;
171
-
172
- // If the path matches the current location, return the path
173
- if (basename + branch.pathname === location.pathname) {
174
- if (
175
- // If the route defined on the element is something like
176
- // <Route path="/stores/:storeId/products/:productId" element={<div>Product</div>} />
177
- // We should check against the branch.pathname for the number of / separators
178
- core.getNumberOfUrlSegments(pathBuilder) !== core.getNumberOfUrlSegments(branch.pathname) &&
179
- // We should not count wildcard operators in the url segments calculation
180
- pathBuilder.slice(-2) !== '/*'
181
- ) {
182
- return [(_stripBasename ? '' : basename) + newPath, 'route'];
183
- }
184
-
185
- // if the last character of the pathbuilder is a wildcard and there are children, remove the wildcard
186
- if (pathEndsWithWildcard(pathBuilder, branch)) {
187
- pathBuilder = pathBuilder.slice(0, -1);
188
- }
189
-
190
- return [(_stripBasename ? '' : basename) + pathBuilder, 'route'];
191
- }
192
- }
193
- }
194
- }
195
- }
196
-
197
- return [_stripBasename ? stripBasenameFromPathname(location.pathname, basename) : location.pathname, 'url'];
198
- }
199
-
200
- function updatePageloadTransaction(
201
- activeRootSpan,
202
- location,
203
- routes,
204
- matches,
205
- basename,
206
- ) {
207
- const branches = Array.isArray(matches)
208
- ? matches
209
- : (_matchRoutes(routes, location, basename) );
210
-
211
- if (branches) {
212
- const [name, source] = getNormalizedName(routes, location, branches, basename);
213
-
214
- core.getCurrentScope().setTransactionName(name);
215
-
216
- if (activeRootSpan) {
217
- activeRootSpan.updateName(name);
218
- activeRootSpan.setAttribute(core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, source);
219
- }
220
- }
221
- }
222
-
223
- function handleNavigation(
224
- location,
225
- routes,
226
- navigationType,
227
- matches,
228
- basename,
229
- ) {
230
- const branches = Array.isArray(matches) ? matches : _matchRoutes(routes, location, basename);
231
-
232
- const client = core.getClient();
233
- if (!client || !CLIENTS_WITH_INSTRUMENT_NAVIGATION.has(client)) {
234
- return;
235
- }
236
-
237
- if ((navigationType === 'PUSH' || navigationType === 'POP') && branches) {
238
- const [name, source] = getNormalizedName(routes, location, branches, basename);
239
-
240
- browser.startBrowserTracingNavigationSpan(client, {
241
- name,
242
- attributes: {
243
- [core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,
244
- [core.SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',
245
- [core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.react.reactrouter_v6',
246
- },
247
- });
248
- }
19
+ function wrapUseRoutesV6(origUseRoutes) {
20
+ return reactrouterv6CompatUtils.createV6CompatibleWrapUseRoutes(origUseRoutes, '6');
249
21
  }
250
22
 
251
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
252
- function withSentryReactRouterV6Routing(Routes) {
253
- if (!_useEffect || !_useLocation || !_useNavigationType || !_createRoutesFromChildren || !_matchRoutes) {
254
- debugBuild.DEBUG_BUILD &&
255
- core.logger.warn(`reactRouterV6Instrumentation was unable to wrap Routes because of one or more missing parameters.
256
- useEffect: ${_useEffect}. useLocation: ${_useLocation}. useNavigationType: ${_useNavigationType}.
257
- createRoutesFromChildren: ${_createRoutesFromChildren}. matchRoutes: ${_matchRoutes}.`);
258
-
259
- return Routes;
260
- }
261
-
262
- let isMountRenderPass = true;
263
-
264
- const SentryRoutes = (props) => {
265
- const location = _useLocation();
266
- const navigationType = _useNavigationType();
267
-
268
- _useEffect(
269
- () => {
270
- const routes = _createRoutesFromChildren(props.children) ;
271
-
272
- if (isMountRenderPass) {
273
- updatePageloadTransaction(getActiveRootSpan(), location, routes);
274
- isMountRenderPass = false;
275
- } else {
276
- handleNavigation(location, routes, navigationType);
277
- }
278
- },
279
- // `props.children` is purposely not included in the dependency array, because we do not want to re-run this effect
280
- // when the children change. We only want to start transactions when the location or navigation type change.
281
- [location, navigationType],
282
- );
283
-
284
- // @ts-expect-error Setting more specific React Component typing for `R` generic above
285
- // will break advanced type inference done by react router params
286
- return React__namespace.createElement(Routes, { ...props,} );
287
- };
288
-
289
- hoistNonReactStatics__default(SentryRoutes, Routes);
290
-
291
- // @ts-expect-error Setting more specific React Component typing for `R` generic above
292
- // will break advanced type inference done by react router params
293
- return SentryRoutes;
294
- }
295
-
296
- function wrapUseRoutes(origUseRoutes) {
297
- if (!_useEffect || !_useLocation || !_useNavigationType || !_matchRoutes) {
298
- debugBuild.DEBUG_BUILD &&
299
- core.logger.warn(
300
- 'reactRouterV6Instrumentation was unable to wrap `useRoutes` because of one or more missing parameters.',
301
- );
302
-
303
- return origUseRoutes;
304
- }
305
-
306
- let isMountRenderPass = true;
307
-
308
- const SentryRoutes
309
-
310
- = (props) => {
311
- const { routes, locationArg } = props;
312
-
313
- const Routes = origUseRoutes(routes, locationArg);
314
-
315
- const location = _useLocation();
316
- const navigationType = _useNavigationType();
317
-
318
- // A value with stable identity to either pick `locationArg` if available or `location` if not
319
- const stableLocationParam =
320
- typeof locationArg === 'string' || (locationArg && locationArg.pathname)
321
- ? (locationArg )
322
- : location;
323
-
324
- _useEffect(() => {
325
- const normalizedLocation =
326
- typeof stableLocationParam === 'string' ? { pathname: stableLocationParam } : stableLocationParam;
327
-
328
- if (isMountRenderPass) {
329
- updatePageloadTransaction(getActiveRootSpan(), normalizedLocation, routes);
330
- isMountRenderPass = false;
331
- } else {
332
- handleNavigation(normalizedLocation, routes, navigationType);
333
- }
334
- }, [navigationType, stableLocationParam]);
335
-
336
- return Routes;
337
- };
338
-
339
- // eslint-disable-next-line react/display-name
340
- return (routes, locationArg) => {
341
- return React__namespace.createElement(SentryRoutes, { routes: routes, locationArg: locationArg,} );
342
- };
343
- }
23
+ /**
24
+ * Alias for backwards compatibility
25
+ * @deprecated Use `wrapUseRoutesV6` or `wrapUseRoutesV7` instead.
26
+ */
27
+ const wrapUseRoutes = wrapUseRoutesV6;
344
28
 
345
- function wrapCreateBrowserRouter
29
+ /**
30
+ * A wrapper function that adds Sentry routing instrumentation to a React Router v6 createBrowserRouter function.
31
+ * This is used to automatically capture route changes as transactions when using the createBrowserRouter API.
32
+ */
33
+ function wrapCreateBrowserRouterV6
346
34
 
347
35
  (createRouterFunction) {
348
- if (!_useEffect || !_useLocation || !_useNavigationType || !_matchRoutes) {
349
- debugBuild.DEBUG_BUILD &&
350
- core.logger.warn(
351
- 'reactRouterV6Instrumentation was unable to wrap the `createRouter` function because of one or more missing parameters.',
352
- );
353
-
354
- return createRouterFunction;
355
- }
356
-
357
- // `opts` for createBrowserHistory and createMemoryHistory are different, but also not relevant for us at the moment.
358
- // `basename` is the only option that is relevant for us, and it is the same for all.
359
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
360
- return function (routes, opts) {
361
- const router = createRouterFunction(routes, opts);
362
- const basename = opts && opts.basename;
363
-
364
- const activeRootSpan = getActiveRootSpan();
365
-
366
- // The initial load ends when `createBrowserRouter` is called.
367
- // This is the earliest convenient time to update the transaction name.
368
- // Callbacks to `router.subscribe` are not called for the initial load.
369
- if (router.state.historyAction === 'POP' && activeRootSpan) {
370
- updatePageloadTransaction(activeRootSpan, router.state.location, routes, undefined, basename);
371
- }
372
-
373
- router.subscribe((state) => {
374
- const location = state.location;
375
- if (state.historyAction === 'PUSH' || state.historyAction === 'POP') {
376
- handleNavigation(location, routes, state.historyAction, undefined, basename);
377
- }
378
- });
379
-
380
- return router;
381
- };
36
+ return reactrouterv6CompatUtils.createV6CompatibleWrapCreateBrowserRouter(createRouterFunction, '6');
382
37
  }
383
38
 
384
- function getActiveRootSpan() {
385
- const span = core.getActiveSpan();
386
- const rootSpan = span ? core.getRootSpan(span) : undefined;
387
-
388
- if (!rootSpan) {
389
- return undefined;
390
- }
391
-
392
- const op = core.spanToJSON(rootSpan).op;
39
+ /**
40
+ * Alias for backwards compatibility
41
+ * @deprecated Use `wrapCreateBrowserRouterV6` or `wrapCreateBrowserRouterV7` instead.
42
+ */
43
+ const wrapCreateBrowserRouter = wrapCreateBrowserRouterV6;
393
44
 
394
- // Only use this root span if it is a pageload or navigation span
395
- return op === 'navigation' || op === 'pageload' ? rootSpan : undefined;
45
+ /**
46
+ * A higher-order component that adds Sentry routing instrumentation to a React Router v6 Route component.
47
+ * This is used to automatically capture route changes as transactions.
48
+ */
49
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
50
+ function withSentryReactRouterV6Routing(routes) {
51
+ return reactrouterv6CompatUtils.createV6CompatibleWithSentryReactRouterRouting(routes, '6');
396
52
  }
397
53
 
398
54
  exports.reactRouterV6BrowserTracingIntegration = reactRouterV6BrowserTracingIntegration;
399
55
  exports.withSentryReactRouterV6Routing = withSentryReactRouterV6Routing;
400
56
  exports.wrapCreateBrowserRouter = wrapCreateBrowserRouter;
57
+ exports.wrapCreateBrowserRouterV6 = wrapCreateBrowserRouterV6;
401
58
  exports.wrapUseRoutes = wrapUseRoutes;
59
+ exports.wrapUseRoutesV6 = wrapUseRoutesV6;
402
60
  //# sourceMappingURL=reactrouterv6.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"reactrouterv6.js","sources":["../../src/reactrouterv6.tsx"],"sourcesContent":["/* eslint-disable max-lines */\n// Inspired from Donnie McNeal's solution:\n// https://gist.github.com/wontondon/e8c4bdf2888875e4c755712e99279536\n\nimport {\n WINDOW,\n browserTracingIntegration,\n startBrowserTracingNavigationSpan,\n startBrowserTracingPageLoadSpan,\n} from '@sentry/browser';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n getActiveSpan,\n getClient,\n getCurrentScope,\n getRootSpan,\n spanToJSON,\n} from '@sentry/core';\nimport { getNumberOfUrlSegments, logger } from '@sentry/core';\nimport type { Client, Integration, Span, TransactionSource } from '@sentry/types';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\n\nimport { DEBUG_BUILD } from './debug-build';\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';\n\nlet _useEffect: UseEffect;\nlet _useLocation: UseLocation;\nlet _useNavigationType: UseNavigationType;\nlet _createRoutesFromChildren: CreateRoutesFromChildren;\nlet _matchRoutes: MatchRoutes;\nlet _stripBasename: boolean = false;\n\nconst CLIENTS_WITH_INSTRUMENT_NAVIGATION = new WeakSet<Client>();\n\ninterface ReactRouterOptions {\n useEffect: UseEffect;\n useLocation: UseLocation;\n useNavigationType: UseNavigationType;\n createRoutesFromChildren: CreateRoutesFromChildren;\n matchRoutes: MatchRoutes;\n stripBasename?: boolean;\n}\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 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 instrumentPageLoad = true,\n instrumentNavigation = true,\n } = options;\n\n return {\n ...integration,\n setup() {\n _useEffect = useEffect;\n _useLocation = useLocation;\n _useNavigationType = useNavigationType;\n _matchRoutes = matchRoutes;\n _createRoutesFromChildren = createRoutesFromChildren;\n _stripBasename = stripBasename || false;\n },\n afterAllSetup(client) {\n integration.afterAllSetup(client);\n\n const initPathName = WINDOW && WINDOW.location && 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_v6',\n },\n });\n }\n\n if (instrumentNavigation) {\n CLIENTS_WITH_INSTRUMENT_NAVIGATION.add(client);\n }\n },\n };\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\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\nfunction pathEndsWithWildcard(path: string, branch: RouteMatch<string>): boolean {\n return (path.slice(-2) === '/*' && branch.route.children && branch.route.children.length > 0) || false;\n}\n\nfunction pathIsWildcardAndHasChildren(path: string, branch: RouteMatch<string>): boolean {\n return (path === '*' && branch.route.children && branch.route.children.length > 0) || false;\n}\n\nfunction 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 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 += newPath;\n\n // If the path matches the current location, return the path\n if (basename + branch.pathname === location.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 pathBuilder.slice(-2) !== '/*'\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 (pathEndsWithWildcard(pathBuilder, branch)) {\n pathBuilder = pathBuilder.slice(0, -1);\n }\n\n return [(_stripBasename ? '' : basename) + pathBuilder, 'route'];\n }\n }\n }\n }\n }\n\n return [_stripBasename ? stripBasenameFromPathname(location.pathname, basename) : location.pathname, 'url'];\n}\n\nfunction updatePageloadTransaction(\n activeRootSpan: Span | undefined,\n location: Location,\n routes: RouteObject[],\n matches?: AgnosticDataRouteMatch,\n basename?: string,\n): void {\n const branches = Array.isArray(matches)\n ? matches\n : (_matchRoutes(routes, location, basename) as unknown as RouteMatch[]);\n\n if (branches) {\n const [name, source] = getNormalizedName(routes, location, branches, basename);\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\nfunction handleNavigation(\n location: Location,\n routes: RouteObject[],\n navigationType: Action,\n matches?: AgnosticDataRouteMatch,\n basename?: string,\n): void {\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] = getNormalizedName(routes, location, branches, basename);\n\n 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_v6',\n },\n });\n }\n}\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 if (!_useEffect || !_useLocation || !_useNavigationType || !_createRoutesFromChildren || !_matchRoutes) {\n DEBUG_BUILD &&\n logger.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 let isMountRenderPass: boolean = true;\n\n const SentryRoutes: React.FC<P> = (props: P) => {\n const location = _useLocation();\n const navigationType = _useNavigationType();\n\n _useEffect(\n () => {\n const routes = _createRoutesFromChildren(props.children) as RouteObject[];\n\n if (isMountRenderPass) {\n updatePageloadTransaction(getActiveRootSpan(), location, routes);\n isMountRenderPass = false;\n } else {\n handleNavigation(location, routes, navigationType);\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\nexport function wrapUseRoutes(origUseRoutes: UseRoutes): UseRoutes {\n if (!_useEffect || !_useLocation || !_useNavigationType || !_matchRoutes) {\n DEBUG_BUILD &&\n logger.warn(\n 'reactRouterV6Instrumentation was unable to wrap `useRoutes` because of one or more missing parameters.',\n );\n\n return origUseRoutes;\n }\n\n let isMountRenderPass: boolean = true;\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 { 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 && locationArg.pathname)\n ? (locationArg as { pathname: string })\n : location;\n\n _useEffect(() => {\n const normalizedLocation =\n typeof stableLocationParam === 'string' ? { pathname: stableLocationParam } : stableLocationParam;\n\n if (isMountRenderPass) {\n updatePageloadTransaction(getActiveRootSpan(), normalizedLocation, routes);\n isMountRenderPass = false;\n } else {\n handleNavigation(normalizedLocation, routes, navigationType);\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\nexport function wrapCreateBrowserRouter<\n TState extends RouterState = RouterState,\n TRouter extends Router<TState> = Router<TState>,\n>(createRouterFunction: CreateRouterFunction<TState, TRouter>): CreateRouterFunction<TState, TRouter> {\n if (!_useEffect || !_useLocation || !_useNavigationType || !_matchRoutes) {\n DEBUG_BUILD &&\n logger.warn(\n 'reactRouterV6Instrumentation was unable to wrap the `createRouter` function because of one or more missing parameters.',\n );\n\n return createRouterFunction;\n }\n\n // `opts` for createBrowserHistory and createMemoryHistory are different, but also not relevant for us at the moment.\n // `basename` is the only option that is relevant for us, and it is the same for all.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return function (routes: RouteObject[], opts?: Record<string, any> & { basename?: string }): TRouter {\n const router = createRouterFunction(routes, opts);\n const basename = opts && 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(activeRootSpan, router.state.location, routes, undefined, basename);\n }\n\n router.subscribe((state: RouterState) => {\n const location = state.location;\n if (state.historyAction === 'PUSH' || state.historyAction === 'POP') {\n handleNavigation(location, routes, state.historyAction, undefined, basename);\n }\n });\n\n return router;\n };\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"],"names":["browserTracingIntegration","WINDOW","startBrowserTracingPageLoadSpan","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","SEMANTIC_ATTRIBUTE_SENTRY_OP","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","getNumberOfUrlSegments","getCurrentScope","getClient","startBrowserTracingNavigationSpan","DEBUG_BUILD","logger","React","hoistNonReactStatics","getActiveSpan","getRootSpan","spanToJSON"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;;;AAyCA,IAAI,UAAU;AACd,IAAI,YAAY;AAChB,IAAI,kBAAkB;AACtB,IAAI,yBAAyB;AAC7B,IAAI,YAAY;AAChB,IAAI,cAAc,GAAY,KAAK;;AAEnC,MAAM,kCAAmC,GAAE,IAAI,OAAO,EAAU;;AAWhE;AACA;AACA;AACA;AACO,SAAS,sCAAsC;AACtD,EAAE,OAAO;AACT,EAAe;AACf,EAAE,MAAM,WAAA,GAAcA,iCAAyB,CAAC;AAChD,IAAI,GAAG,OAAO;AACd,IAAI,kBAAkB,EAAE,KAAK;AAC7B,IAAI,oBAAoB,EAAE,KAAK;AAC/B,GAAG,CAAC;;AAEJ,EAAE,MAAM;AACR,IAAI,SAAS;AACb,IAAI,WAAW;AACf,IAAI,iBAAiB;AACrB,IAAI,wBAAwB;AAC5B,IAAI,WAAW;AACf,IAAI,aAAa;AACjB,IAAI,kBAAA,GAAqB,IAAI;AAC7B,IAAI,oBAAA,GAAuB,I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AAA,GAAA,IAAA,IAAA,IAAA,CAAA,QAAA;;AAEA,IAAA,MAAA,cAAA,GAAA,iBAAA,EAAA;;AAEA;AACA;AACA;AACA,IAAA,IAAA,MAAA,CAAA,KAAA,CAAA,aAAA,KAAA,KAAA,IAAA,cAAA,EAAA;AACA,MAAA,yBAAA,CAAA,cAAA,EAAA,MAAA,CAAA,KAAA,CAAA,QAAA,EAAA,MAAA,EAAA,SAAA,EAAA,QAAA,CAAA;AACA;;AAEA,IAAA,MAAA,CAAA,SAAA,CAAA,CAAA,KAAA,KAAA;AACA,MAAA,MAAA,QAAA,GAAA,KAAA,CAAA,QAAA;AACA,MAAA,IAAA,KAAA,CAAA,aAAA,KAAA,MAAA,IAAA,KAAA,CAAA,aAAA,KAAA,KAAA,EAAA;AACA,QAAA,gBAAA,CAAA,QAAA,EAAA,MAAA,EAAA,KAAA,CAAA,aAAA,EAAA,SAAA,EAAA,QAAA,CAAA;AACA;AACA,KAAA,CAAA;;AAEA,IAAA,OAAA,MAAA;AACA,GAAA;AACA;;AAEA,SAAA,iBAAA,GAAA;AACA,EAAA,MAAA,IAAA,GAAAG,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;;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":"reactrouterv6.js","sources":["../../src/reactrouterv6.tsx"],"sourcesContent":["import type { browserTracingIntegration } from '@sentry/browser';\nimport type { Integration } from '@sentry/core';\nimport type { ReactRouterOptions } from './reactrouterv6-compat-utils';\nimport {\n createReactRouterV6CompatibleTracingIntegration,\n createV6CompatibleWithSentryReactRouterRouting,\n createV6CompatibleWrapCreateBrowserRouter,\n createV6CompatibleWrapUseRoutes,\n} from './reactrouterv6-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 * Alias for backwards compatibility\n * @deprecated Use `wrapUseRoutesV6` or `wrapUseRoutesV7` instead.\n */\nexport const wrapUseRoutes = wrapUseRoutesV6;\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 * Alias for backwards compatibility\n * @deprecated Use `wrapCreateBrowserRouterV6` or `wrapCreateBrowserRouterV7` instead.\n */\nexport const wrapCreateBrowserRouter = wrapCreateBrowserRouterV6;\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","createV6CompatibleWithSentryReactRouterRouting"],"mappings":";;;;AAWA;AACA;AACA;AACA;AACO,SAAS,sCAAsC;AACtD,EAAE,OAAO;AACT,EAAe;AACf,EAAE,OAAOA,wEAA+C,CAAC,OAAO,EAAE,GAAG,CAAC;AACtE;;AAEA;AACA;AACA;AACA;AACO,SAAS,eAAe,CAAC,aAAa,EAAwB;AACrE,EAAE,OAAOC,wDAA+B,CAAC,aAAa,EAAE,GAAG,CAAC;AAC5D;;AAEA;AACA;AACA;AACA;AACO,MAAM,aAAc,GAAE;;AAE7B;AACA;AACA;AACA;AACO,SAAS;;AAGhB,CAAE,oBAAoB,EAAgF;AACtG,EAAE,OAAOC,kEAAyC,CAAC,oBAAoB,EAAE,GAAG,CAAC;AAC7E;;AAEA;AACA;AACA;AACA;AACO,MAAM,uBAAwB,GAAE;;AAEvC;AACA;AACA;AACA;AACA;AACO,SAAS,8BAA8B,CAAuD,MAAM,EAAQ;AACnH,EAAE,OAAOC,uEAA8C,CAAO,MAAM,EAAE,GAAG,CAAC;AAC1E;;;;;;;;;"}
@@ -0,0 +1,46 @@
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+
3
+ const reactrouterv6CompatUtils = require('./reactrouterv6-compat-utils.js');
4
+
5
+ /**
6
+ * A browser tracing integration that uses React Router v7 to instrument navigations.
7
+ * Expects `useEffect`, `useLocation`, `useNavigationType`, `createRoutesFromChildren` and `matchRoutes` to be passed as options.
8
+ */
9
+ function reactRouterV7BrowserTracingIntegration(
10
+ options,
11
+ ) {
12
+ return reactrouterv6CompatUtils.createReactRouterV6CompatibleTracingIntegration(options, '7');
13
+ }
14
+
15
+ /**
16
+ * A higher-order component that adds Sentry routing instrumentation to a React Router v7 Route component.
17
+ * This is used to automatically capture route changes as transactions.
18
+ */
19
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
+ function withSentryReactRouterV7Routing(routes) {
21
+ return reactrouterv6CompatUtils.createV6CompatibleWithSentryReactRouterRouting(routes, '7');
22
+ }
23
+
24
+ /**
25
+ * A wrapper function that adds Sentry routing instrumentation to a React Router v7 createBrowserRouter function.
26
+ * This is used to automatically capture route changes as transactions when using the createBrowserRouter API.
27
+ */
28
+ function wrapCreateBrowserRouterV7
29
+
30
+ (createRouterFunction) {
31
+ return reactrouterv6CompatUtils.createV6CompatibleWrapCreateBrowserRouter(createRouterFunction, '7');
32
+ }
33
+
34
+ /**
35
+ * A wrapper function that adds Sentry routing instrumentation to a React Router v7 useRoutes hook.
36
+ * This is used to automatically capture route changes as transactions when using the useRoutes hook.
37
+ */
38
+ function wrapUseRoutesV7(origUseRoutes) {
39
+ return reactrouterv6CompatUtils.createV6CompatibleWrapUseRoutes(origUseRoutes, '7');
40
+ }
41
+
42
+ exports.reactRouterV7BrowserTracingIntegration = reactRouterV7BrowserTracingIntegration;
43
+ exports.withSentryReactRouterV7Routing = withSentryReactRouterV7Routing;
44
+ exports.wrapCreateBrowserRouterV7 = wrapCreateBrowserRouterV7;
45
+ exports.wrapUseRoutesV7 = wrapUseRoutesV7;
46
+ //# sourceMappingURL=reactrouterv7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactrouterv7.js","sources":["../../src/reactrouterv7.tsx"],"sourcesContent":["// React Router v7 uses the same integration as v6\nimport type { browserTracingIntegration } from '@sentry/browser';\nimport type { Integration } from '@sentry/core';\nimport type { ReactRouterOptions } from './reactrouterv6-compat-utils';\nimport {\n createReactRouterV6CompatibleTracingIntegration,\n createV6CompatibleWithSentryReactRouterRouting,\n createV6CompatibleWrapCreateBrowserRouter,\n createV6CompatibleWrapUseRoutes,\n} from './reactrouterv6-compat-utils';\nimport type { CreateRouterFunction, Router, RouterState, UseRoutes } from './types';\n\n/**\n * A browser tracing integration that uses React Router v7 to instrument navigations.\n * Expects `useEffect`, `useLocation`, `useNavigationType`, `createRoutesFromChildren` and `matchRoutes` to be passed as options.\n */\nexport function reactRouterV7BrowserTracingIntegration(\n options: Parameters<typeof browserTracingIntegration>[0] & ReactRouterOptions,\n): Integration {\n return createReactRouterV6CompatibleTracingIntegration(options, '7');\n}\n\n/**\n * A higher-order component that adds Sentry routing instrumentation to a React Router v7 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 withSentryReactRouterV7Routing<P extends Record<string, any>, R extends React.FC<P>>(routes: R): R {\n return createV6CompatibleWithSentryReactRouterRouting<P, R>(routes, '7');\n}\n\n/**\n * A wrapper function that adds Sentry routing instrumentation to a React Router v7 createBrowserRouter function.\n * This is used to automatically capture route changes as transactions when using the createBrowserRouter API.\n */\nexport function wrapCreateBrowserRouterV7<\n TState extends RouterState = RouterState,\n TRouter extends Router<TState> = Router<TState>,\n>(createRouterFunction: CreateRouterFunction<TState, TRouter>): CreateRouterFunction<TState, TRouter> {\n return createV6CompatibleWrapCreateBrowserRouter(createRouterFunction, '7');\n}\n\n/**\n * A wrapper function that adds Sentry routing instrumentation to a React Router v7 useRoutes hook.\n * This is used to automatically capture route changes as transactions when using the useRoutes hook.\n */\nexport function wrapUseRoutesV7(origUseRoutes: UseRoutes): UseRoutes {\n return createV6CompatibleWrapUseRoutes(origUseRoutes, '7');\n}\n"],"names":["createReactRouterV6CompatibleTracingIntegration","createV6CompatibleWithSentryReactRouterRouting","createV6CompatibleWrapCreateBrowserRouter","createV6CompatibleWrapUseRoutes"],"mappings":";;;;AAYA;AACA;AACA;AACA;AACO,SAAS,sCAAsC;AACtD,EAAE,OAAO;AACT,EAAe;AACf,EAAE,OAAOA,wEAA+C,CAAC,OAAO,EAAE,GAAG,CAAC;AACtE;;AAEA;AACA;AACA;AACA;AACA;AACO,SAAS,8BAA8B,CAAuD,MAAM,EAAQ;AACnH,EAAE,OAAOC,uEAA8C,CAAO,MAAM,EAAE,GAAG,CAAC;AAC1E;;AAEA;AACA;AACA;AACA;AACO,SAAS;;AAGhB,CAAE,oBAAoB,EAAgF;AACtG,EAAE,OAAOC,kEAAyC,CAAC,oBAAoB,EAAE,GAAG,CAAC;AAC7E;;AAEA;AACA;AACA;AACA;AACO,SAAS,eAAe,CAAC,aAAa,EAAwB;AACrE,EAAE,OAAOC,wDAA+B,CAAC,aAAa,EAAE,GAAG,CAAC;AAC5D;;;;;;;"}
@@ -2,8 +2,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
2
2
 
3
3
  const core = require('@sentry/core');
4
4
 
5
- /* eslint-disable @typescript-eslint/no-explicit-any */
6
-
7
5
  const ACTION_BREADCRUMB_CATEGORY = 'redux.action';
8
6
  const ACTION_BREADCRUMB_TYPE = 'info';
9
7
 
@@ -1 +1 @@
1
- {"version":3,"file":"redux.js","sources":["../../src/redux.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { addBreadcrumb, getClient, getCurrentScope, getGlobalScope } from '@sentry/core';\nimport { addNonEnumerableProperty } from '@sentry/core';\nimport type { Scope } from '@sentry/types';\n\ninterface Action<T = any> {\n type: T;\n}\n\ninterface AnyAction extends Action {\n [extraProps: string]: any;\n}\n\ntype Reducer<S = any, A extends Action = AnyAction> = (state: S | undefined, action: A) => S;\n\ntype Dispatch<A extends Action = AnyAction> = <T extends A>(action: T, ...extraArgs: any[]) => T;\n\ntype ExtendState<State, Extension> = [Extension] extends [never] ? State : State & Extension;\n\ntype Unsubscribe = () => void;\n\ninterface Store<S = any, A extends Action = AnyAction, StateExt = never, Ext = Record<string, unknown>> {\n dispatch: Dispatch<A>;\n getState(): S;\n subscribe(listener: () => void): Unsubscribe;\n replaceReducer<NewState, NewActions extends Action>(\n nextReducer: Reducer<NewState, NewActions>,\n ): Store<ExtendState<NewState, StateExt>, NewActions, StateExt, Ext> & Ext;\n}\n\ndeclare const $CombinedState: unique symbol;\n\ntype CombinedState<S> = { readonly [$CombinedState]?: undefined } & S;\n\ntype PreloadedState<S> = Required<S> extends {\n [$CombinedState]: undefined;\n}\n ? S extends CombinedState<infer S1>\n ? { [K in keyof S1]?: S1[K] extends Record<string, unknown> ? PreloadedState<S1[K]> : S1[K] }\n : never\n : { [K in keyof S]: S[K] extends string | number | boolean | symbol ? S[K] : PreloadedState<S[K]> };\n\ntype StoreEnhancerStoreCreator<Ext = Record<string, unknown>, StateExt = never> = <\n S = any,\n A extends Action = AnyAction,\n>(\n reducer: Reducer<S, A>,\n preloadedState?: PreloadedState<S>,\n) => Store<ExtendState<S, StateExt>, A, StateExt, Ext> & Ext;\n\nexport interface SentryEnhancerOptions<S = any> {\n /**\n * Redux state in attachments or not.\n * @default true\n */\n attachReduxState?: boolean;\n\n /**\n * Transforms the state before attaching it to an event.\n * Use this to remove any private data before sending it to Sentry.\n * Return null to not attach the state.\n */\n stateTransformer(state: S | undefined): (S & any) | null;\n /**\n * Transforms the action before sending it as a breadcrumb.\n * Use this to remove any private data before sending it to Sentry.\n * Return null to not send the breadcrumb.\n */\n actionTransformer(action: AnyAction): AnyAction | null;\n /**\n * Called on every state update, configure the Sentry Scope with the redux state.\n */\n configureScopeWithState?(scope: Scope, state: S): void;\n}\n\nconst ACTION_BREADCRUMB_CATEGORY = 'redux.action';\nconst ACTION_BREADCRUMB_TYPE = 'info';\n\nconst defaultOptions: SentryEnhancerOptions = {\n attachReduxState: true,\n actionTransformer: action => action,\n stateTransformer: state => state || null,\n};\n\n/**\n * Creates an enhancer that would be passed to Redux's createStore to log actions and the latest state to Sentry.\n *\n * @param enhancerOptions Options to pass to the enhancer\n */\nfunction createReduxEnhancer(enhancerOptions?: Partial<SentryEnhancerOptions>): any {\n // Note: We return an any type as to not have type conflicts.\n const options = {\n ...defaultOptions,\n ...enhancerOptions,\n };\n\n return (next: StoreEnhancerStoreCreator): StoreEnhancerStoreCreator =>\n <S = any, A extends Action = AnyAction>(reducer: Reducer<S, A>, initialState?: PreloadedState<S>) => {\n options.attachReduxState &&\n getGlobalScope().addEventProcessor((event, hint) => {\n try {\n // @ts-expect-error try catch to reduce bundle size\n if (event.type === undefined && event.contexts.state.state.type === 'redux') {\n hint.attachments = [\n ...(hint.attachments || []),\n // @ts-expect-error try catch to reduce bundle size\n { filename: 'redux_state.json', data: JSON.stringify(event.contexts.state.state.value) },\n ];\n }\n } catch (_) {\n // empty\n }\n return event;\n });\n\n const sentryReducer: Reducer<S, A> = (state, action): S => {\n const newState = reducer(state, action);\n\n const scope = getCurrentScope();\n\n /* Action breadcrumbs */\n const transformedAction = options.actionTransformer(action);\n if (typeof transformedAction !== 'undefined' && transformedAction !== null) {\n addBreadcrumb({\n category: ACTION_BREADCRUMB_CATEGORY,\n data: transformedAction,\n type: ACTION_BREADCRUMB_TYPE,\n });\n }\n\n /* Set latest state to scope */\n const transformedState = options.stateTransformer(newState);\n if (typeof transformedState !== 'undefined' && transformedState !== null) {\n const client = getClient();\n const options = client && client.getOptions();\n const normalizationDepth = (options && options.normalizeDepth) || 3; // default state normalization depth to 3\n\n // Set the normalization depth of the redux state to the configured `normalizeDepth` option or a sane number as a fallback\n const newStateContext = { state: { type: 'redux', value: transformedState } };\n addNonEnumerableProperty(\n newStateContext,\n '__sentry_override_normalization_depth__',\n 3 + // 3 layers for `state.value.transformedState`\n normalizationDepth, // rest for the actual state\n );\n\n scope.setContext('state', newStateContext);\n } else {\n scope.setContext('state', null);\n }\n\n /* Allow user to configure scope with latest state */\n const { configureScopeWithState } = options;\n if (typeof configureScopeWithState === 'function') {\n configureScopeWithState(scope, newState);\n }\n\n return newState;\n };\n\n return next(sentryReducer, initialState);\n };\n}\n\nexport { createReduxEnhancer };\n"],"names":["getGlobalScope","getCurrentScope","addBreadcrumb","getClient","addNonEnumerableProperty"],"mappings":";;;;AAAA;;AA2EA,MAAM,0BAAA,GAA6B,cAAc;AACjD,MAAM,sBAAA,GAAyB,MAAM;;AAErC,MAAM,cAAc,GAA0B;AAC9C,EAAE,gBAAgB,EAAE,IAAI;AACxB,EAAE,iBAAiB,EA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{ Scope } from '@sentry/core';\nimport { addBreadcrumb, addNonEnumerableProperty, getClient, getCurrentScope, getGlobalScope } from '@sentry/core';\n\ninterface Action<T = any> {\n type: T;\n}\n\ninterface AnyAction extends Action {\n [extraProps: string]: any;\n}\n\ntype Reducer<S = any, A extends Action = AnyAction> = (state: S | undefined, action: A) => S;\n\ntype Dispatch<A extends Action = AnyAction> = <T extends A>(action: T, ...extraArgs: any[]) => T;\n\ntype ExtendState<State, Extension> = [Extension] extends [never] ? State : State & Extension;\n\ntype Unsubscribe = () => void;\n\ninterface Store<S = any, A extends Action = AnyAction, StateExt = never, Ext = Record<string, unknown>> {\n dispatch: Dispatch<A>;\n getState(): S;\n subscribe(listener: () => void): Unsubscribe;\n replaceReducer<NewState, NewActions extends Action>(\n nextReducer: Reducer<NewState, NewActions>,\n ): Store<ExtendState<NewState, StateExt>, NewActions, StateExt, Ext> & Ext;\n}\n\ndeclare const $CombinedState: unique symbol;\n\ntype CombinedState<S> = { readonly [$CombinedState]?: undefined } & S;\n\ntype PreloadedState<S> = Required<S> extends {\n [$CombinedState]: undefined;\n}\n ? S extends CombinedState<infer S1>\n ? { [K in keyof S1]?: S1[K] extends Record<string, unknown> ? PreloadedState<S1[K]> : S1[K] }\n : never\n : { [K in keyof S]: S[K] extends string | number | boolean | symbol ? S[K] : PreloadedState<S[K]> };\n\ntype StoreEnhancerStoreCreator<Ext = Record<string, unknown>, StateExt = never> = <\n S = any,\n A extends Action = AnyAction,\n>(\n reducer: Reducer<S, A>,\n preloadedState?: PreloadedState<S>,\n) => Store<ExtendState<S, StateExt>, A, StateExt, Ext> & Ext;\n\nexport interface SentryEnhancerOptions<S = any> {\n /**\n * Redux state in attachments or not.\n * @default true\n */\n attachReduxState?: boolean;\n\n /**\n * Transforms the state before attaching it to an event.\n * Use this to remove any private data before sending it to Sentry.\n * Return null to not attach the state.\n */\n stateTransformer(state: S | undefined): (S & any) | null;\n /**\n * Transforms the action before sending it as a breadcrumb.\n * Use this to remove any private data before sending it to Sentry.\n * Return null to not send the breadcrumb.\n */\n actionTransformer(action: AnyAction): AnyAction | null;\n /**\n * Called on every state update, configure the Sentry Scope with the redux state.\n */\n configureScopeWithState?(scope: Scope, state: S): void;\n}\n\nconst ACTION_BREADCRUMB_CATEGORY = 'redux.action';\nconst ACTION_BREADCRUMB_TYPE = 'info';\n\nconst defaultOptions: SentryEnhancerOptions = {\n attachReduxState: true,\n actionTransformer: action => action,\n stateTransformer: state => state || null,\n};\n\n/**\n * Creates an enhancer that would be passed to Redux's createStore to log actions and the latest state to Sentry.\n *\n * @param enhancerOptions Options to pass to the enhancer\n */\nfunction createReduxEnhancer(enhancerOptions?: Partial<SentryEnhancerOptions>): any {\n // Note: We return an any type as to not have type conflicts.\n const options = {\n ...defaultOptions,\n ...enhancerOptions,\n };\n\n return (next: StoreEnhancerStoreCreator): StoreEnhancerStoreCreator =>\n <S = any, A extends Action = AnyAction>(reducer: Reducer<S, A>, initialState?: PreloadedState<S>) => {\n options.attachReduxState &&\n getGlobalScope().addEventProcessor((event, hint) => {\n try {\n // @ts-expect-error try catch to reduce bundle size\n if (event.type === undefined && event.contexts.state.state.type === 'redux') {\n hint.attachments = [\n ...(hint.attachments || []),\n // @ts-expect-error try catch to reduce bundle size\n { filename: 'redux_state.json', data: JSON.stringify(event.contexts.state.state.value) },\n ];\n }\n } catch (_) {\n // empty\n }\n return event;\n });\n\n const sentryReducer: Reducer<S, A> = (state, action): S => {\n const newState = reducer(state, action);\n\n const scope = getCurrentScope();\n\n /* Action breadcrumbs */\n const transformedAction = options.actionTransformer(action);\n if (typeof transformedAction !== 'undefined' && transformedAction !== null) {\n addBreadcrumb({\n category: ACTION_BREADCRUMB_CATEGORY,\n data: transformedAction,\n type: ACTION_BREADCRUMB_TYPE,\n });\n }\n\n /* Set latest state to scope */\n const transformedState = options.stateTransformer(newState);\n if (typeof transformedState !== 'undefined' && transformedState !== null) {\n const client = getClient();\n const options = client && client.getOptions();\n const normalizationDepth = (options && options.normalizeDepth) || 3; // default state normalization depth to 3\n\n // Set the normalization depth of the redux state to the configured `normalizeDepth` option or a sane number as a fallback\n const newStateContext = { state: { type: 'redux', value: transformedState } };\n addNonEnumerableProperty(\n newStateContext,\n '__sentry_override_normalization_depth__',\n 3 + // 3 layers for `state.value.transformedState`\n normalizationDepth, // rest for the actual state\n );\n\n scope.setContext('state', newStateContext);\n } else {\n scope.setContext('state', null);\n }\n\n /* Allow user to configure scope with latest state */\n const { configureScopeWithState } = options;\n if (typeof configureScopeWithState === 'function') {\n configureScopeWithState(scope, newState);\n }\n\n return newState;\n };\n\n return next(sentryReducer, initialState);\n };\n}\n\nexport { createReduxEnhancer };\n"],"names":["getGlobalScope","getCurrentScope","addBreadcrumb","getClient","addNonEnumerableProperty"],"mappings":";;;;AA0EA,MAAM,0BAAA,GAA6B,cAAc;AACjD,MAAM,sBAAA,GAAyB,MAAM;;AAErC,MAAM,cAAc,GAA0B;AAC9C,EAAE,gBAAgB,EAAE,IAAI;AACxB,EAAE,iBAAiB,EAAE,MAAO,IAAG,MAAM;AACrC,EAAE,gBAAgB,EAAE,KAAA,IAAS,KAAA,IAAS,IAAI;AAC1C,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,SAAS,mBAAmB,CAAC,eAAe,EAAwC;AACpF;AACA,EAAE,MAAM,UAAU;AAClB,IAAI,GAAG,cAAc;AACrB,IAAI,GAAG,eAAe;AACtB,GAAG;;AAEH,EAAE,OAAO,CAAC,IAAI;AACd,IAAI,CAAwC,OAAO,EAAiB,YAAY,KAAyB;AACzG,MAAM,OAAO,CAAC,gBAAiB;AAC/B,QAAQA,mBAAc,EAAE,CAAC,iBAAiB,CAAC,CAAC,KAAK,EAAE,IAAI,KAAK;AAC5D,UAAU,IAAI;AACd;AACA,YAAY,IAAI,KAAK,CAAC,IAAK,KAAI,aAAa,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,IAAK,KAAI,OAAO,EAAE;AACzF,cAAc,IAAI,CAAC,WAAA,G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AACvF,UAAUC,6BAAwB;AAClC,YAAY,eAAe;AAC3B,YAAY,yCAAyC;AACrD,YAAY,CAAE;AACd,cAAc,kBAAkB;AAChC,WAAW;;AAEX,UAAU,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,eAAe,CAAC;AACpD,eAAe;AACf,UAAU,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC;AACzC;;AAEA;AACA,QAAQ,MAAM,EAAE,uBAAwB,EAAA,GAAI,OAAO;AACnD,QAAQ,IAAI,OAAO,uBAAwB,KAAI,UAAU,EAAE;AAC3D,UAAU,uBAAuB,CAAC,KAAK,EAAE,QAAQ,CAAC;AAClD;;AAEA,QAAQ,OAAO,QAAQ;AACvB,OAAO;;AAEP,MAAM,OAAO,IAAI,CAAC,aAAa,EAAE,YAAY,CAAC;AAC9C,KAAK;AACL;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import type { BrowserOptions } from '@sentry/browser';\nimport { init as browserInit, setContext } from '@sentry/browser';\nimport { applySdkMetadata } from '@sentry/core';\nimport type { Client } from '@sentry/types';\n\nimport { version } from 'react';\n\n/**\n * Inits the React SDK\n */\nexport function init(options: BrowserOptions): Client | undefined {\n const opts = {\n ...options,\n };\n\n applySdkMetadata(opts, 'react');\n setContext('react', { version });\n return browserInit(opts);\n}\n"],"names":["applySdkMetadata","setContext","version","browserInit"],"mappings":";;;;;;AAOA;AACA;AACA;AACO,SAAS,IAAI,CAAC,OAAO,EAAsC;AAClE,EAAE,MAAM,OAAO;AACf,IAAI,GAAG,OAAO;AACd,GAAG;;AAEH,EAAEA,qBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC;AACjC,EAAEC,kBAAU,CAAC,OAAO,EAAE,WAAEC,aAAA,EAAS,CAAC;AAClC,EAAE,OAAOC,YAAW,CAAC,IAAI,CAAC;AAC1B;;;;"}
1
+ {"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import type { BrowserOptions } from '@sentry/browser';\nimport { init as browserInit, setContext } from '@sentry/browser';\nimport { applySdkMetadata } from '@sentry/core';\nimport type { Client } from '@sentry/core';\n\nimport { version } from 'react';\n\n/**\n * Inits the React SDK\n */\nexport function init(options: BrowserOptions): Client | undefined {\n const opts = {\n ...options,\n };\n\n applySdkMetadata(opts, 'react');\n setContext('react', { version });\n return browserInit(opts);\n}\n"],"names":["applySdkMetadata","setContext","version","browserInit"],"mappings":";;;;;;AAOA;AACA;AACA;AACO,SAAS,IAAI,CAAC,OAAO,EAAsC;AAClE,EAAE,MAAM,OAAO;AACf,IAAI,GAAG,OAAO;AACd,GAAG;;AAEH,EAAEA,qBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC;AACjC,EAAEC,kBAAU,CAAC,OAAO,EAAE,WAAEC,aAAA,EAAS,CAAC;AAClC,EAAE,OAAOC,YAAW,CAAC,IAAI,CAAC;AAC1B;;;;"}