@sentry/react 10.53.1 → 10.54.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 (70) hide show
  1. package/build/cjs/constants.js +3 -5
  2. package/build/cjs/constants.js.map +1 -1
  3. package/build/cjs/debug-build.js +0 -5
  4. package/build/cjs/debug-build.js.map +1 -1
  5. package/build/cjs/error.js +12 -72
  6. package/build/cjs/error.js.map +1 -1
  7. package/build/cjs/errorboundary.js +22 -77
  8. package/build/cjs/errorboundary.js.map +1 -1
  9. package/build/cjs/hoist-non-react-statics.js +16 -84
  10. package/build/cjs/hoist-non-react-statics.js.map +1 -1
  11. package/build/cjs/profiler.js +35 -110
  12. package/build/cjs/profiler.js.map +1 -1
  13. package/build/cjs/reactrouter-compat-utils/instrumentation.js +219 -690
  14. package/build/cjs/reactrouter-compat-utils/instrumentation.js.map +1 -1
  15. package/build/cjs/reactrouter-compat-utils/lazy-routes.js +24 -85
  16. package/build/cjs/reactrouter-compat-utils/lazy-routes.js.map +1 -1
  17. package/build/cjs/reactrouter-compat-utils/route-manifest.js +17 -95
  18. package/build/cjs/reactrouter-compat-utils/route-manifest.js.map +1 -1
  19. package/build/cjs/reactrouter-compat-utils/utils.js +48 -190
  20. package/build/cjs/reactrouter-compat-utils/utils.js.map +1 -1
  21. package/build/cjs/reactrouter.js +33 -113
  22. package/build/cjs/reactrouter.js.map +1 -1
  23. package/build/cjs/reactrouterv3.js +27 -59
  24. package/build/cjs/reactrouterv3.js.map +1 -1
  25. package/build/cjs/reactrouterv6.js +8 -41
  26. package/build/cjs/reactrouterv6.js.map +1 -1
  27. package/build/cjs/reactrouterv7.js +8 -41
  28. package/build/cjs/reactrouterv7.js.map +1 -1
  29. package/build/cjs/redux.js +60 -88
  30. package/build/cjs/redux.js.map +1 -1
  31. package/build/cjs/sdk.js +3 -7
  32. package/build/cjs/sdk.js.map +1 -1
  33. package/build/cjs/tanstackrouter.js +24 -64
  34. package/build/cjs/tanstackrouter.js.map +1 -1
  35. package/build/esm/constants.js +3 -5
  36. package/build/esm/constants.js.map +1 -1
  37. package/build/esm/debug-build.js +0 -5
  38. package/build/esm/debug-build.js.map +1 -1
  39. package/build/esm/error.js +12 -72
  40. package/build/esm/error.js.map +1 -1
  41. package/build/esm/errorboundary.js +22 -77
  42. package/build/esm/errorboundary.js.map +1 -1
  43. package/build/esm/hoist-non-react-statics.js +16 -84
  44. package/build/esm/hoist-non-react-statics.js.map +1 -1
  45. package/build/esm/package.json +1 -1
  46. package/build/esm/profiler.js +35 -110
  47. package/build/esm/profiler.js.map +1 -1
  48. package/build/esm/reactrouter-compat-utils/instrumentation.js +219 -690
  49. package/build/esm/reactrouter-compat-utils/instrumentation.js.map +1 -1
  50. package/build/esm/reactrouter-compat-utils/lazy-routes.js +24 -85
  51. package/build/esm/reactrouter-compat-utils/lazy-routes.js.map +1 -1
  52. package/build/esm/reactrouter-compat-utils/route-manifest.js +17 -95
  53. package/build/esm/reactrouter-compat-utils/route-manifest.js.map +1 -1
  54. package/build/esm/reactrouter-compat-utils/utils.js +48 -190
  55. package/build/esm/reactrouter-compat-utils/utils.js.map +1 -1
  56. package/build/esm/reactrouter.js +33 -113
  57. package/build/esm/reactrouter.js.map +1 -1
  58. package/build/esm/reactrouterv3.js +27 -59
  59. package/build/esm/reactrouterv3.js.map +1 -1
  60. package/build/esm/reactrouterv6.js +8 -41
  61. package/build/esm/reactrouterv6.js.map +1 -1
  62. package/build/esm/reactrouterv7.js +8 -41
  63. package/build/esm/reactrouterv7.js.map +1 -1
  64. package/build/esm/redux.js +60 -88
  65. package/build/esm/redux.js.map +1 -1
  66. package/build/esm/sdk.js +3 -7
  67. package/build/esm/sdk.js.map +1 -1
  68. package/build/esm/tanstackrouter.js +24 -64
  69. package/build/esm/tanstackrouter.js.map +1 -1
  70. package/package.json +3 -3
@@ -5,53 +5,20 @@ require('@sentry/core/browser');
5
5
  require('@sentry/browser');
6
6
  require('@sentry/core');
7
7
 
8
- /**
9
- * A browser tracing integration that uses React Router v6 to instrument navigations.
10
- * Expects `useEffect`, `useLocation`, `useNavigationType`, `createRoutesFromChildren` and `matchRoutes` to be passed as options.
11
- */
12
- function reactRouterV6BrowserTracingIntegration(
13
- options,
14
- ) {
15
- return instrumentation.createReactRouterV6CompatibleTracingIntegration(options, '6');
8
+ function reactRouterV6BrowserTracingIntegration(options) {
9
+ return instrumentation.createReactRouterV6CompatibleTracingIntegration(options, "6");
16
10
  }
17
-
18
- /**
19
- * A wrapper function that adds Sentry routing instrumentation to a React Router v6 useRoutes hook.
20
- * This is used to automatically capture route changes as transactions when using the useRoutes hook.
21
- */
22
11
  function wrapUseRoutesV6(origUseRoutes) {
23
- return instrumentation.createV6CompatibleWrapUseRoutes(origUseRoutes, '6');
12
+ return instrumentation.createV6CompatibleWrapUseRoutes(origUseRoutes, "6");
24
13
  }
25
-
26
- /**
27
- * A wrapper function that adds Sentry routing instrumentation to a React Router v6 createBrowserRouter function.
28
- * This is used to automatically capture route changes as transactions when using the createBrowserRouter API.
29
- */
30
- function wrapCreateBrowserRouterV6
31
-
32
- (createRouterFunction) {
33
- return instrumentation.createV6CompatibleWrapCreateBrowserRouter(createRouterFunction, '6');
14
+ function wrapCreateBrowserRouterV6(createRouterFunction) {
15
+ return instrumentation.createV6CompatibleWrapCreateBrowserRouter(createRouterFunction, "6");
34
16
  }
35
-
36
- /**
37
- * A wrapper function that adds Sentry routing instrumentation to a React Router v6 createMemoryRouter function.
38
- * This is used to automatically capture route changes as transactions when using the createMemoryRouter API.
39
- * The difference between createBrowserRouter and createMemoryRouter is that with createMemoryRouter,
40
- * optional `initialEntries` are also taken into account.
41
- */
42
- function wrapCreateMemoryRouterV6
43
-
44
- (createMemoryRouterFunction) {
45
- return instrumentation.createV6CompatibleWrapCreateMemoryRouter(createMemoryRouterFunction, '6');
17
+ function wrapCreateMemoryRouterV6(createMemoryRouterFunction) {
18
+ return instrumentation.createV6CompatibleWrapCreateMemoryRouter(createMemoryRouterFunction, "6");
46
19
  }
47
-
48
- /**
49
- * A higher-order component that adds Sentry routing instrumentation to a React Router v6 Route component.
50
- * This is used to automatically capture route changes as transactions.
51
- */
52
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
53
20
  function withSentryReactRouterV6Routing(routes) {
54
- return instrumentation.createV6CompatibleWithSentryReactRouterRouting(routes, '6');
21
+ return instrumentation.createV6CompatibleWithSentryReactRouterRouting(routes, "6");
55
22
  }
56
23
 
57
24
  exports.reactRouterV6BrowserTracingIntegration = reactRouterV6BrowserTracingIntegration;
@@ -1 +1 @@
1
- {"version":3,"file":"reactrouterv6.js","sources":["../../src/reactrouterv6.tsx"],"sourcesContent":["import type { browserTracingIntegration } from '@sentry/browser';\nimport type { Integration } from '@sentry/core';\nimport type { ReactRouterOptions } from './reactrouter-compat-utils';\nimport {\n createReactRouterV6CompatibleTracingIntegration,\n createV6CompatibleWithSentryReactRouterRouting,\n createV6CompatibleWrapCreateBrowserRouter,\n createV6CompatibleWrapCreateMemoryRouter,\n createV6CompatibleWrapUseRoutes,\n} from './reactrouter-compat-utils';\nimport type { CreateRouterFunction, Router, RouterState, UseRoutes } from './types';\n\n/**\n * A browser tracing integration that uses React Router v6 to instrument navigations.\n * Expects `useEffect`, `useLocation`, `useNavigationType`, `createRoutesFromChildren` and `matchRoutes` to be passed as options.\n */\nexport function reactRouterV6BrowserTracingIntegration(\n options: Parameters<typeof browserTracingIntegration>[0] & ReactRouterOptions,\n): Integration {\n return createReactRouterV6CompatibleTracingIntegration(options, '6');\n}\n\n/**\n * A wrapper function that adds Sentry routing instrumentation to a React Router v6 useRoutes hook.\n * This is used to automatically capture route changes as transactions when using the useRoutes hook.\n */\nexport function wrapUseRoutesV6(origUseRoutes: UseRoutes): UseRoutes {\n return createV6CompatibleWrapUseRoutes(origUseRoutes, '6');\n}\n\n/**\n * A wrapper function that adds Sentry routing instrumentation to a React Router v6 createBrowserRouter function.\n * This is used to automatically capture route changes as transactions when using the createBrowserRouter API.\n */\nexport function wrapCreateBrowserRouterV6<\n TState extends RouterState = RouterState,\n TRouter extends Router<TState> = Router<TState>,\n>(createRouterFunction: CreateRouterFunction<TState, TRouter>): CreateRouterFunction<TState, TRouter> {\n return createV6CompatibleWrapCreateBrowserRouter(createRouterFunction, '6');\n}\n\n/**\n * A wrapper function that adds Sentry routing instrumentation to a React Router v6 createMemoryRouter function.\n * This is used to automatically capture route changes as transactions when using the createMemoryRouter API.\n * The difference between createBrowserRouter and createMemoryRouter is that with createMemoryRouter,\n * optional `initialEntries` are also taken into account.\n */\nexport function wrapCreateMemoryRouterV6<\n TState extends RouterState = RouterState,\n TRouter extends Router<TState> = Router<TState>,\n>(createMemoryRouterFunction: CreateRouterFunction<TState, TRouter>): CreateRouterFunction<TState, TRouter> {\n return createV6CompatibleWrapCreateMemoryRouter(createMemoryRouterFunction, '6');\n}\n\n/**\n * A higher-order component that adds Sentry routing instrumentation to a React Router v6 Route component.\n * This is used to automatically capture route changes as transactions.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function withSentryReactRouterV6Routing<P extends Record<string, any>, R extends React.FC<P>>(routes: R): R {\n return createV6CompatibleWithSentryReactRouterRouting<P, R>(routes, '6');\n}\n"],"names":["createReactRouterV6CompatibleTracingIntegration","createV6CompatibleWrapUseRoutes","createV6CompatibleWrapCreateBrowserRouter","createV6CompatibleWrapCreateMemoryRouter","createV6CompatibleWithSentryReactRouterRouting"],"mappings":";;;;;;;AAYA;AACA;AACA;AACA;AACO,SAAS,sCAAsC;AACtD,EAAE,OAAO;AACT,EAAe;AACf,EAAE,OAAOA,+DAA+C,CAAC,OAAO,EAAE,GAAG,CAAC;AACtE;;AAEA;AACA;AACA;AACA;AACO,SAAS,eAAe,CAAC,aAAa,EAAwB;AACrE,EAAE,OAAOC,+CAA+B,CAAC,aAAa,EAAE,GAAG,CAAC;AAC5D;;AAEA;AACA;AACA;AACA;AACO,SAAS;;AAGhB,CAAE,oBAAoB,EAAgF;AACtG,EAAE,OAAOC,yDAAyC,CAAC,oBAAoB,EAAE,GAAG,CAAC;AAC7E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS;;AAGhB,CAAE,0BAA0B,EAAgF;AAC5G,EAAE,OAAOC,wDAAwC,CAAC,0BAA0B,EAAE,GAAG,CAAC;AAClF;;AAEA;AACA;AACA;AACA;AACA;AACO,SAAS,8BAA8B,CAAuD,MAAM,EAAQ;AACnH,EAAE,OAAOC,8DAA8C,CAAO,MAAM,EAAE,GAAG,CAAC;AAC1E;;;;;;;;"}
1
+ {"version":3,"file":"reactrouterv6.js","sources":["../../src/reactrouterv6.tsx"],"sourcesContent":["import type { browserTracingIntegration } from '@sentry/browser';\nimport type { Integration } from '@sentry/core';\nimport type { ReactRouterOptions } from './reactrouter-compat-utils';\nimport {\n createReactRouterV6CompatibleTracingIntegration,\n createV6CompatibleWithSentryReactRouterRouting,\n createV6CompatibleWrapCreateBrowserRouter,\n createV6CompatibleWrapCreateMemoryRouter,\n createV6CompatibleWrapUseRoutes,\n} from './reactrouter-compat-utils';\nimport type { CreateRouterFunction, Router, RouterState, UseRoutes } from './types';\n\n/**\n * A browser tracing integration that uses React Router v6 to instrument navigations.\n * Expects `useEffect`, `useLocation`, `useNavigationType`, `createRoutesFromChildren` and `matchRoutes` to be passed as options.\n */\nexport function reactRouterV6BrowserTracingIntegration(\n options: Parameters<typeof browserTracingIntegration>[0] & ReactRouterOptions,\n): Integration {\n return createReactRouterV6CompatibleTracingIntegration(options, '6');\n}\n\n/**\n * A wrapper function that adds Sentry routing instrumentation to a React Router v6 useRoutes hook.\n * This is used to automatically capture route changes as transactions when using the useRoutes hook.\n */\nexport function wrapUseRoutesV6(origUseRoutes: UseRoutes): UseRoutes {\n return createV6CompatibleWrapUseRoutes(origUseRoutes, '6');\n}\n\n/**\n * A wrapper function that adds Sentry routing instrumentation to a React Router v6 createBrowserRouter function.\n * This is used to automatically capture route changes as transactions when using the createBrowserRouter API.\n */\nexport function wrapCreateBrowserRouterV6<\n TState extends RouterState = RouterState,\n TRouter extends Router<TState> = Router<TState>,\n>(createRouterFunction: CreateRouterFunction<TState, TRouter>): CreateRouterFunction<TState, TRouter> {\n return createV6CompatibleWrapCreateBrowserRouter(createRouterFunction, '6');\n}\n\n/**\n * A wrapper function that adds Sentry routing instrumentation to a React Router v6 createMemoryRouter function.\n * This is used to automatically capture route changes as transactions when using the createMemoryRouter API.\n * The difference between createBrowserRouter and createMemoryRouter is that with createMemoryRouter,\n * optional `initialEntries` are also taken into account.\n */\nexport function wrapCreateMemoryRouterV6<\n TState extends RouterState = RouterState,\n TRouter extends Router<TState> = Router<TState>,\n>(createMemoryRouterFunction: CreateRouterFunction<TState, TRouter>): CreateRouterFunction<TState, TRouter> {\n return createV6CompatibleWrapCreateMemoryRouter(createMemoryRouterFunction, '6');\n}\n\n/**\n * A higher-order component that adds Sentry routing instrumentation to a React Router v6 Route component.\n * This is used to automatically capture route changes as transactions.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function withSentryReactRouterV6Routing<P extends Record<string, any>, R extends React.FC<P>>(routes: R): R {\n return createV6CompatibleWithSentryReactRouterRouting<P, R>(routes, '6');\n}\n"],"names":["createReactRouterV6CompatibleTracingIntegration","createV6CompatibleWrapUseRoutes","createV6CompatibleWrapCreateBrowserRouter","createV6CompatibleWrapCreateMemoryRouter","createV6CompatibleWithSentryReactRouterRouting"],"mappings":";;;;;;;AAgBO,SAAS,uCACd,OAAA,EACa;AACb,EAAA,OAAOA,+DAAA,CAAgD,SAAS,GAAG,CAAA;AACrE;AAMO,SAAS,gBAAgB,aAAA,EAAqC;AACnE,EAAA,OAAOC,+CAAA,CAAgC,eAAe,GAAG,CAAA;AAC3D;AAMO,SAAS,0BAGd,oBAAA,EAAoG;AACpG,EAAA,OAAOC,yDAAA,CAA0C,sBAAsB,GAAG,CAAA;AAC5E;AAQO,SAAS,yBAGd,0BAAA,EAA0G;AAC1G,EAAA,OAAOC,wDAAA,CAAyC,4BAA4B,GAAG,CAAA;AACjF;AAOO,SAAS,+BAAqF,MAAA,EAAc;AACjH,EAAA,OAAOC,8DAAA,CAAqD,QAAQ,GAAG,CAAA;AACzE;;;;;;;;"}
@@ -5,53 +5,20 @@ require('@sentry/core/browser');
5
5
  require('@sentry/browser');
6
6
  require('@sentry/core');
7
7
 
8
- /**
9
- * A browser tracing integration that uses React Router v7 to instrument navigations.
10
- * Expects `useEffect`, `useLocation`, `useNavigationType`, `createRoutesFromChildren` and `matchRoutes` to be passed as options.
11
- */
12
- function reactRouterV7BrowserTracingIntegration(
13
- options,
14
- ) {
15
- return instrumentation.createReactRouterV6CompatibleTracingIntegration(options, '7');
8
+ function reactRouterV7BrowserTracingIntegration(options) {
9
+ return instrumentation.createReactRouterV6CompatibleTracingIntegration(options, "7");
16
10
  }
17
-
18
- /**
19
- * A higher-order component that adds Sentry routing instrumentation to a React Router v7 Route component.
20
- * This is used to automatically capture route changes as transactions.
21
- */
22
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
23
11
  function withSentryReactRouterV7Routing(routes) {
24
- return instrumentation.createV6CompatibleWithSentryReactRouterRouting(routes, '7');
12
+ return instrumentation.createV6CompatibleWithSentryReactRouterRouting(routes, "7");
25
13
  }
26
-
27
- /**
28
- * A wrapper function that adds Sentry routing instrumentation to a React Router v7 createBrowserRouter function.
29
- * This is used to automatically capture route changes as transactions when using the createBrowserRouter API.
30
- */
31
- function wrapCreateBrowserRouterV7
32
-
33
- (createRouterFunction) {
34
- return instrumentation.createV6CompatibleWrapCreateBrowserRouter(createRouterFunction, '7');
14
+ function wrapCreateBrowserRouterV7(createRouterFunction) {
15
+ return instrumentation.createV6CompatibleWrapCreateBrowserRouter(createRouterFunction, "7");
35
16
  }
36
-
37
- /**
38
- * A wrapper function that adds Sentry routing instrumentation to a React Router v7 createMemoryRouter function.
39
- * This is used to automatically capture route changes as transactions when using the createMemoryRouter API.
40
- * The difference between createBrowserRouter and createMemoryRouter is that with createMemoryRouter,
41
- * optional `initialEntries` are also taken into account.
42
- */
43
- function wrapCreateMemoryRouterV7
44
-
45
- (createMemoryRouterFunction) {
46
- return instrumentation.createV6CompatibleWrapCreateMemoryRouter(createMemoryRouterFunction, '7');
17
+ function wrapCreateMemoryRouterV7(createMemoryRouterFunction) {
18
+ return instrumentation.createV6CompatibleWrapCreateMemoryRouter(createMemoryRouterFunction, "7");
47
19
  }
48
-
49
- /**
50
- * A wrapper function that adds Sentry routing instrumentation to a React Router v7 useRoutes hook.
51
- * This is used to automatically capture route changes as transactions when using the useRoutes hook.
52
- */
53
20
  function wrapUseRoutesV7(origUseRoutes) {
54
- return instrumentation.createV6CompatibleWrapUseRoutes(origUseRoutes, '7');
21
+ return instrumentation.createV6CompatibleWrapUseRoutes(origUseRoutes, "7");
55
22
  }
56
23
 
57
24
  exports.reactRouterV7BrowserTracingIntegration = reactRouterV7BrowserTracingIntegration;
@@ -1 +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 './reactrouter-compat-utils';\nimport {\n createReactRouterV6CompatibleTracingIntegration,\n createV6CompatibleWithSentryReactRouterRouting,\n createV6CompatibleWrapCreateBrowserRouter,\n createV6CompatibleWrapCreateMemoryRouter,\n createV6CompatibleWrapUseRoutes,\n} from './reactrouter-compat-utils';\nimport type { CreateRouterFunction, Router, RouterState, UseRoutes } from './types';\n\n/**\n * A browser tracing integration that uses React Router 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 createMemoryRouter function.\n * This is used to automatically capture route changes as transactions when using the createMemoryRouter API.\n * The difference between createBrowserRouter and createMemoryRouter is that with createMemoryRouter,\n * optional `initialEntries` are also taken into account.\n */\nexport function wrapCreateMemoryRouterV7<\n TState extends RouterState = RouterState,\n TRouter extends Router<TState> = Router<TState>,\n>(createMemoryRouterFunction: CreateRouterFunction<TState, TRouter>): CreateRouterFunction<TState, TRouter> {\n return createV6CompatibleWrapCreateMemoryRouter(createMemoryRouterFunction, '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","createV6CompatibleWrapCreateMemoryRouter","createV6CompatibleWrapUseRoutes"],"mappings":";;;;;;;AAaA;AACA;AACA;AACA;AACO,SAAS,sCAAsC;AACtD,EAAE,OAAO;AACT,EAAe;AACf,EAAE,OAAOA,+DAA+C,CAAC,OAAO,EAAE,GAAG,CAAC;AACtE;;AAEA;AACA;AACA;AACA;AACA;AACO,SAAS,8BAA8B,CAAuD,MAAM,EAAQ;AACnH,EAAE,OAAOC,8DAA8C,CAAO,MAAM,EAAE,GAAG,CAAC;AAC1E;;AAEA;AACA;AACA;AACA;AACO,SAAS;;AAGhB,CAAE,oBAAoB,EAAgF;AACtG,EAAE,OAAOC,yDAAyC,CAAC,oBAAoB,EAAE,GAAG,CAAC;AAC7E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS;;AAGhB,CAAE,0BAA0B,EAAgF;AAC5G,EAAE,OAAOC,wDAAwC,CAAC,0BAA0B,EAAE,GAAG,CAAC;AAClF;;AAEA;AACA;AACA;AACA;AACO,SAAS,eAAe,CAAC,aAAa,EAAwB;AACrE,EAAE,OAAOC,+CAA+B,CAAC,aAAa,EAAE,GAAG,CAAC;AAC5D;;;;;;;;"}
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 './reactrouter-compat-utils';\nimport {\n createReactRouterV6CompatibleTracingIntegration,\n createV6CompatibleWithSentryReactRouterRouting,\n createV6CompatibleWrapCreateBrowserRouter,\n createV6CompatibleWrapCreateMemoryRouter,\n createV6CompatibleWrapUseRoutes,\n} from './reactrouter-compat-utils';\nimport type { CreateRouterFunction, Router, RouterState, UseRoutes } from './types';\n\n/**\n * A browser tracing integration that uses React Router 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 createMemoryRouter function.\n * This is used to automatically capture route changes as transactions when using the createMemoryRouter API.\n * The difference between createBrowserRouter and createMemoryRouter is that with createMemoryRouter,\n * optional `initialEntries` are also taken into account.\n */\nexport function wrapCreateMemoryRouterV7<\n TState extends RouterState = RouterState,\n TRouter extends Router<TState> = Router<TState>,\n>(createMemoryRouterFunction: CreateRouterFunction<TState, TRouter>): CreateRouterFunction<TState, TRouter> {\n return createV6CompatibleWrapCreateMemoryRouter(createMemoryRouterFunction, '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","createV6CompatibleWrapCreateMemoryRouter","createV6CompatibleWrapUseRoutes"],"mappings":";;;;;;;AAiBO,SAAS,uCACd,OAAA,EACa;AACb,EAAA,OAAOA,+DAAA,CAAgD,SAAS,GAAG,CAAA;AACrE;AAOO,SAAS,+BAAqF,MAAA,EAAc;AACjH,EAAA,OAAOC,8DAAA,CAAqD,QAAQ,GAAG,CAAA;AACzE;AAMO,SAAS,0BAGd,oBAAA,EAAoG;AACpG,EAAA,OAAOC,yDAAA,CAA0C,sBAAsB,GAAG,CAAA;AAC5E;AAQO,SAAS,yBAGd,0BAAA,EAA0G;AAC1G,EAAA,OAAOC,wDAAA,CAAyC,4BAA4B,GAAG,CAAA;AACjF;AAMO,SAAS,gBAAgB,aAAA,EAAqC;AACnE,EAAA,OAAOC,+CAAA,CAAgC,eAAe,GAAG,CAAA;AAC3D;;;;;;;;"}
@@ -2,103 +2,75 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  const browser = require('@sentry/core/browser');
4
4
 
5
- const ACTION_BREADCRUMB_CATEGORY = 'redux.action';
6
- const ACTION_BREADCRUMB_TYPE = 'info';
7
-
5
+ const ACTION_BREADCRUMB_CATEGORY = "redux.action";
6
+ const ACTION_BREADCRUMB_TYPE = "info";
8
7
  const defaultOptions = {
9
8
  attachReduxState: true,
10
- actionTransformer: action => action,
11
- stateTransformer: state => state || null,
9
+ actionTransformer: (action) => action,
10
+ stateTransformer: (state) => state || null
12
11
  };
13
-
14
- /**
15
- * Creates an enhancer that would be passed to Redux's createStore to log actions and the latest state to Sentry.
16
- *
17
- * @param enhancerOptions Options to pass to the enhancer
18
- */
19
12
  function createReduxEnhancer(enhancerOptions) {
20
- // Note: We return an any type as to not have type conflicts.
21
13
  const options = {
22
14
  ...defaultOptions,
23
- ...enhancerOptions,
15
+ ...enhancerOptions
24
16
  };
25
-
26
- return (next) =>
27
- (reducer, initialState) => {
28
- options.attachReduxState &&
29
- browser.getGlobalScope().addEventProcessor((event, hint) => {
30
- try {
17
+ return (next) => (reducer, initialState) => {
18
+ options.attachReduxState && browser.getGlobalScope().addEventProcessor((event, hint) => {
19
+ try {
20
+ if (event.type === void 0 && event.contexts.state.state.type === "redux") {
21
+ hint.attachments = [
22
+ ...hint.attachments || [],
31
23
  // @ts-expect-error try catch to reduce bundle size
32
- if (event.type === undefined && event.contexts.state.state.type === 'redux') {
33
- hint.attachments = [
34
- ...(hint.attachments || []),
35
- // @ts-expect-error try catch to reduce bundle size
36
- { filename: 'redux_state.json', data: JSON.stringify(event.contexts.state.state.value) },
37
- ];
38
- }
39
- } catch {
40
- // empty
41
- }
42
- return event;
43
- });
44
-
45
- function sentryWrapReducer(reducer) {
46
- return (state, action) => {
47
- const newState = reducer(state, action);
48
-
49
- const scope = browser.getCurrentScope();
50
-
51
- /* Action breadcrumbs */
52
- const transformedAction = options.actionTransformer(action);
53
- if (typeof transformedAction !== 'undefined' && transformedAction !== null) {
54
- browser.addBreadcrumb({
55
- category: ACTION_BREADCRUMB_CATEGORY,
56
- data: transformedAction,
57
- type: ACTION_BREADCRUMB_TYPE,
58
- });
59
- }
60
-
61
- /* Set latest state to scope */
62
- const transformedState = options.stateTransformer(newState);
63
- if (typeof transformedState !== 'undefined' && transformedState !== null) {
64
- const client = browser.getClient();
65
- const options = client?.getOptions();
66
- const normalizationDepth = options?.normalizeDepth || 3; // default state normalization depth to 3
67
-
68
- // Set the normalization depth of the redux state to the configured `normalizeDepth` option or a sane number as a fallback
69
- const newStateContext = { state: { type: 'redux', value: transformedState } };
70
- browser.setNormalizationDepthOverrideHint(
71
- newStateContext,
72
- 3 + // 3 layers for `state.value.transformedState`
73
- normalizationDepth, // rest for the actual state
74
- );
75
-
76
- scope.setContext('state', newStateContext);
77
- } else {
78
- scope.setContext('state', null);
79
- }
80
-
81
- /* Allow user to configure scope with latest state */
82
- const { configureScopeWithState } = options;
83
- if (typeof configureScopeWithState === 'function') {
84
- configureScopeWithState(scope, newState);
85
- }
86
-
87
- return newState;
88
- };
24
+ { filename: "redux_state.json", data: JSON.stringify(event.contexts.state.state.value) }
25
+ ];
26
+ }
27
+ } catch {
89
28
  }
90
-
91
- const store = next(sentryWrapReducer(reducer), initialState);
92
-
93
- // eslint-disable-next-line @typescript-eslint/unbound-method
94
- store.replaceReducer = new Proxy(store.replaceReducer, {
95
- apply: function (target, thisArg, args) {
96
- target.apply(thisArg, [sentryWrapReducer(args[0])]);
97
- },
98
- });
99
-
100
- return store;
101
- };
29
+ return event;
30
+ });
31
+ function sentryWrapReducer(reducer2) {
32
+ return (state, action) => {
33
+ const newState = reducer2(state, action);
34
+ const scope = browser.getCurrentScope();
35
+ const transformedAction = options.actionTransformer(action);
36
+ if (typeof transformedAction !== "undefined" && transformedAction !== null) {
37
+ browser.addBreadcrumb({
38
+ category: ACTION_BREADCRUMB_CATEGORY,
39
+ data: transformedAction,
40
+ type: ACTION_BREADCRUMB_TYPE
41
+ });
42
+ }
43
+ const transformedState = options.stateTransformer(newState);
44
+ if (typeof transformedState !== "undefined" && transformedState !== null) {
45
+ const client = browser.getClient();
46
+ const options2 = client?.getOptions();
47
+ const normalizationDepth = options2?.normalizeDepth || 3;
48
+ const newStateContext = { state: { type: "redux", value: transformedState } };
49
+ browser.setNormalizationDepthOverrideHint(
50
+ newStateContext,
51
+ 3 + // 3 layers for `state.value.transformedState`
52
+ normalizationDepth
53
+ // rest for the actual state
54
+ );
55
+ scope.setContext("state", newStateContext);
56
+ } else {
57
+ scope.setContext("state", null);
58
+ }
59
+ const { configureScopeWithState } = options;
60
+ if (typeof configureScopeWithState === "function") {
61
+ configureScopeWithState(scope, newState);
62
+ }
63
+ return newState;
64
+ };
65
+ }
66
+ const store = next(sentryWrapReducer(reducer), initialState);
67
+ store.replaceReducer = new Proxy(store.replaceReducer, {
68
+ apply: function(target, thisArg, args) {
69
+ target.apply(thisArg, [sentryWrapReducer(args[0])]);
70
+ }
71
+ });
72
+ return store;
73
+ };
102
74
  }
103
75
 
104
76
  exports.createReduxEnhancer = createReduxEnhancer;
@@ -1 +1 @@
1
- {"version":3,"file":"redux.js","sources":["../../src/redux.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Scope } from '@sentry/core/browser';\nimport {\n addBreadcrumb,\n getClient,\n getCurrentScope,\n getGlobalScope,\n setNormalizationDepthOverrideHint,\n} from '@sentry/core/browser';\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> =\n 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 function sentryWrapReducer(reducer: Reducer<S, A>): Reducer<S, A> {\n return (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?.getOptions();\n const normalizationDepth = 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 setNormalizationDepthOverrideHint(\n newStateContext,\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\n const store = next(sentryWrapReducer(reducer), initialState);\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n store.replaceReducer = new Proxy(store.replaceReducer, {\n apply: function (target, thisArg, args) {\n target.apply(thisArg, [sentryWrapReducer(args[0])]);\n },\n });\n\n return store;\n };\n}\n\nexport { createReduxEnhancer };\n"],"names":["getGlobalScope","getCurrentScope","addBreadcrumb","getClient","setNormalizationDepthOverrideHint"],"mappings":"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"}
1
+ {"version":3,"file":"redux.js","sources":["../../src/redux.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Scope } from '@sentry/core/browser';\nimport {\n addBreadcrumb,\n getClient,\n getCurrentScope,\n getGlobalScope,\n setNormalizationDepthOverrideHint,\n} from '@sentry/core/browser';\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> =\n 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 function sentryWrapReducer(reducer: Reducer<S, A>): Reducer<S, A> {\n return (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?.getOptions();\n const normalizationDepth = 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 setNormalizationDepthOverrideHint(\n newStateContext,\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\n const store = next(sentryWrapReducer(reducer), initialState);\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n store.replaceReducer = new Proxy(store.replaceReducer, {\n apply: function (target, thisArg, args) {\n target.apply(thisArg, [sentryWrapReducer(args[0])]);\n },\n });\n\n return store;\n };\n}\n\nexport { createReduxEnhancer };\n"],"names":["getGlobalScope","reducer","getCurrentScope","addBreadcrumb","getClient","options","setNormalizationDepthOverrideHint"],"mappings":"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"}
package/build/cjs/sdk.js CHANGED
@@ -4,16 +4,12 @@ const browser$1 = require('@sentry/browser');
4
4
  const browser = require('@sentry/core/browser');
5
5
  const React = require('react');
6
6
 
7
- /**
8
- * Inits the React SDK
9
- */
10
7
  function init(options) {
11
8
  const opts = {
12
- ...options,
9
+ ...options
13
10
  };
14
-
15
- browser.applySdkMetadata(opts, 'react');
16
- browser$1.setContext('react', { version: React.version });
11
+ browser.applySdkMetadata(opts, "react");
12
+ browser$1.setContext("react", { version: React.version });
17
13
  return browser$1.init(opts);
18
14
  }
19
15
 
@@ -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 type { Client } from '@sentry/core/browser';\nimport { applySdkMetadata } from '@sentry/core/browser';\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":";;;;;;AAMA;AACA;AACA;AACO,SAAS,IAAI,CAAC,OAAO,EAAsC;AAClE,EAAE,MAAM,OAAO;AACf,IAAI,GAAG,OAAO;AACd,GAAG;;AAEH,EAAEA,wBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC;AACjC,EAAEC,oBAAU,CAAC,OAAO,EAAE,WAAEC,aAAA,EAAS,CAAC;AAClC,EAAE,OAAOC,cAAW,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 type { Client } from '@sentry/core/browser';\nimport { applySdkMetadata } from '@sentry/core/browser';\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":";;;;;;AASO,SAAS,KAAK,OAAA,EAA6C;AAChE,EAAA,MAAM,IAAA,GAAO;AAAA,IACX,GAAG;AAAA,GACL;AAEA,EAAAA,wBAAA,CAAiB,MAAM,OAAO,CAAA;AAC9B,EAAAC,oBAAA,CAAW,OAAA,EAAS,WAAEC,aAAA,EAAS,CAAA;AAC/B,EAAA,OAAOC,eAAY,IAAI,CAAA;AACzB;;;;"}
@@ -3,130 +3,90 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3
3
  const browser = require('@sentry/browser');
4
4
  const browser$1 = require('@sentry/core/browser');
5
5
 
6
- /**
7
- * A custom browser tracing integration for TanStack Router.
8
- *
9
- * The minimum compatible version of `@tanstack/react-router` is `1.64.0`.
10
- *
11
- * @param router A TanStack Router `Router` instance that should be used for routing instrumentation.
12
- * @param options Sentry browser tracing configuration.
13
- */
14
- function tanstackRouterBrowserTracingIntegration(
15
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
- router, // This is `any` because we don't want any type mismatches if TanStack Router changes their types
17
- options = {},
18
- ) {
6
+ function tanstackRouterBrowserTracingIntegration(router, options = {}) {
19
7
  const castRouterInstance = router;
20
-
21
8
  const browserTracingIntegrationInstance = browser.browserTracingIntegration({
22
9
  ...options,
23
10
  instrumentNavigation: false,
24
- instrumentPageLoad: false,
11
+ instrumentPageLoad: false
25
12
  });
26
-
27
13
  const { instrumentPageLoad = true, instrumentNavigation = true } = options;
28
-
29
14
  return {
30
15
  ...browserTracingIntegrationInstance,
31
16
  afterAllSetup(client) {
32
17
  browserTracingIntegrationInstance.afterAllSetup(client);
33
-
34
18
  const initialWindowLocation = browser.WINDOW.location;
35
19
  if (instrumentPageLoad && initialWindowLocation) {
36
20
  const matchedRoutes = castRouterInstance.matchRoutes(
37
21
  initialWindowLocation.pathname,
38
22
  castRouterInstance.options.parseSearch(initialWindowLocation.search),
39
- { preload: false, throwOnError: false },
23
+ { preload: false, throwOnError: false }
40
24
  );
41
-
42
25
  const lastMatch = matchedRoutes[matchedRoutes.length - 1];
43
- // If we only match __root__, we ended up not matching any route at all, so
44
- // we fall back to the pathname.
45
- const routeMatch = lastMatch?.routeId !== '__root__' ? lastMatch : undefined;
46
-
26
+ const routeMatch = lastMatch?.routeId !== "__root__" ? lastMatch : void 0;
47
27
  browser.startBrowserTracingPageLoadSpan(client, {
48
28
  name: routeMatch ? routeMatch.routeId : initialWindowLocation.pathname,
49
29
  attributes: {
50
- [browser$1.SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'pageload',
51
- [browser$1.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.pageload.react.tanstack_router',
52
- [browser$1.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: routeMatch ? 'route' : 'url',
53
- ...routeMatchToParamSpanAttributes(routeMatch),
54
- },
30
+ [browser$1.SEMANTIC_ATTRIBUTE_SENTRY_OP]: "pageload",
31
+ [browser$1.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.pageload.react.tanstack_router",
32
+ [browser$1.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: routeMatch ? "route" : "url",
33
+ ...routeMatchToParamSpanAttributes(routeMatch)
34
+ }
55
35
  });
56
36
  }
57
-
58
37
  if (instrumentNavigation) {
59
- // The onBeforeNavigate hook is called at the very beginning of a navigation and is only called once per navigation, even when the user is redirected
60
- castRouterInstance.subscribe('onBeforeNavigate', onBeforeNavigateArgs => {
61
- // onBeforeNavigate is called during pageloads. We can avoid creating navigation spans by:
62
- // 1. Checking if there's no fromLocation (initial pageload)
63
- // 2. Comparing the states of the to and from arguments
64
- if (
65
- !onBeforeNavigateArgs.fromLocation ||
66
- onBeforeNavigateArgs.toLocation.state === onBeforeNavigateArgs.fromLocation.state
67
- ) {
38
+ castRouterInstance.subscribe("onBeforeNavigate", (onBeforeNavigateArgs) => {
39
+ if (!onBeforeNavigateArgs.fromLocation || onBeforeNavigateArgs.toLocation.state === onBeforeNavigateArgs.fromLocation.state) {
68
40
  return;
69
41
  }
70
-
71
42
  const matchedRoutesOnBeforeNavigate = castRouterInstance.matchRoutes(
72
43
  onBeforeNavigateArgs.toLocation.pathname,
73
44
  onBeforeNavigateArgs.toLocation.search,
74
- { preload: false, throwOnError: false },
45
+ { preload: false, throwOnError: false }
75
46
  );
76
-
77
47
  const onBeforeNavigateLastMatch = matchedRoutesOnBeforeNavigate[matchedRoutesOnBeforeNavigate.length - 1];
78
- const onBeforeNavigateRouteMatch =
79
- onBeforeNavigateLastMatch?.routeId !== '__root__' ? onBeforeNavigateLastMatch : undefined;
80
-
48
+ const onBeforeNavigateRouteMatch = onBeforeNavigateLastMatch?.routeId !== "__root__" ? onBeforeNavigateLastMatch : void 0;
81
49
  const navigationLocation = browser.WINDOW.location;
82
50
  const navigationSpan = browser.startBrowserTracingNavigationSpan(client, {
83
51
  name: onBeforeNavigateRouteMatch ? onBeforeNavigateRouteMatch.routeId : navigationLocation.pathname,
84
52
  attributes: {
85
- [browser$1.SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',
86
- [browser$1.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.react.tanstack_router',
87
- [browser$1.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: onBeforeNavigateRouteMatch ? 'route' : 'url',
88
- },
53
+ [browser$1.SEMANTIC_ATTRIBUTE_SENTRY_OP]: "navigation",
54
+ [browser$1.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.navigation.react.tanstack_router",
55
+ [browser$1.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: onBeforeNavigateRouteMatch ? "route" : "url"
56
+ }
89
57
  });
90
-
91
- // In case the user is redirected during navigation we want to update the span with the right value.
92
- const unsubscribeOnResolved = castRouterInstance.subscribe('onResolved', onResolvedArgs => {
58
+ const unsubscribeOnResolved = castRouterInstance.subscribe("onResolved", (onResolvedArgs) => {
93
59
  unsubscribeOnResolved();
94
60
  if (navigationSpan) {
95
61
  const matchedRoutesOnResolved = castRouterInstance.matchRoutes(
96
62
  onResolvedArgs.toLocation.pathname,
97
63
  onResolvedArgs.toLocation.search,
98
- { preload: false, throwOnError: false },
64
+ { preload: false, throwOnError: false }
99
65
  );
100
-
101
66
  const onResolvedLastMatch = matchedRoutesOnResolved[matchedRoutesOnResolved.length - 1];
102
- const onResolvedRouteMatch =
103
- onResolvedLastMatch?.routeId !== '__root__' ? onResolvedLastMatch : undefined;
104
-
67
+ const onResolvedRouteMatch = onResolvedLastMatch?.routeId !== "__root__" ? onResolvedLastMatch : void 0;
105
68
  if (onResolvedRouteMatch) {
106
69
  navigationSpan.updateName(onResolvedRouteMatch.routeId);
107
- navigationSpan.setAttribute(browser$1.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'route');
70
+ navigationSpan.setAttribute(browser$1.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, "route");
108
71
  navigationSpan.setAttributes(routeMatchToParamSpanAttributes(onResolvedRouteMatch));
109
72
  }
110
73
  }
111
74
  });
112
75
  });
113
76
  }
114
- },
77
+ }
115
78
  };
116
79
  }
117
-
118
80
  function routeMatchToParamSpanAttributes(match) {
119
81
  if (!match) {
120
82
  return {};
121
83
  }
122
-
123
84
  const paramAttributes = {};
124
85
  Object.entries(match.params).forEach(([key, value]) => {
125
- paramAttributes[`url.path.params.${key}`] = value; // TODO(v11): remove attribute which does not adhere to Sentry's semantic convention
86
+ paramAttributes[`url.path.params.${key}`] = value;
126
87
  paramAttributes[`url.path.parameter.${key}`] = value;
127
- paramAttributes[`params.${key}`] = value; // params.[key] is an alias
88
+ paramAttributes[`params.${key}`] = value;
128
89
  });
129
-
130
90
  return paramAttributes;
131
91
  }
132
92