@sentry/react 10.53.1 → 10.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/constants.js +3 -5
- package/build/cjs/constants.js.map +1 -1
- package/build/cjs/debug-build.js +0 -5
- package/build/cjs/debug-build.js.map +1 -1
- package/build/cjs/error.js +12 -72
- package/build/cjs/error.js.map +1 -1
- package/build/cjs/errorboundary.js +22 -77
- package/build/cjs/errorboundary.js.map +1 -1
- package/build/cjs/hoist-non-react-statics.js +16 -84
- package/build/cjs/hoist-non-react-statics.js.map +1 -1
- package/build/cjs/isSyntheticEvent.js +10 -0
- package/build/cjs/isSyntheticEvent.js.map +1 -0
- package/build/cjs/profiler.js +35 -110
- package/build/cjs/profiler.js.map +1 -1
- package/build/cjs/reactrouter-compat-utils/instrumentation.js +219 -690
- package/build/cjs/reactrouter-compat-utils/instrumentation.js.map +1 -1
- package/build/cjs/reactrouter-compat-utils/lazy-routes.js +24 -85
- package/build/cjs/reactrouter-compat-utils/lazy-routes.js.map +1 -1
- package/build/cjs/reactrouter-compat-utils/route-manifest.js +17 -95
- package/build/cjs/reactrouter-compat-utils/route-manifest.js.map +1 -1
- package/build/cjs/reactrouter-compat-utils/utils.js +48 -190
- package/build/cjs/reactrouter-compat-utils/utils.js.map +1 -1
- package/build/cjs/reactrouter.js +33 -113
- package/build/cjs/reactrouter.js.map +1 -1
- package/build/cjs/reactrouterv3.js +27 -59
- package/build/cjs/reactrouterv3.js.map +1 -1
- package/build/cjs/reactrouterv6.js +8 -41
- package/build/cjs/reactrouterv6.js.map +1 -1
- package/build/cjs/reactrouterv7.js +8 -41
- package/build/cjs/reactrouterv7.js.map +1 -1
- package/build/cjs/redux.js +60 -88
- package/build/cjs/redux.js.map +1 -1
- package/build/cjs/sdk.js +13 -8
- package/build/cjs/sdk.js.map +1 -1
- package/build/cjs/tanstackrouter.js +24 -64
- package/build/cjs/tanstackrouter.js.map +1 -1
- package/build/esm/constants.js +3 -5
- package/build/esm/constants.js.map +1 -1
- package/build/esm/debug-build.js +0 -5
- package/build/esm/debug-build.js.map +1 -1
- package/build/esm/error.js +12 -72
- package/build/esm/error.js.map +1 -1
- package/build/esm/errorboundary.js +22 -77
- package/build/esm/errorboundary.js.map +1 -1
- package/build/esm/hoist-non-react-statics.js +16 -84
- package/build/esm/hoist-non-react-statics.js.map +1 -1
- package/build/esm/isSyntheticEvent.js +8 -0
- package/build/esm/isSyntheticEvent.js.map +1 -0
- package/build/esm/package.json +1 -1
- package/build/esm/profiler.js +35 -110
- package/build/esm/profiler.js.map +1 -1
- package/build/esm/reactrouter-compat-utils/instrumentation.js +219 -690
- package/build/esm/reactrouter-compat-utils/instrumentation.js.map +1 -1
- package/build/esm/reactrouter-compat-utils/lazy-routes.js +24 -85
- package/build/esm/reactrouter-compat-utils/lazy-routes.js.map +1 -1
- package/build/esm/reactrouter-compat-utils/route-manifest.js +17 -95
- package/build/esm/reactrouter-compat-utils/route-manifest.js.map +1 -1
- package/build/esm/reactrouter-compat-utils/utils.js +48 -190
- package/build/esm/reactrouter-compat-utils/utils.js.map +1 -1
- package/build/esm/reactrouter.js +33 -113
- package/build/esm/reactrouter.js.map +1 -1
- package/build/esm/reactrouterv3.js +27 -59
- package/build/esm/reactrouterv3.js.map +1 -1
- package/build/esm/reactrouterv6.js +8 -41
- package/build/esm/reactrouterv6.js.map +1 -1
- package/build/esm/reactrouterv7.js +8 -41
- package/build/esm/reactrouterv7.js.map +1 -1
- package/build/esm/redux.js +60 -88
- package/build/esm/redux.js.map +1 -1
- package/build/esm/sdk.js +15 -10
- package/build/esm/sdk.js.map +1 -1
- package/build/esm/tanstackrouter.js +24 -64
- package/build/esm/tanstackrouter.js.map +1 -1
- package/build/types/isSyntheticEvent.d.ts +10 -0
- package/build/types/isSyntheticEvent.d.ts.map +1 -0
- package/build/types/sdk.d.ts.map +1 -1
- package/build/types-ts3.8/isSyntheticEvent.d.ts +10 -0
- package/package.json +3 -3
|
@@ -3,53 +3,20 @@ import '@sentry/core/browser';
|
|
|
3
3
|
import '@sentry/browser';
|
|
4
4
|
import '@sentry/core';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* Expects `useEffect`, `useLocation`, `useNavigationType`, `createRoutesFromChildren` and `matchRoutes` to be passed as options.
|
|
9
|
-
*/
|
|
10
|
-
function reactRouterV6BrowserTracingIntegration(
|
|
11
|
-
options,
|
|
12
|
-
) {
|
|
13
|
-
return createReactRouterV6CompatibleTracingIntegration(options, '6');
|
|
6
|
+
function reactRouterV6BrowserTracingIntegration(options) {
|
|
7
|
+
return createReactRouterV6CompatibleTracingIntegration(options, "6");
|
|
14
8
|
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* A wrapper function that adds Sentry routing instrumentation to a React Router v6 useRoutes hook.
|
|
18
|
-
* This is used to automatically capture route changes as transactions when using the useRoutes hook.
|
|
19
|
-
*/
|
|
20
9
|
function wrapUseRoutesV6(origUseRoutes) {
|
|
21
|
-
return createV6CompatibleWrapUseRoutes(origUseRoutes,
|
|
10
|
+
return createV6CompatibleWrapUseRoutes(origUseRoutes, "6");
|
|
22
11
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
* A wrapper function that adds Sentry routing instrumentation to a React Router v6 createBrowserRouter function.
|
|
26
|
-
* This is used to automatically capture route changes as transactions when using the createBrowserRouter API.
|
|
27
|
-
*/
|
|
28
|
-
function wrapCreateBrowserRouterV6
|
|
29
|
-
|
|
30
|
-
(createRouterFunction) {
|
|
31
|
-
return createV6CompatibleWrapCreateBrowserRouter(createRouterFunction, '6');
|
|
12
|
+
function wrapCreateBrowserRouterV6(createRouterFunction) {
|
|
13
|
+
return createV6CompatibleWrapCreateBrowserRouter(createRouterFunction, "6");
|
|
32
14
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
* A wrapper function that adds Sentry routing instrumentation to a React Router v6 createMemoryRouter function.
|
|
36
|
-
* This is used to automatically capture route changes as transactions when using the createMemoryRouter API.
|
|
37
|
-
* The difference between createBrowserRouter and createMemoryRouter is that with createMemoryRouter,
|
|
38
|
-
* optional `initialEntries` are also taken into account.
|
|
39
|
-
*/
|
|
40
|
-
function wrapCreateMemoryRouterV6
|
|
41
|
-
|
|
42
|
-
(createMemoryRouterFunction) {
|
|
43
|
-
return createV6CompatibleWrapCreateMemoryRouter(createMemoryRouterFunction, '6');
|
|
15
|
+
function wrapCreateMemoryRouterV6(createMemoryRouterFunction) {
|
|
16
|
+
return createV6CompatibleWrapCreateMemoryRouter(createMemoryRouterFunction, "6");
|
|
44
17
|
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* A higher-order component that adds Sentry routing instrumentation to a React Router v6 Route component.
|
|
48
|
-
* This is used to automatically capture route changes as transactions.
|
|
49
|
-
*/
|
|
50
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
51
18
|
function withSentryReactRouterV6Routing(routes) {
|
|
52
|
-
return createV6CompatibleWithSentryReactRouterRouting(routes,
|
|
19
|
+
return createV6CompatibleWithSentryReactRouterRouting(routes, "6");
|
|
53
20
|
}
|
|
54
21
|
|
|
55
22
|
export { reactRouterV6BrowserTracingIntegration, withSentryReactRouterV6Routing, wrapCreateBrowserRouterV6, wrapCreateMemoryRouterV6, wrapUseRoutesV6 };
|
|
@@ -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":[],"mappings":";;;;;
|
|
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":[],"mappings":";;;;;AAgBO,SAAS,uCACd,OAAA,EACa;AACb,EAAA,OAAO,+CAAA,CAAgD,SAAS,GAAG,CAAA;AACrE;AAMO,SAAS,gBAAgB,aAAA,EAAqC;AACnE,EAAA,OAAO,+BAAA,CAAgC,eAAe,GAAG,CAAA;AAC3D;AAMO,SAAS,0BAGd,oBAAA,EAAoG;AACpG,EAAA,OAAO,yCAAA,CAA0C,sBAAsB,GAAG,CAAA;AAC5E;AAQO,SAAS,yBAGd,0BAAA,EAA0G;AAC1G,EAAA,OAAO,wCAAA,CAAyC,4BAA4B,GAAG,CAAA;AACjF;AAOO,SAAS,+BAAqF,MAAA,EAAc;AACjH,EAAA,OAAO,8CAAA,CAAqD,QAAQ,GAAG,CAAA;AACzE;;;;"}
|
|
@@ -3,53 +3,20 @@ import '@sentry/core/browser';
|
|
|
3
3
|
import '@sentry/browser';
|
|
4
4
|
import '@sentry/core';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* Expects `useEffect`, `useLocation`, `useNavigationType`, `createRoutesFromChildren` and `matchRoutes` to be passed as options.
|
|
9
|
-
*/
|
|
10
|
-
function reactRouterV7BrowserTracingIntegration(
|
|
11
|
-
options,
|
|
12
|
-
) {
|
|
13
|
-
return createReactRouterV6CompatibleTracingIntegration(options, '7');
|
|
6
|
+
function reactRouterV7BrowserTracingIntegration(options) {
|
|
7
|
+
return createReactRouterV6CompatibleTracingIntegration(options, "7");
|
|
14
8
|
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* A higher-order component that adds Sentry routing instrumentation to a React Router v7 Route component.
|
|
18
|
-
* This is used to automatically capture route changes as transactions.
|
|
19
|
-
*/
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
9
|
function withSentryReactRouterV7Routing(routes) {
|
|
22
|
-
return createV6CompatibleWithSentryReactRouterRouting(routes,
|
|
10
|
+
return createV6CompatibleWithSentryReactRouterRouting(routes, "7");
|
|
23
11
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
* A wrapper function that adds Sentry routing instrumentation to a React Router v7 createBrowserRouter function.
|
|
27
|
-
* This is used to automatically capture route changes as transactions when using the createBrowserRouter API.
|
|
28
|
-
*/
|
|
29
|
-
function wrapCreateBrowserRouterV7
|
|
30
|
-
|
|
31
|
-
(createRouterFunction) {
|
|
32
|
-
return createV6CompatibleWrapCreateBrowserRouter(createRouterFunction, '7');
|
|
12
|
+
function wrapCreateBrowserRouterV7(createRouterFunction) {
|
|
13
|
+
return createV6CompatibleWrapCreateBrowserRouter(createRouterFunction, "7");
|
|
33
14
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
* A wrapper function that adds Sentry routing instrumentation to a React Router v7 createMemoryRouter function.
|
|
37
|
-
* This is used to automatically capture route changes as transactions when using the createMemoryRouter API.
|
|
38
|
-
* The difference between createBrowserRouter and createMemoryRouter is that with createMemoryRouter,
|
|
39
|
-
* optional `initialEntries` are also taken into account.
|
|
40
|
-
*/
|
|
41
|
-
function wrapCreateMemoryRouterV7
|
|
42
|
-
|
|
43
|
-
(createMemoryRouterFunction) {
|
|
44
|
-
return createV6CompatibleWrapCreateMemoryRouter(createMemoryRouterFunction, '7');
|
|
15
|
+
function wrapCreateMemoryRouterV7(createMemoryRouterFunction) {
|
|
16
|
+
return createV6CompatibleWrapCreateMemoryRouter(createMemoryRouterFunction, "7");
|
|
45
17
|
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* A wrapper function that adds Sentry routing instrumentation to a React Router v7 useRoutes hook.
|
|
49
|
-
* This is used to automatically capture route changes as transactions when using the useRoutes hook.
|
|
50
|
-
*/
|
|
51
18
|
function wrapUseRoutesV7(origUseRoutes) {
|
|
52
|
-
return createV6CompatibleWrapUseRoutes(origUseRoutes,
|
|
19
|
+
return createV6CompatibleWrapUseRoutes(origUseRoutes, "7");
|
|
53
20
|
}
|
|
54
21
|
|
|
55
22
|
export { reactRouterV7BrowserTracingIntegration, withSentryReactRouterV7Routing, wrapCreateBrowserRouterV7, wrapCreateMemoryRouterV7, wrapUseRoutesV7 };
|
|
@@ -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":[],"mappings":";;;;;
|
|
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":[],"mappings":";;;;;AAiBO,SAAS,uCACd,OAAA,EACa;AACb,EAAA,OAAO,+CAAA,CAAgD,SAAS,GAAG,CAAA;AACrE;AAOO,SAAS,+BAAqF,MAAA,EAAc;AACjH,EAAA,OAAO,8CAAA,CAAqD,QAAQ,GAAG,CAAA;AACzE;AAMO,SAAS,0BAGd,oBAAA,EAAoG;AACpG,EAAA,OAAO,yCAAA,CAA0C,sBAAsB,GAAG,CAAA;AAC5E;AAQO,SAAS,yBAGd,0BAAA,EAA0G;AAC1G,EAAA,OAAO,wCAAA,CAAyC,4BAA4B,GAAG,CAAA;AACjF;AAMO,SAAS,gBAAgB,aAAA,EAAqC;AACnE,EAAA,OAAO,+BAAA,CAAgC,eAAe,GAAG,CAAA;AAC3D;;;;"}
|
package/build/esm/redux.js
CHANGED
|
@@ -1,102 +1,74 @@
|
|
|
1
1
|
import { getGlobalScope, getCurrentScope, addBreadcrumb, getClient, setNormalizationDepthOverrideHint } from '@sentry/core/browser';
|
|
2
2
|
|
|
3
|
-
const ACTION_BREADCRUMB_CATEGORY =
|
|
4
|
-
const ACTION_BREADCRUMB_TYPE =
|
|
5
|
-
|
|
3
|
+
const ACTION_BREADCRUMB_CATEGORY = "redux.action";
|
|
4
|
+
const ACTION_BREADCRUMB_TYPE = "info";
|
|
6
5
|
const defaultOptions = {
|
|
7
6
|
attachReduxState: true,
|
|
8
|
-
actionTransformer: action => action,
|
|
9
|
-
stateTransformer: state => state || null
|
|
7
|
+
actionTransformer: (action) => action,
|
|
8
|
+
stateTransformer: (state) => state || null
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Creates an enhancer that would be passed to Redux's createStore to log actions and the latest state to Sentry.
|
|
14
|
-
*
|
|
15
|
-
* @param enhancerOptions Options to pass to the enhancer
|
|
16
|
-
*/
|
|
17
10
|
function createReduxEnhancer(enhancerOptions) {
|
|
18
|
-
// Note: We return an any type as to not have type conflicts.
|
|
19
11
|
const options = {
|
|
20
12
|
...defaultOptions,
|
|
21
|
-
...enhancerOptions
|
|
13
|
+
...enhancerOptions
|
|
22
14
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
15
|
+
return (next) => (reducer, initialState) => {
|
|
16
|
+
options.attachReduxState && getGlobalScope().addEventProcessor((event, hint) => {
|
|
17
|
+
try {
|
|
18
|
+
if (event.type === void 0 && event.contexts.state.state.type === "redux") {
|
|
19
|
+
hint.attachments = [
|
|
20
|
+
...hint.attachments || [],
|
|
29
21
|
// @ts-expect-error try catch to reduce bundle size
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
{ filename: 'redux_state.json', data: JSON.stringify(event.contexts.state.state.value) },
|
|
35
|
-
];
|
|
36
|
-
}
|
|
37
|
-
} catch {
|
|
38
|
-
// empty
|
|
39
|
-
}
|
|
40
|
-
return event;
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
function sentryWrapReducer(reducer) {
|
|
44
|
-
return (state, action) => {
|
|
45
|
-
const newState = reducer(state, action);
|
|
46
|
-
|
|
47
|
-
const scope = getCurrentScope();
|
|
48
|
-
|
|
49
|
-
/* Action breadcrumbs */
|
|
50
|
-
const transformedAction = options.actionTransformer(action);
|
|
51
|
-
if (typeof transformedAction !== 'undefined' && transformedAction !== null) {
|
|
52
|
-
addBreadcrumb({
|
|
53
|
-
category: ACTION_BREADCRUMB_CATEGORY,
|
|
54
|
-
data: transformedAction,
|
|
55
|
-
type: ACTION_BREADCRUMB_TYPE,
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/* Set latest state to scope */
|
|
60
|
-
const transformedState = options.stateTransformer(newState);
|
|
61
|
-
if (typeof transformedState !== 'undefined' && transformedState !== null) {
|
|
62
|
-
const client = getClient();
|
|
63
|
-
const options = client?.getOptions();
|
|
64
|
-
const normalizationDepth = options?.normalizeDepth || 3; // default state normalization depth to 3
|
|
65
|
-
|
|
66
|
-
// Set the normalization depth of the redux state to the configured `normalizeDepth` option or a sane number as a fallback
|
|
67
|
-
const newStateContext = { state: { type: 'redux', value: transformedState } };
|
|
68
|
-
setNormalizationDepthOverrideHint(
|
|
69
|
-
newStateContext,
|
|
70
|
-
3 + // 3 layers for `state.value.transformedState`
|
|
71
|
-
normalizationDepth, // rest for the actual state
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
scope.setContext('state', newStateContext);
|
|
75
|
-
} else {
|
|
76
|
-
scope.setContext('state', null);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/* Allow user to configure scope with latest state */
|
|
80
|
-
const { configureScopeWithState } = options;
|
|
81
|
-
if (typeof configureScopeWithState === 'function') {
|
|
82
|
-
configureScopeWithState(scope, newState);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return newState;
|
|
86
|
-
};
|
|
22
|
+
{ filename: "redux_state.json", data: JSON.stringify(event.contexts.state.state.value) }
|
|
23
|
+
];
|
|
24
|
+
}
|
|
25
|
+
} catch {
|
|
87
26
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
27
|
+
return event;
|
|
28
|
+
});
|
|
29
|
+
function sentryWrapReducer(reducer2) {
|
|
30
|
+
return (state, action) => {
|
|
31
|
+
const newState = reducer2(state, action);
|
|
32
|
+
const scope = getCurrentScope();
|
|
33
|
+
const transformedAction = options.actionTransformer(action);
|
|
34
|
+
if (typeof transformedAction !== "undefined" && transformedAction !== null) {
|
|
35
|
+
addBreadcrumb({
|
|
36
|
+
category: ACTION_BREADCRUMB_CATEGORY,
|
|
37
|
+
data: transformedAction,
|
|
38
|
+
type: ACTION_BREADCRUMB_TYPE
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
const transformedState = options.stateTransformer(newState);
|
|
42
|
+
if (typeof transformedState !== "undefined" && transformedState !== null) {
|
|
43
|
+
const client = getClient();
|
|
44
|
+
const options2 = client?.getOptions();
|
|
45
|
+
const normalizationDepth = options2?.normalizeDepth || 3;
|
|
46
|
+
const newStateContext = { state: { type: "redux", value: transformedState } };
|
|
47
|
+
setNormalizationDepthOverrideHint(
|
|
48
|
+
newStateContext,
|
|
49
|
+
3 + // 3 layers for `state.value.transformedState`
|
|
50
|
+
normalizationDepth
|
|
51
|
+
// rest for the actual state
|
|
52
|
+
);
|
|
53
|
+
scope.setContext("state", newStateContext);
|
|
54
|
+
} else {
|
|
55
|
+
scope.setContext("state", null);
|
|
56
|
+
}
|
|
57
|
+
const { configureScopeWithState } = options;
|
|
58
|
+
if (typeof configureScopeWithState === "function") {
|
|
59
|
+
configureScopeWithState(scope, newState);
|
|
60
|
+
}
|
|
61
|
+
return newState;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
const store = next(sentryWrapReducer(reducer), initialState);
|
|
65
|
+
store.replaceReducer = new Proxy(store.replaceReducer, {
|
|
66
|
+
apply: function(target, thisArg, args) {
|
|
67
|
+
target.apply(thisArg, [sentryWrapReducer(args[0])]);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
return store;
|
|
71
|
+
};
|
|
100
72
|
}
|
|
101
73
|
|
|
102
74
|
export { createReduxEnhancer };
|
package/build/esm/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 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":[],"mappings":";;AAiFA,MAAM,0BAAA,GAA6B,
|
|
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":["reducer","options"],"mappings":"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"}
|
package/build/esm/sdk.js
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
import { setContext, init as init$1 } from '@sentry/browser';
|
|
2
|
-
import { applySdkMetadata } from '@sentry/core/browser';
|
|
1
|
+
import { setContext, init as init$1, normalizeStringifyValue as normalizeStringifyValue$1 } from '@sentry/browser';
|
|
2
|
+
import { applySdkMetadata, setNormalizeStringifier } from '@sentry/core/browser';
|
|
3
3
|
import { version } from 'react';
|
|
4
|
+
import { isSyntheticEvent } from './isSyntheticEvent.js';
|
|
4
5
|
|
|
5
|
-
/**
|
|
6
|
-
* Inits the React SDK
|
|
7
|
-
*/
|
|
8
6
|
function init(options) {
|
|
9
7
|
const opts = {
|
|
10
|
-
...options
|
|
8
|
+
...options
|
|
11
9
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
applySdkMetadata(opts, "react");
|
|
11
|
+
setContext("react", { version });
|
|
12
|
+
const client = init$1(opts);
|
|
13
|
+
setNormalizeStringifier(normalizeStringifyValue);
|
|
14
|
+
return client;
|
|
15
|
+
}
|
|
16
|
+
function normalizeStringifyValue(value) {
|
|
17
|
+
if (isSyntheticEvent(value)) {
|
|
18
|
+
return "[SyntheticEvent]";
|
|
19
|
+
}
|
|
20
|
+
return normalizeStringifyValue$1(value);
|
|
16
21
|
}
|
|
17
22
|
|
|
18
23
|
export { init };
|
package/build/esm/sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import type { BrowserOptions } from '@sentry/browser';\nimport {
|
|
1
|
+
{"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import type { BrowserOptions } from '@sentry/browser';\nimport {\n init as browserInit,\n normalizeStringifyValue as browserNormalizeStringifyValue,\n setContext,\n} from '@sentry/browser';\nimport type { Client } from '@sentry/core/browser';\nimport { applySdkMetadata, setNormalizeStringifier } from '@sentry/core/browser';\nimport { version } from 'react';\nimport { isSyntheticEvent } from './isSyntheticEvent';\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 const client = browserInit(opts);\n\n // Add react-specific stringification\n setNormalizeStringifier(normalizeStringifyValue);\n\n return client;\n}\n\nfunction normalizeStringifyValue(value: Exclude<unknown, string | number | boolean | null>): string | undefined {\n if (isSyntheticEvent(value)) {\n return '[SyntheticEvent]';\n }\n return browserNormalizeStringifyValue(value);\n}\n"],"names":["browserInit","browserNormalizeStringifyValue"],"mappings":";;;;;AAcO,SAAS,KAAK,OAAA,EAA6C;AAChE,EAAA,MAAM,IAAA,GAAO;AAAA,IACX,GAAG;AAAA,GACL;AAEA,EAAA,gBAAA,CAAiB,MAAM,OAAO,CAAA;AAC9B,EAAA,UAAA,CAAW,OAAA,EAAS,EAAE,OAAA,EAAS,CAAA;AAC/B,EAAA,MAAM,MAAA,GAASA,OAAY,IAAI,CAAA;AAG/B,EAAA,uBAAA,CAAwB,uBAAuB,CAAA;AAE/C,EAAA,OAAO,MAAA;AACT;AAEA,SAAS,wBAAwB,KAAA,EAA+E;AAC9G,EAAA,IAAI,gBAAA,CAAiB,KAAK,CAAA,EAAG;AAC3B,IAAA,OAAO,kBAAA;AAAA,EACT;AACA,EAAA,OAAOC,0BAA+B,KAAK,CAAA;AAC7C;;;;"}
|
|
@@ -1,130 +1,90 @@
|
|
|
1
1
|
import { browserTracingIntegration, WINDOW, startBrowserTracingPageLoadSpan, startBrowserTracingNavigationSpan } from '@sentry/browser';
|
|
2
2
|
import { SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_OP } from '@sentry/core/browser';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
* A custom browser tracing integration for TanStack Router.
|
|
6
|
-
*
|
|
7
|
-
* The minimum compatible version of `@tanstack/react-router` is `1.64.0`.
|
|
8
|
-
*
|
|
9
|
-
* @param router A TanStack Router `Router` instance that should be used for routing instrumentation.
|
|
10
|
-
* @param options Sentry browser tracing configuration.
|
|
11
|
-
*/
|
|
12
|
-
function tanstackRouterBrowserTracingIntegration(
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
-
router, // This is `any` because we don't want any type mismatches if TanStack Router changes their types
|
|
15
|
-
options = {},
|
|
16
|
-
) {
|
|
4
|
+
function tanstackRouterBrowserTracingIntegration(router, options = {}) {
|
|
17
5
|
const castRouterInstance = router;
|
|
18
|
-
|
|
19
6
|
const browserTracingIntegrationInstance = browserTracingIntegration({
|
|
20
7
|
...options,
|
|
21
8
|
instrumentNavigation: false,
|
|
22
|
-
instrumentPageLoad: false
|
|
9
|
+
instrumentPageLoad: false
|
|
23
10
|
});
|
|
24
|
-
|
|
25
11
|
const { instrumentPageLoad = true, instrumentNavigation = true } = options;
|
|
26
|
-
|
|
27
12
|
return {
|
|
28
13
|
...browserTracingIntegrationInstance,
|
|
29
14
|
afterAllSetup(client) {
|
|
30
15
|
browserTracingIntegrationInstance.afterAllSetup(client);
|
|
31
|
-
|
|
32
16
|
const initialWindowLocation = WINDOW.location;
|
|
33
17
|
if (instrumentPageLoad && initialWindowLocation) {
|
|
34
18
|
const matchedRoutes = castRouterInstance.matchRoutes(
|
|
35
19
|
initialWindowLocation.pathname,
|
|
36
20
|
castRouterInstance.options.parseSearch(initialWindowLocation.search),
|
|
37
|
-
{ preload: false, throwOnError: false }
|
|
21
|
+
{ preload: false, throwOnError: false }
|
|
38
22
|
);
|
|
39
|
-
|
|
40
23
|
const lastMatch = matchedRoutes[matchedRoutes.length - 1];
|
|
41
|
-
|
|
42
|
-
// we fall back to the pathname.
|
|
43
|
-
const routeMatch = lastMatch?.routeId !== '__root__' ? lastMatch : undefined;
|
|
44
|
-
|
|
24
|
+
const routeMatch = lastMatch?.routeId !== "__root__" ? lastMatch : void 0;
|
|
45
25
|
startBrowserTracingPageLoadSpan(client, {
|
|
46
26
|
name: routeMatch ? routeMatch.routeId : initialWindowLocation.pathname,
|
|
47
27
|
attributes: {
|
|
48
|
-
[SEMANTIC_ATTRIBUTE_SENTRY_OP]:
|
|
49
|
-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]:
|
|
50
|
-
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: routeMatch ?
|
|
51
|
-
...routeMatchToParamSpanAttributes(routeMatch)
|
|
52
|
-
}
|
|
28
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: "pageload",
|
|
29
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.pageload.react.tanstack_router",
|
|
30
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: routeMatch ? "route" : "url",
|
|
31
|
+
...routeMatchToParamSpanAttributes(routeMatch)
|
|
32
|
+
}
|
|
53
33
|
});
|
|
54
34
|
}
|
|
55
|
-
|
|
56
35
|
if (instrumentNavigation) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
// onBeforeNavigate is called during pageloads. We can avoid creating navigation spans by:
|
|
60
|
-
// 1. Checking if there's no fromLocation (initial pageload)
|
|
61
|
-
// 2. Comparing the states of the to and from arguments
|
|
62
|
-
if (
|
|
63
|
-
!onBeforeNavigateArgs.fromLocation ||
|
|
64
|
-
onBeforeNavigateArgs.toLocation.state === onBeforeNavigateArgs.fromLocation.state
|
|
65
|
-
) {
|
|
36
|
+
castRouterInstance.subscribe("onBeforeNavigate", (onBeforeNavigateArgs) => {
|
|
37
|
+
if (!onBeforeNavigateArgs.fromLocation || onBeforeNavigateArgs.toLocation.state === onBeforeNavigateArgs.fromLocation.state) {
|
|
66
38
|
return;
|
|
67
39
|
}
|
|
68
|
-
|
|
69
40
|
const matchedRoutesOnBeforeNavigate = castRouterInstance.matchRoutes(
|
|
70
41
|
onBeforeNavigateArgs.toLocation.pathname,
|
|
71
42
|
onBeforeNavigateArgs.toLocation.search,
|
|
72
|
-
{ preload: false, throwOnError: false }
|
|
43
|
+
{ preload: false, throwOnError: false }
|
|
73
44
|
);
|
|
74
|
-
|
|
75
45
|
const onBeforeNavigateLastMatch = matchedRoutesOnBeforeNavigate[matchedRoutesOnBeforeNavigate.length - 1];
|
|
76
|
-
const onBeforeNavigateRouteMatch =
|
|
77
|
-
onBeforeNavigateLastMatch?.routeId !== '__root__' ? onBeforeNavigateLastMatch : undefined;
|
|
78
|
-
|
|
46
|
+
const onBeforeNavigateRouteMatch = onBeforeNavigateLastMatch?.routeId !== "__root__" ? onBeforeNavigateLastMatch : void 0;
|
|
79
47
|
const navigationLocation = WINDOW.location;
|
|
80
48
|
const navigationSpan = startBrowserTracingNavigationSpan(client, {
|
|
81
49
|
name: onBeforeNavigateRouteMatch ? onBeforeNavigateRouteMatch.routeId : navigationLocation.pathname,
|
|
82
50
|
attributes: {
|
|
83
|
-
[SEMANTIC_ATTRIBUTE_SENTRY_OP]:
|
|
84
|
-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]:
|
|
85
|
-
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: onBeforeNavigateRouteMatch ?
|
|
86
|
-
}
|
|
51
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: "navigation",
|
|
52
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.navigation.react.tanstack_router",
|
|
53
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: onBeforeNavigateRouteMatch ? "route" : "url"
|
|
54
|
+
}
|
|
87
55
|
});
|
|
88
|
-
|
|
89
|
-
// In case the user is redirected during navigation we want to update the span with the right value.
|
|
90
|
-
const unsubscribeOnResolved = castRouterInstance.subscribe('onResolved', onResolvedArgs => {
|
|
56
|
+
const unsubscribeOnResolved = castRouterInstance.subscribe("onResolved", (onResolvedArgs) => {
|
|
91
57
|
unsubscribeOnResolved();
|
|
92
58
|
if (navigationSpan) {
|
|
93
59
|
const matchedRoutesOnResolved = castRouterInstance.matchRoutes(
|
|
94
60
|
onResolvedArgs.toLocation.pathname,
|
|
95
61
|
onResolvedArgs.toLocation.search,
|
|
96
|
-
{ preload: false, throwOnError: false }
|
|
62
|
+
{ preload: false, throwOnError: false }
|
|
97
63
|
);
|
|
98
|
-
|
|
99
64
|
const onResolvedLastMatch = matchedRoutesOnResolved[matchedRoutesOnResolved.length - 1];
|
|
100
|
-
const onResolvedRouteMatch =
|
|
101
|
-
onResolvedLastMatch?.routeId !== '__root__' ? onResolvedLastMatch : undefined;
|
|
102
|
-
|
|
65
|
+
const onResolvedRouteMatch = onResolvedLastMatch?.routeId !== "__root__" ? onResolvedLastMatch : void 0;
|
|
103
66
|
if (onResolvedRouteMatch) {
|
|
104
67
|
navigationSpan.updateName(onResolvedRouteMatch.routeId);
|
|
105
|
-
navigationSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
|
|
68
|
+
navigationSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, "route");
|
|
106
69
|
navigationSpan.setAttributes(routeMatchToParamSpanAttributes(onResolvedRouteMatch));
|
|
107
70
|
}
|
|
108
71
|
}
|
|
109
72
|
});
|
|
110
73
|
});
|
|
111
74
|
}
|
|
112
|
-
}
|
|
75
|
+
}
|
|
113
76
|
};
|
|
114
77
|
}
|
|
115
|
-
|
|
116
78
|
function routeMatchToParamSpanAttributes(match) {
|
|
117
79
|
if (!match) {
|
|
118
80
|
return {};
|
|
119
81
|
}
|
|
120
|
-
|
|
121
82
|
const paramAttributes = {};
|
|
122
83
|
Object.entries(match.params).forEach(([key, value]) => {
|
|
123
|
-
paramAttributes[`url.path.params.${key}`] = value;
|
|
84
|
+
paramAttributes[`url.path.params.${key}`] = value;
|
|
124
85
|
paramAttributes[`url.path.parameter.${key}`] = value;
|
|
125
|
-
paramAttributes[`params.${key}`] = value;
|
|
86
|
+
paramAttributes[`params.${key}`] = value;
|
|
126
87
|
});
|
|
127
|
-
|
|
128
88
|
return paramAttributes;
|
|
129
89
|
}
|
|
130
90
|
|