@sentry/react 8.0.0-alpha.2 → 8.0.0-alpha.4

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.
@@ -24,19 +24,17 @@ function _interopNamespace(e) {
24
24
  const hoistNonReactStatics__default = /*#__PURE__*/_interopDefault(hoistNonReactStatics);
25
25
  const React__namespace = /*#__PURE__*/_interopNamespace(React);
26
26
 
27
- const _jsxFileName = "/home/runner/work/sentry-javascript/sentry-javascript/packages/react/src/reactrouterv6.tsx";/* eslint-disable max-lines */
28
-
29
- let activeTransaction;
27
+ const _jsxFileName = "/home/runner/work/sentry-javascript/sentry-javascript/packages/react/src/reactrouterv6.tsx";// Inspired from Donnie McNeal's solution:
30
28
 
31
29
  let _useEffect;
32
30
  let _useLocation;
33
31
  let _useNavigationType;
34
32
  let _createRoutesFromChildren;
35
33
  let _matchRoutes;
36
- let _customStartTransaction;
37
- let _startTransactionOnLocationChange;
38
34
  let _stripBasename = false;
39
35
 
36
+ const CLIENTS_WITH_INSTRUMENT_NAVIGATION = [];
37
+
40
38
  /**
41
39
  * A browser tracing integration that uses React Router v3 to instrument navigations.
42
40
  * Expects `history` (and optionally `routes` and `matchPath`) to be passed as options.
@@ -66,11 +64,6 @@ function reactRouterV6BrowserTracingIntegration(
66
64
  afterAllSetup(client) {
67
65
  integration.afterAllSetup(client);
68
66
 
69
- const startNavigationCallback = (startSpanOptions) => {
70
- browser.startBrowserTracingNavigationSpan(client, startSpanOptions);
71
- return undefined;
72
- };
73
-
74
67
  const initPathName = browser.WINDOW && browser.WINDOW.location && browser.WINDOW.location.pathname;
75
68
  if (instrumentPageLoad && initPathName) {
76
69
  browser.startBrowserTracingPageLoadSpan(client, {
@@ -90,8 +83,9 @@ function reactRouterV6BrowserTracingIntegration(
90
83
  _createRoutesFromChildren = createRoutesFromChildren;
91
84
  _stripBasename = stripBasename || false;
92
85
 
93
- _customStartTransaction = startNavigationCallback;
94
- _startTransactionOnLocationChange = instrumentNavigation;
86
+ if (instrumentNavigation) {
87
+ CLIENTS_WITH_INSTRUMENT_NAVIGATION.push(client);
88
+ }
95
89
  },
96
90
  };
97
91
  }
@@ -182,10 +176,15 @@ function updatePageloadTransaction(
182
176
  ? matches
183
177
  : (_matchRoutes(routes, location, basename) );
184
178
 
185
- if (activeRootSpan && branches) {
179
+ if (branches) {
186
180
  const [name, source] = getNormalizedName(routes, location, branches, basename);
187
- activeRootSpan.updateName(name);
188
- activeRootSpan.setAttribute(core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, source);
181
+
182
+ core.getCurrentScope().setTransactionName(name);
183
+
184
+ if (activeRootSpan) {
185
+ activeRootSpan.updateName(name);
186
+ activeRootSpan.setAttribute(core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, source);
187
+ }
189
188
  }
190
189
  }
191
190
 
@@ -198,13 +197,15 @@ function handleNavigation(
198
197
  ) {
199
198
  const branches = Array.isArray(matches) ? matches : _matchRoutes(routes, location, basename);
200
199
 
201
- if (_startTransactionOnLocationChange && (navigationType === 'PUSH' || navigationType === 'POP') && branches) {
202
- if (activeTransaction) {
203
- activeTransaction.end();
204
- }
200
+ const client = core.getClient();
201
+ if (!client || !CLIENTS_WITH_INSTRUMENT_NAVIGATION.includes(client)) {
202
+ return;
203
+ }
205
204
 
205
+ if ((navigationType === 'PUSH' || navigationType === 'POP') && branches) {
206
206
  const [name, source] = getNormalizedName(routes, location, branches, basename);
207
- activeTransaction = _customStartTransaction({
207
+
208
+ browser.startBrowserTracingNavigationSpan(client, {
208
209
  name,
209
210
  attributes: {
210
211
  [core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,
@@ -217,18 +218,11 @@ function handleNavigation(
217
218
 
218
219
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
219
220
  function withSentryReactRouterV6Routing(Routes) {
220
- if (
221
- !_useEffect ||
222
- !_useLocation ||
223
- !_useNavigationType ||
224
- !_createRoutesFromChildren ||
225
- !_matchRoutes ||
226
- !_customStartTransaction
227
- ) {
221
+ if (!_useEffect || !_useLocation || !_useNavigationType || !_createRoutesFromChildren || !_matchRoutes) {
228
222
  debugBuild.DEBUG_BUILD &&
229
223
  utils.logger.warn(`reactRouterV6Instrumentation was unable to wrap Routes because of one or more missing parameters.
230
224
  useEffect: ${_useEffect}. useLocation: ${_useLocation}. useNavigationType: ${_useNavigationType}.
231
- createRoutesFromChildren: ${_createRoutesFromChildren}. matchRoutes: ${_matchRoutes}. customStartTransaction: ${_customStartTransaction}.`);
225
+ createRoutesFromChildren: ${_createRoutesFromChildren}. matchRoutes: ${_matchRoutes}.`);
232
226
 
233
227
  return Routes;
234
228
  }
@@ -257,7 +251,7 @@ function withSentryReactRouterV6Routing(Routes) {
257
251
 
258
252
  // @ts-expect-error Setting more specific React Component typing for `R` generic above
259
253
  // will break advanced type inference done by react router params
260
- return React__namespace.createElement(Routes, { ...props, __self: this, __source: {fileName: _jsxFileName, lineNumber: 329}} );
254
+ return React__namespace.createElement(Routes, { ...props, __self: this, __source: {fileName: _jsxFileName, lineNumber: 277}} );
261
255
  };
262
256
 
263
257
  hoistNonReactStatics__default(SentryRoutes, Routes);
@@ -268,7 +262,7 @@ function withSentryReactRouterV6Routing(Routes) {
268
262
  }
269
263
 
270
264
  function wrapUseRoutes(origUseRoutes) {
271
- if (!_useEffect || !_useLocation || !_useNavigationType || !_matchRoutes || !_customStartTransaction) {
265
+ if (!_useEffect || !_useLocation || !_useNavigationType || !_matchRoutes) {
272
266
  debugBuild.DEBUG_BUILD &&
273
267
  utils.logger.warn(
274
268
  'reactRouterV6Instrumentation was unable to wrap `useRoutes` because of one or more missing parameters.',
@@ -312,7 +306,7 @@ function wrapUseRoutes(origUseRoutes) {
312
306
 
313
307
  // eslint-disable-next-line react/display-name
314
308
  return (routes, locationArg) => {
315
- return React__namespace.createElement(SentryRoutes, { routes: routes, locationArg: locationArg, __self: this, __source: {fileName: _jsxFileName, lineNumber: 386}} );
309
+ return React__namespace.createElement(SentryRoutes, { routes: routes, locationArg: locationArg, __self: this, __source: {fileName: _jsxFileName, lineNumber: 334}} );
316
310
  };
317
311
  }
318
312
 
@@ -337,7 +331,7 @@ function wrapCreateBrowserRouter
337
331
 
338
332
  router.subscribe((state) => {
339
333
  const location = state.location;
340
- if (_startTransactionOnLocationChange && (state.historyAction === 'PUSH' || state.historyAction === 'POP')) {
334
+ if (state.historyAction === 'PUSH' || state.historyAction === 'POP') {
341
335
  handleNavigation(location, routes, state.historyAction, undefined, basename);
342
336
  }
343
337
  });
@@ -347,11 +341,6 @@ function wrapCreateBrowserRouter
347
341
  }
348
342
 
349
343
  function getActiveRootSpan() {
350
- // Legacy behavior for "old" react router instrumentation
351
- if (activeTransaction) {
352
- return activeTransaction;
353
- }
354
-
355
344
  const span = core.getActiveSpan();
356
345
  const rootSpan = span ? core.getRootSpan(span) : undefined;
357
346
 
@@ -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 getRootSpan,\n spanToJSON,\n} from '@sentry/core';\nimport type {\n Integration,\n Span,\n StartSpanOptions,\n Transaction,\n TransactionContext,\n TransactionSource,\n} from '@sentry/types';\nimport { getNumberOfUrlSegments, logger } from '@sentry/utils';\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 activeTransaction: Transaction | undefined;\n\nlet _useEffect: UseEffect;\nlet _useLocation: UseLocation;\nlet _useNavigationType: UseNavigationType;\nlet _createRoutesFromChildren: CreateRoutesFromChildren;\nlet _matchRoutes: MatchRoutes;\nlet _customStartTransaction: (context: TransactionContext) => Transaction | undefined;\nlet _startTransactionOnLocationChange: boolean;\nlet _stripBasename: boolean = false;\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 v3 to instrument navigations.\n * Expects `history` (and optionally `routes` and `matchPath`) 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 afterAllSetup(client) {\n integration.afterAllSetup(client);\n\n const startNavigationCallback = (startSpanOptions: StartSpanOptions): undefined => {\n startBrowserTracingNavigationSpan(client, startSpanOptions);\n return undefined;\n };\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 _useEffect = useEffect;\n _useLocation = useLocation;\n _useNavigationType = useNavigationType;\n _matchRoutes = matchRoutes;\n _createRoutesFromChildren = createRoutesFromChildren;\n _stripBasename = stripBasename || false;\n\n _customStartTransaction = startNavigationCallback;\n _startTransactionOnLocationChange = instrumentNavigation;\n },\n };\n}\n\n/**\n * @deprecated Use `reactRouterV6BrowserTracingIntegration()` instead.\n */\nexport function reactRouterV6Instrumentation(\n useEffect: UseEffect,\n useLocation: UseLocation,\n useNavigationType: UseNavigationType,\n createRoutesFromChildren: CreateRoutesFromChildren,\n matchRoutes: MatchRoutes,\n stripBasename?: boolean,\n) {\n return (\n customStartTransaction: (context: TransactionContext) => Transaction | undefined,\n startTransactionOnPageLoad = true,\n startTransactionOnLocationChange = true,\n ): void => {\n const initPathName = WINDOW && WINDOW.location && WINDOW.location.pathname;\n if (startTransactionOnPageLoad && initPathName) {\n activeTransaction = customStartTransaction({\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 _useEffect = useEffect;\n _useLocation = useLocation;\n _useNavigationType = useNavigationType;\n _matchRoutes = matchRoutes;\n _createRoutesFromChildren = createRoutesFromChildren;\n _stripBasename = stripBasename || false;\n\n _customStartTransaction = customStartTransaction;\n _startTransactionOnLocationChange = startTransactionOnLocationChange;\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 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 // eslint-disable-next-line @typescript-eslint/prefer-for-of\n for (let x = 0; x < branches.length; x++) {\n const branch = branches[x];\n const route = branch.route;\n if (route) {\n // Early return if index route\n if (route.index) {\n return [_stripBasename ? stripBasenameFromPathname(branch.pathname, basename) : branch.pathname, 'route'];\n }\n\n const path = route.path;\n if (path) {\n const newPath = path[0] === '/' || pathBuilder[pathBuilder.length - 1] === '/' ? path : `/${path}`;\n pathBuilder += newPath;\n\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 / seperators\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 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 (activeRootSpan && branches) {\n const [name, source] = getNormalizedName(routes, location, branches, basename);\n activeRootSpan.updateName(name);\n activeRootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, source);\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 if (_startTransactionOnLocationChange && (navigationType === 'PUSH' || navigationType === 'POP') && branches) {\n if (activeTransaction) {\n activeTransaction.end();\n }\n\n const [name, source] = getNormalizedName(routes, location, branches, basename);\n activeTransaction = _customStartTransaction({\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 (\n !_useEffect ||\n !_useLocation ||\n !_useNavigationType ||\n !_createRoutesFromChildren ||\n !_matchRoutes ||\n !_customStartTransaction\n ) {\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}. customStartTransaction: ${_customStartTransaction}.`);\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 purpusely 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 || !_customStartTransaction) {\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 // `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 (_startTransactionOnLocationChange && (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 // Legacy behavior for \"old\" react router instrumentation\n if (activeTransaction) {\n return activeTransaction;\n }\n\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","startBrowserTracingNavigationSpan","WINDOW","startBrowserTracingPageLoadSpan","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","SEMANTIC_ATTRIBUTE_SENTRY_OP","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","getNumberOfUrlSegments","DEBUG_BUILD","logger","React","hoistNonReactStatics","getActiveSpan","getRootSpan","spanToJSON"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAA,YAAA,GAAA,4FAAA,CAAA;;AAgDA,IAAI,iBAAiB,CAAA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AACA;AACA,EAAA,MAAA,IAAA,GAAAE,kBAAA,EAAA,CAAA;AACA,EAAA,MAAA,QAAA,GAAA,IAAA,GAAAC,gBAAA,CAAA,IAAA,CAAA,GAAA,SAAA,CAAA;AACA;AACA,EAAA,IAAA,CAAA,QAAA,EAAA;AACA,IAAA,OAAA,SAAA,CAAA;AACA,GAAA;AACA;AACA,EAAA,MAAA,EAAA,GAAAC,eAAA,CAAA,QAAA,CAAA,CAAA,EAAA,CAAA;AACA;AACA;AACA,EAAA,OAAA,EAAA,KAAA,YAAA,IAAA,EAAA,KAAA,UAAA,GAAA,QAAA,GAAA,SAAA,CAAA;AACA;;;;;;;"}
1
+ {"version":3,"file":"reactrouterv6.js","sources":["../../src/reactrouterv6.tsx"],"sourcesContent":["// 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 type { Client, Integration, Span, TransactionSource } from '@sentry/types';\nimport { getNumberOfUrlSegments, logger } from '@sentry/utils';\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: 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 v3 to instrument navigations.\n * Expects `history` (and optionally `routes` and `matchPath`) 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 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 _useEffect = useEffect;\n _useLocation = useLocation;\n _useNavigationType = useNavigationType;\n _matchRoutes = matchRoutes;\n _createRoutesFromChildren = createRoutesFromChildren;\n _stripBasename = stripBasename || false;\n\n if (instrumentNavigation) {\n CLIENTS_WITH_INSTRUMENT_NAVIGATION.push(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 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 // eslint-disable-next-line @typescript-eslint/prefer-for-of\n for (let x = 0; x < branches.length; x++) {\n const branch = branches[x];\n const route = branch.route;\n if (route) {\n // Early return if index route\n if (route.index) {\n return [_stripBasename ? stripBasenameFromPathname(branch.pathname, basename) : branch.pathname, 'route'];\n }\n\n const path = route.path;\n if (path) {\n const newPath = path[0] === '/' || pathBuilder[pathBuilder.length - 1] === '/' ? path : `/${path}`;\n pathBuilder += newPath;\n\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 / seperators\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 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.includes(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 purpusely 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 // `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"],"m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AAA,SAAA,CAAA;AACA;AACA,EAAA,IAAA,CAAA,QAAA,EAAA;AACA,IAAA,OAAA,SAAA,CAAA;AACA,GAAA;AACA;AACA,EAAA,MAAA,EAAA,GAAAC,eAAA,CAAA,QAAA,CAAA,CAAA,EAAA,CAAA;AACA;AACA;AACA,EAAA,OAAA,EAAA,KAAA,YAAA,IAAA,EAAA,KAAA,UAAA,GAAA,QAAA,GAAA,SAAA,CAAA;AACA;;;;;;;"}
package/cjs/redux.js.map CHANGED
@@ -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 type { Scope } from '@sentry/types';\nimport { addNonEnumerableProperty } from '@sentry/utils';\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,CAAA;AACjD,MAAM,sBAAA,GAAyB,MAAM,CAAA;AACrC;AACA,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,CAAA;AACD;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,mBAAmB,CAAC,eA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cesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { addBreadcrumb, getClient, getCurrentScope, getGlobalScope } from '@sentry/core';\nimport type { Scope } from '@sentry/types';\nimport { addNonEnumerableProperty } from '@sentry/utils';\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,CAAA;AACjD,MAAM,sBAAA,GAAyB,MAAM,CAAA;AACrC;AACA,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,CAAA;AACD;AACA;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,CAAA;AACH;AACA,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,K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,MAAM,kBAAmB,GAAE,CAAC,OAAA,IAAW,OAAO,CAAC,cAAc,KAAK,CAAC,CAAA;AAC7E;AACA;AACA,UAAU,MAAM,eAAA,GAAkB,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,gBAAA,IAAoB,CAAA;AACvF,UAAUC,8BAAwB;AAClC,YAAY,eAAe;AAC3B,YAAY,yCAAyC;AACrD,YAAY,CAAE;AACd,cAAc,kBAAkB;AAChC,WAAW,CAAA;AACX;AACA,UAAU,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,eAAe,CAAC,CAAA;AACpD,eAAe;AACf,UAAU,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;AACzC,SAAQ;AACR;AACA;AACA,QAAQ,MAAM,EAAE,uBAAwB,EAAA,GAAI,OAAO,CAAA;AACnD,QAAQ,IAAI,OAAO,uBAAwB,KAAI,UAAU,EAAE;AAC3D,UAAU,uBAAuB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;AAClD,SAAQ;AACR;AACA,QAAQ,OAAO,QAAQ,CAAA;AACvB,OAAO,CAAA;AACP;AACA,MAAM,OAAO,IAAI,CAAC,aAAa,EAAE,YAAY,CAAC,CAAA;AAC9C,KAAK,CAAA;AACL;;;;"}
@@ -90,7 +90,9 @@ class ErrorBoundary extends React.Component {
90
90
  captureContext: {
91
91
  contexts: { react: { componentStack } },
92
92
  },
93
- mechanism: { handled: false },
93
+ // If users provide a fallback component we can assume they are handling the error.
94
+ // Therefore, we set the mechanism depending on the presence of the fallback prop.
95
+ mechanism: { handled: !!this.props.fallback },
94
96
  });
95
97
 
96
98
  if (onError) {
@@ -140,7 +142,7 @@ class ErrorBoundary extends React.Component {
140
142
  if (state.error) {
141
143
  let element = undefined;
142
144
  if (typeof fallback === 'function') {
143
- element = fallback({
145
+ element = React.createElement(fallback, {
144
146
  error: state.error,
145
147
  componentStack: state.componentStack,
146
148
  resetError: this.resetErrorBoundary,
@@ -178,8 +180,8 @@ function withErrorBoundary(
178
180
  const componentDisplayName = WrappedComponent.displayName || WrappedComponent.name || UNKNOWN_COMPONENT;
179
181
 
180
182
  const Wrapped = (props) => (
181
- React.createElement(ErrorBoundary, { ...errorBoundaryOptions, __self: this, __source: {fileName: _jsxFileName, lineNumber: 237}}
182
- , React.createElement(WrappedComponent, { ...props, __self: this, __source: {fileName: _jsxFileName, lineNumber: 238}} )
183
+ React.createElement(ErrorBoundary, { ...errorBoundaryOptions, __self: this, __source: {fileName: _jsxFileName, lineNumber: 239}}
184
+ , React.createElement(WrappedComponent, { ...props, __self: this, __source: {fileName: _jsxFileName, lineNumber: 240}} )
183
185
  )
184
186
  );
185
187
 
@@ -1 +1 @@
1
- {"version":3,"file":"errorboundary.js","sources":["../../src/errorboundary.tsx"],"sourcesContent":["import type { ReportDialogOptions } from '@sentry/browser';\nimport { captureException, getClient, showReportDialog, withScope } from '@sentry/browser';\nimport type { Scope } from '@sentry/types';\nimport { isError, logger } from '@sentry/utils';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\n\nimport { DEBUG_BUILD } from './debug-build';\n\nexport function isAtLeastReact17(version: string): boolean {\n const major = version.match(/^([^.]+)/);\n return major !== null && parseInt(major[0]) >= 17;\n}\n\nexport const UNKNOWN_COMPONENT = 'unknown';\n\nexport type FallbackRender = (errorData: {\n error: Error;\n componentStack: string;\n eventId: string;\n resetError(): void;\n}) => React.ReactElement;\n\nexport type ErrorBoundaryProps = {\n children?: React.ReactNode | (() => React.ReactNode);\n /** If a Sentry report dialog should be rendered on error */\n showDialog?: boolean | undefined;\n /**\n * Options to be passed into the Sentry report dialog.\n * No-op if {@link showDialog} is false.\n */\n dialogOptions?: Omit<ReportDialogOptions, 'eventId'> | undefined;\n /**\n * A fallback component that gets rendered when the error boundary encounters an error.\n *\n * Can either provide a React Component, or a function that returns React Component as\n * a valid fallback prop. If a function is provided, the function will be called with\n * the error, the component stack, and an function that resets the error boundary on error.\n *\n */\n fallback?: React.ReactElement | FallbackRender | undefined;\n /** Called when the error boundary encounters an error */\n onError?: ((error: Error, componentStack: string, eventId: string) => void) | undefined;\n /** Called on componentDidMount() */\n onMount?: (() => void) | undefined;\n /** Called if resetError() is called from the fallback render props function */\n onReset?: ((error: Error | null, componentStack: string | null, eventId: string | null) => void) | undefined;\n /** Called on componentWillUnmount() */\n onUnmount?: ((error: Error | null, componentStack: string | null, eventId: string | null) => void) | undefined;\n /** Called before the error is captured by Sentry, allows for you to add tags or context using the scope */\n beforeCapture?: ((scope: Scope, error: Error | null, componentStack: string | null) => void) | undefined;\n};\n\ntype ErrorBoundaryState =\n | {\n componentStack: null;\n error: null;\n eventId: null;\n }\n | {\n componentStack: React.ErrorInfo['componentStack'];\n error: Error;\n eventId: string;\n };\n\nconst INITIAL_STATE = {\n componentStack: null,\n error: null,\n eventId: null,\n};\n\nfunction setCause(error: Error & { cause?: Error }, cause: Error): void {\n const seenErrors = new WeakMap<Error, boolean>();\n\n function recurse(error: Error & { cause?: Error }, cause: Error): void {\n // If we've already seen the error, there is a recursive loop somewhere in the error's\n // cause chain. Let's just bail out then to prevent a stack overflow.\n if (seenErrors.has(error)) {\n return;\n }\n if (error.cause) {\n seenErrors.set(error, true);\n return recurse(error.cause, cause);\n }\n error.cause = cause;\n }\n\n recurse(error, cause);\n}\n\n/**\n * A ErrorBoundary component that logs errors to Sentry.\n * NOTE: If you are a Sentry user, and you are seeing this stack frame, it means the\n * Sentry React SDK ErrorBoundary caught an error invoking your application code. This\n * is expected behavior and NOT indicative of a bug with the Sentry React SDK.\n */\nclass ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {\n public state: ErrorBoundaryState;\n\n private readonly _openFallbackReportDialog: boolean;\n\n private _lastEventId?: string;\n\n public constructor(props: ErrorBoundaryProps) {\n super(props);\n\n this.state = INITIAL_STATE;\n this._openFallbackReportDialog = true;\n\n const client = getClient();\n if (client && props.showDialog) {\n this._openFallbackReportDialog = false;\n client.on('afterSendEvent', event => {\n if (!event.type && this._lastEventId && event.event_id === this._lastEventId) {\n showReportDialog({ ...props.dialogOptions, eventId: this._lastEventId });\n }\n });\n }\n }\n\n public componentDidCatch(error: Error & { cause?: Error }, { componentStack }: React.ErrorInfo): void {\n const { beforeCapture, onError, showDialog, dialogOptions } = this.props;\n withScope(scope => {\n // If on React version >= 17, create stack trace from componentStack param and links\n // to to the original error using `error.cause` otherwise relies on error param for stacktrace.\n // Linking errors requires the `LinkedErrors` integration be enabled.\n // See: https://reactjs.org/blog/2020/08/10/react-v17-rc.html#native-component-stacks\n //\n // Although `componentDidCatch` is typed to accept an `Error` object, it can also be invoked\n // with non-error objects. This is why we need to check if the error is an error-like object.\n // See: https://github.com/getsentry/sentry-javascript/issues/6167\n if (isAtLeastReact17(React.version) && isError(error)) {\n const errorBoundaryError = new Error(error.message);\n errorBoundaryError.name = `React ErrorBoundary ${error.name}`;\n errorBoundaryError.stack = componentStack;\n\n // Using the `LinkedErrors` integration to link the errors together.\n setCause(error, errorBoundaryError);\n }\n\n if (beforeCapture) {\n beforeCapture(scope, error, componentStack);\n }\n\n const eventId = captureException(error, {\n captureContext: {\n contexts: { react: { componentStack } },\n },\n mechanism: { handled: false },\n });\n\n if (onError) {\n onError(error, componentStack, eventId);\n }\n if (showDialog) {\n this._lastEventId = eventId;\n if (this._openFallbackReportDialog) {\n showReportDialog({ ...dialogOptions, eventId });\n }\n }\n\n // componentDidCatch is used over getDerivedStateFromError\n // so that componentStack is accessible through state.\n this.setState({ error, componentStack, eventId });\n });\n }\n\n public componentDidMount(): void {\n const { onMount } = this.props;\n if (onMount) {\n onMount();\n }\n }\n\n public componentWillUnmount(): void {\n const { error, componentStack, eventId } = this.state;\n const { onUnmount } = this.props;\n if (onUnmount) {\n onUnmount(error, componentStack, eventId);\n }\n }\n\n public resetErrorBoundary: () => void = () => {\n const { onReset } = this.props;\n const { error, componentStack, eventId } = this.state;\n if (onReset) {\n onReset(error, componentStack, eventId);\n }\n this.setState(INITIAL_STATE);\n };\n\n public render(): React.ReactNode {\n const { fallback, children } = this.props;\n const state = this.state;\n\n if (state.error) {\n let element: React.ReactElement | undefined = undefined;\n if (typeof fallback === 'function') {\n element = fallback({\n error: state.error,\n componentStack: state.componentStack,\n resetError: this.resetErrorBoundary,\n eventId: state.eventId,\n });\n } else {\n element = fallback;\n }\n\n if (React.isValidElement(element)) {\n return element;\n }\n\n if (fallback) {\n DEBUG_BUILD && logger.warn('fallback did not produce a valid ReactElement');\n }\n\n // Fail gracefully if no fallback provided or is not valid\n return null;\n }\n\n if (typeof children === 'function') {\n return (children as () => React.ReactNode)();\n }\n return children;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction withErrorBoundary<P extends Record<string, any>>(\n WrappedComponent: React.ComponentType<P>,\n errorBoundaryOptions: ErrorBoundaryProps,\n): React.FC<P> {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const componentDisplayName = WrappedComponent.displayName || WrappedComponent.name || UNKNOWN_COMPONENT;\n\n const Wrapped: React.FC<P> = (props: P) => (\n <ErrorBoundary {...errorBoundaryOptions}>\n <WrappedComponent {...props} />\n </ErrorBoundary>\n );\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n Wrapped.displayName = `errorBoundary(${componentDisplayName})`;\n\n // Copy over static methods from Wrapped component to Profiler HOC\n // See: https://reactjs.org/docs/higher-order-components.html#static-methods-must-be-copied-over\n hoistNonReactStatics(Wrapped, WrappedComponent);\n return Wrapped;\n}\n\nexport { ErrorBoundary, withErrorBoundary };\n"],"names":[],"mappings":";;;;;;AAAA,MAAA,YAAA,GAAA,4FAAA,CAAA;AAQA;AACO,SAAS,gBAAgB,CAAC,OAAO,EAAmB;AAC3D,EAAE,MAAM,QAAQ,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;AACzC,EAAE,OAAO,KAAA,KAAU,IAAA,IAAQ,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,C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AA;AACA;AACA;AACA,SAAA,iBAAA;AACA,EAAA,gBAAA;AACA,EAAA,oBAAA;AACA,EAAA;AACA;AACA,EAAA,MAAA,oBAAA,GAAA,gBAAA,CAAA,WAAA,IAAA,gBAAA,CAAA,IAAA,IAAA,iBAAA,CAAA;AACA;AACA,EAAA,MAAA,OAAA,GAAA,CAAA,KAAA;AACA,IAAA,KAAA,CAAA,aAAA,CAAA,aAAA,EAAA,EAAA,GAAA,oBAAA,EAAA,MAAA,EAAA,IAAA,EAAA,QAAA,EAAA,CAAA,QAAA,EAAA,YAAA,EAAA,UAAA,EAAA,GAAA,CAAA,CAAA;AACA,QAAA,KAAA,CAAA,aAAA,CAAA,gBAAA,EAAA,EAAA,GAAA,KAAA,EAAA,MAAA,EAAA,IAAA,EAAA,QAAA,EAAA,CAAA,QAAA,EAAA,YAAA,EAAA,UAAA,EAAA,GAAA,CAAA,CAAA,EAAA;AACA,KAAA;AACA,GAAA,CAAA;AACA;AACA;AACA,EAAA,OAAA,CAAA,WAAA,GAAA,CAAA,cAAA,EAAA,oBAAA,CAAA,CAAA,CAAA,CAAA;AACA;AACA;AACA;AACA,EAAA,oBAAA,CAAA,OAAA,EAAA,gBAAA,CAAA,CAAA;AACA,EAAA,OAAA,OAAA,CAAA;AACA;;;;"}
1
+ {"version":3,"file":"errorboundary.js","sources":["../../src/errorboundary.tsx"],"sourcesContent":["import type { ReportDialogOptions } from '@sentry/browser';\nimport { captureException, getClient, showReportDialog, withScope } from '@sentry/browser';\nimport type { Scope } from '@sentry/types';\nimport { isError, logger } from '@sentry/utils';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\n\nimport { DEBUG_BUILD } from './debug-build';\n\nexport function isAtLeastReact17(version: string): boolean {\n const major = version.match(/^([^.]+)/);\n return major !== null && parseInt(major[0]) >= 17;\n}\n\nexport const UNKNOWN_COMPONENT = 'unknown';\n\nexport type FallbackRender = (errorData: {\n error: Error;\n componentStack: string;\n eventId: string;\n resetError(): void;\n}) => React.ReactElement;\n\nexport type ErrorBoundaryProps = {\n children?: React.ReactNode | (() => React.ReactNode);\n /** If a Sentry report dialog should be rendered on error */\n showDialog?: boolean | undefined;\n /**\n * Options to be passed into the Sentry report dialog.\n * No-op if {@link showDialog} is false.\n */\n dialogOptions?: Omit<ReportDialogOptions, 'eventId'> | undefined;\n /**\n * A fallback component that gets rendered when the error boundary encounters an error.\n *\n * Can either provide a React Component, or a function that returns React Component as\n * a valid fallback prop. If a function is provided, the function will be called with\n * the error, the component stack, and an function that resets the error boundary on error.\n *\n */\n fallback?: React.ReactElement | FallbackRender | undefined;\n /** Called when the error boundary encounters an error */\n onError?: ((error: Error, componentStack: string, eventId: string) => void) | undefined;\n /** Called on componentDidMount() */\n onMount?: (() => void) | undefined;\n /** Called if resetError() is called from the fallback render props function */\n onReset?: ((error: Error | null, componentStack: string | null, eventId: string | null) => void) | undefined;\n /** Called on componentWillUnmount() */\n onUnmount?: ((error: Error | null, componentStack: string | null, eventId: string | null) => void) | undefined;\n /** Called before the error is captured by Sentry, allows for you to add tags or context using the scope */\n beforeCapture?: ((scope: Scope, error: Error | null, componentStack: string | null) => void) | undefined;\n};\n\ntype ErrorBoundaryState =\n | {\n componentStack: null;\n error: null;\n eventId: null;\n }\n | {\n componentStack: React.ErrorInfo['componentStack'];\n error: Error;\n eventId: string;\n };\n\nconst INITIAL_STATE = {\n componentStack: null,\n error: null,\n eventId: null,\n};\n\nfunction setCause(error: Error & { cause?: Error }, cause: Error): void {\n const seenErrors = new WeakMap<Error, boolean>();\n\n function recurse(error: Error & { cause?: Error }, cause: Error): void {\n // If we've already seen the error, there is a recursive loop somewhere in the error's\n // cause chain. Let's just bail out then to prevent a stack overflow.\n if (seenErrors.has(error)) {\n return;\n }\n if (error.cause) {\n seenErrors.set(error, true);\n return recurse(error.cause, cause);\n }\n error.cause = cause;\n }\n\n recurse(error, cause);\n}\n\n/**\n * A ErrorBoundary component that logs errors to Sentry.\n * NOTE: If you are a Sentry user, and you are seeing this stack frame, it means the\n * Sentry React SDK ErrorBoundary caught an error invoking your application code. This\n * is expected behavior and NOT indicative of a bug with the Sentry React SDK.\n */\nclass ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {\n public state: ErrorBoundaryState;\n\n private readonly _openFallbackReportDialog: boolean;\n\n private _lastEventId?: string;\n\n public constructor(props: ErrorBoundaryProps) {\n super(props);\n\n this.state = INITIAL_STATE;\n this._openFallbackReportDialog = true;\n\n const client = getClient();\n if (client && props.showDialog) {\n this._openFallbackReportDialog = false;\n client.on('afterSendEvent', event => {\n if (!event.type && this._lastEventId && event.event_id === this._lastEventId) {\n showReportDialog({ ...props.dialogOptions, eventId: this._lastEventId });\n }\n });\n }\n }\n\n public componentDidCatch(error: Error & { cause?: Error }, { componentStack }: React.ErrorInfo): void {\n const { beforeCapture, onError, showDialog, dialogOptions } = this.props;\n withScope(scope => {\n // If on React version >= 17, create stack trace from componentStack param and links\n // to to the original error using `error.cause` otherwise relies on error param for stacktrace.\n // Linking errors requires the `LinkedErrors` integration be enabled.\n // See: https://reactjs.org/blog/2020/08/10/react-v17-rc.html#native-component-stacks\n //\n // Although `componentDidCatch` is typed to accept an `Error` object, it can also be invoked\n // with non-error objects. This is why we need to check if the error is an error-like object.\n // See: https://github.com/getsentry/sentry-javascript/issues/6167\n if (isAtLeastReact17(React.version) && isError(error)) {\n const errorBoundaryError = new Error(error.message);\n errorBoundaryError.name = `React ErrorBoundary ${error.name}`;\n errorBoundaryError.stack = componentStack;\n\n // Using the `LinkedErrors` integration to link the errors together.\n setCause(error, errorBoundaryError);\n }\n\n if (beforeCapture) {\n beforeCapture(scope, error, componentStack);\n }\n\n const eventId = captureException(error, {\n captureContext: {\n contexts: { react: { componentStack } },\n },\n // If users provide a fallback component we can assume they are handling the error.\n // Therefore, we set the mechanism depending on the presence of the fallback prop.\n mechanism: { handled: !!this.props.fallback },\n });\n\n if (onError) {\n onError(error, componentStack, eventId);\n }\n if (showDialog) {\n this._lastEventId = eventId;\n if (this._openFallbackReportDialog) {\n showReportDialog({ ...dialogOptions, eventId });\n }\n }\n\n // componentDidCatch is used over getDerivedStateFromError\n // so that componentStack is accessible through state.\n this.setState({ error, componentStack, eventId });\n });\n }\n\n public componentDidMount(): void {\n const { onMount } = this.props;\n if (onMount) {\n onMount();\n }\n }\n\n public componentWillUnmount(): void {\n const { error, componentStack, eventId } = this.state;\n const { onUnmount } = this.props;\n if (onUnmount) {\n onUnmount(error, componentStack, eventId);\n }\n }\n\n public resetErrorBoundary: () => void = () => {\n const { onReset } = this.props;\n const { error, componentStack, eventId } = this.state;\n if (onReset) {\n onReset(error, componentStack, eventId);\n }\n this.setState(INITIAL_STATE);\n };\n\n public render(): React.ReactNode {\n const { fallback, children } = this.props;\n const state = this.state;\n\n if (state.error) {\n let element: React.ReactElement | undefined = undefined;\n if (typeof fallback === 'function') {\n element = React.createElement(fallback, {\n error: state.error,\n componentStack: state.componentStack,\n resetError: this.resetErrorBoundary,\n eventId: state.eventId,\n });\n } else {\n element = fallback;\n }\n\n if (React.isValidElement(element)) {\n return element;\n }\n\n if (fallback) {\n DEBUG_BUILD && logger.warn('fallback did not produce a valid ReactElement');\n }\n\n // Fail gracefully if no fallback provided or is not valid\n return null;\n }\n\n if (typeof children === 'function') {\n return (children as () => React.ReactNode)();\n }\n return children;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction withErrorBoundary<P extends Record<string, any>>(\n WrappedComponent: React.ComponentType<P>,\n errorBoundaryOptions: ErrorBoundaryProps,\n): React.FC<P> {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const componentDisplayName = WrappedComponent.displayName || WrappedComponent.name || UNKNOWN_COMPONENT;\n\n const Wrapped: React.FC<P> = (props: P) => (\n <ErrorBoundary {...errorBoundaryOptions}>\n <WrappedComponent {...props} />\n </ErrorBoundary>\n );\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n Wrapped.displayName = `errorBoundary(${componentDisplayName})`;\n\n // Copy over static methods from Wrapped component to Profiler HOC\n // See: https://reactjs.org/docs/higher-order-components.html#static-methods-must-be-copied-over\n hoistNonReactStatics(Wrapped, WrappedComponent);\n return Wrapped;\n}\n\nexport { ErrorBoundary, withErrorBoundary };\n"],"names":[],"mappings":";;;;;;AAAA,MAAA,YAAA,GAAA,4FAAA,CAAA;AAQA;AACO,SAAS,gBAAgB,CAAC,OAAO,EAAmB;AAC3D,EAAE,MAAM,QAAQ,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;AACzC,EAAE,OAAO,KAAA,KAAU,IAAA,IAAQ,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA,IAAK,EAAE,CAAA;AACnD,CAAA;AACA;AACO,MAAM,iBAAkB,GAAE,UAAS;;AAmD1C,MAAM,gBAAgB;AACtB,EAAE,cAAc,EAAE,IAAI;AACtB,EAAE,KAAK,EAAE,IAAI;AACb,EAAE,OAAO,EAAE,IAAI;AACf,CAAC,CAAA;AACD;AACA,SAAS,QAAQ,CAAC,KAAK,EAA6B,KAAK,EAAe;AACxE,EAAE,MAAM,UAAW,GAAE,IAAI,OAAO,EAAkB,CAAA;AAClD;AACA,EAAE,SAAS,OAAO,CAAC,KAAK,EAA6B,KAAK,EAAe;AACzE;AACA;AACA,IAAI,IAAI,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;AAC/B,MAAM,OAAM;AACZ,KAAI;AACJ,IAAI,IAAI,KAAK,CAAC,KAAK,EAAE;AACrB,MAAM,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;AACjC,MAAM,OAAO,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AACxC,KAAI;AACJ,IAAI,KAAK,CAAC,KAAM,GAAE,KAAK,CAAA;AACvB,GAAE;AACF;AACA,EAAE,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AACvB,CAAA;AACA;AACA;AACA;AACA;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,CAAA,CAAA;AACA,EAAA,OAAA,OAAA,CAAA;AACA;;;;"}
@@ -0,0 +1 @@
1
+ { "type": "module" }
@@ -1,5 +1,5 @@
1
1
  import { browserTracingIntegration, startBrowserTracingPageLoadSpan, startBrowserTracingNavigationSpan, WINDOW } from '@sentry/browser';
2
- import { getActiveSpan, getRootSpan, spanToJSON, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '@sentry/core';
2
+ import { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, getActiveSpan, getRootSpan, spanToJSON, getCurrentScope } from '@sentry/core';
3
3
  import hoistNonReactStatics from 'hoist-non-react-statics';
4
4
  import * as React from 'react';
5
5
 
@@ -7,8 +7,6 @@ const _jsxFileName = "/home/runner/work/sentry-javascript/sentry-javascript/pack
7
7
  // We need to disable eslint no-explict-any because any is required for the
8
8
  // react-router typings.
9
9
 
10
- let activeTransaction;
11
-
12
10
  /**
13
11
  * A browser tracing integration that uses React Router v4 to instrument navigations.
14
12
  * Expects `history` (and optionally `routes` and `matchPath`) to be passed as options.
@@ -29,21 +27,15 @@ function reactRouterV4BrowserTracingIntegration(
29
27
  afterAllSetup(client) {
30
28
  integration.afterAllSetup(client);
31
29
 
32
- const startPageloadCallback = (startSpanOptions) => {
33
- startBrowserTracingPageLoadSpan(client, startSpanOptions);
34
- return undefined;
35
- };
36
-
37
- const startNavigationCallback = (startSpanOptions) => {
38
- startBrowserTracingNavigationSpan(client, startSpanOptions);
39
- return undefined;
40
- };
41
-
42
- const instrumentation = createReactRouterInstrumentation(history, 'reactrouter_v4', routes, matchPath);
43
-
44
- // Now instrument page load & navigation with correct settings
45
- instrumentation(startPageloadCallback, instrumentPageLoad, false);
46
- instrumentation(startNavigationCallback, false, instrumentNavigation);
30
+ instrumentReactRouter(
31
+ client,
32
+ instrumentPageLoad,
33
+ instrumentNavigation,
34
+ history,
35
+ 'reactrouter_v4',
36
+ routes,
37
+ matchPath,
38
+ );
47
39
  },
48
40
  };
49
41
  }
@@ -61,33 +53,30 @@ function reactRouterV5BrowserTracingIntegration(
61
53
  instrumentNavigation: false,
62
54
  });
63
55
 
64
- const { history, routes, matchPath } = options;
56
+ const { history, routes, matchPath, instrumentPageLoad = true, instrumentNavigation = true } = options;
65
57
 
66
58
  return {
67
59
  ...integration,
68
60
  afterAllSetup(client) {
69
61
  integration.afterAllSetup(client);
70
62
 
71
- const startPageloadCallback = (startSpanOptions) => {
72
- startBrowserTracingPageLoadSpan(client, startSpanOptions);
73
- return undefined;
74
- };
75
-
76
- const startNavigationCallback = (startSpanOptions) => {
77
- startBrowserTracingNavigationSpan(client, startSpanOptions);
78
- return undefined;
79
- };
80
-
81
- const instrumentation = createReactRouterInstrumentation(history, 'reactrouter_v5', routes, matchPath);
82
-
83
- // Now instrument page load & navigation with correct settings
84
- instrumentation(startPageloadCallback, options.instrumentPageLoad, false);
85
- instrumentation(startNavigationCallback, false, options.instrumentNavigation);
63
+ instrumentReactRouter(
64
+ client,
65
+ instrumentPageLoad,
66
+ instrumentNavigation,
67
+ history,
68
+ 'reactrouter_v5',
69
+ routes,
70
+ matchPath,
71
+ );
86
72
  },
87
73
  };
88
74
  }
89
75
 
90
- function createReactRouterInstrumentation(
76
+ function instrumentReactRouter(
77
+ client,
78
+ instrumentPageLoad,
79
+ instrumentNavigation,
91
80
  history,
92
81
  instrumentationName,
93
82
  allRoutes = [],
@@ -127,12 +116,11 @@ function createReactRouterInstrumentation(
127
116
  return [pathname, 'url'];
128
117
  }
129
118
 
130
- return (customStartTransaction, startTransactionOnPageLoad = true, startTransactionOnLocationChange = true) => {
119
+ if (instrumentPageLoad) {
131
120
  const initPathName = getInitPathName();
132
-
133
- if (startTransactionOnPageLoad && initPathName) {
121
+ if (initPathName) {
134
122
  const [name, source] = normalizeTransactionName(initPathName);
135
- activeTransaction = customStartTransaction({
123
+ startBrowserTracingPageLoadSpan(client, {
136
124
  name,
137
125
  attributes: {
138
126
  [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'pageload',
@@ -141,27 +129,23 @@ function createReactRouterInstrumentation(
141
129
  },
142
130
  });
143
131
  }
132
+ }
144
133
 
145
- if (startTransactionOnLocationChange && history.listen) {
146
- history.listen((location, action) => {
147
- if (action && (action === 'PUSH' || action === 'POP')) {
148
- if (activeTransaction) {
149
- activeTransaction.end();
150
- }
151
-
152
- const [name, source] = normalizeTransactionName(location.pathname);
153
- activeTransaction = customStartTransaction({
154
- name,
155
- attributes: {
156
- [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',
157
- [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: `auto.navigation.react.${instrumentationName}`,
158
- [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,
159
- },
160
- });
161
- }
162
- });
163
- }
164
- };
134
+ if (instrumentNavigation && history.listen) {
135
+ history.listen((location, action) => {
136
+ if (action && (action === 'PUSH' || action === 'POP')) {
137
+ const [name, source] = normalizeTransactionName(location.pathname);
138
+ startBrowserTracingNavigationSpan(client, {
139
+ name,
140
+ attributes: {
141
+ [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',
142
+ [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: `auto.navigation.react.${instrumentationName}`,
143
+ [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,
144
+ },
145
+ });
146
+ }
147
+ });
148
+ }
165
149
  }
166
150
 
167
151
  /**
@@ -206,15 +190,19 @@ function withSentryRouting(Route) {
206
190
  const activeRootSpan = getActiveRootSpan();
207
191
 
208
192
  const WrappedRoute = (props) => {
209
- if (activeRootSpan && props && props.computedMatch && props.computedMatch.isExact) {
210
- activeRootSpan.updateName(props.computedMatch.path);
211
- activeRootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'route');
193
+ if (props && props.computedMatch && props.computedMatch.isExact) {
194
+ getCurrentScope().setTransactionName(props.computedMatch.path);
195
+
196
+ if (activeRootSpan) {
197
+ activeRootSpan.updateName(props.computedMatch.path);
198
+ activeRootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'route');
199
+ }
212
200
  }
213
201
 
214
202
  // @ts-expect-error Setting more specific React Component typing for `R` generic above
215
203
  // will break advanced type inference done by react router params:
216
204
  // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/13dc4235c069e25fe7ee16e11f529d909f9f3ff8/types/react-router/index.d.ts#L154-L164
217
- return React.createElement(Route, { ...props, __self: this, __source: {fileName: _jsxFileName, lineNumber: 253}} );
205
+ return React.createElement(Route, { ...props, __self: this, __source: {fileName: _jsxFileName, lineNumber: 242}} );
218
206
  };
219
207
 
220
208
  WrappedRoute.displayName = `sentryRoute(${componentDisplayName})`;
@@ -227,13 +215,8 @@ function withSentryRouting(Route) {
227
215
  /* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */
228
216
 
229
217
  function getActiveRootSpan() {
230
- // Legacy behavior for "old" react router instrumentation
231
- if (activeTransaction) {
232
- return activeTransaction;
233
- }
234
-
235
218
  const span = getActiveSpan();
236
- const rootSpan = span ? getRootSpan(span) : undefined;
219
+ const rootSpan = span && getRootSpan(span);
237
220
 
238
221
  if (!rootSpan) {
239
222
  return undefined;