@sentry/react 7.67.0 → 7.69.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/cjs/profiler.js +1 -3
- package/cjs/profiler.js.map +1 -1
- package/cjs/reactrouter.js +2 -2
- package/cjs/reactrouter.js.map +1 -1
- package/cjs/reactrouterv6.js +30 -26
- package/cjs/reactrouterv6.js.map +1 -1
- package/cjs/redux.js +18 -0
- package/cjs/redux.js.map +1 -1
- package/esm/profiler.js +1 -3
- package/esm/profiler.js.map +1 -1
- package/esm/reactrouter.js +2 -2
- package/esm/reactrouter.js.map +1 -1
- package/esm/reactrouterv6.js +30 -26
- package/esm/reactrouterv6.js.map +1 -1
- package/esm/redux.js +19 -1
- package/esm/redux.js.map +1 -1
- package/package.json +5 -5
- package/types/profiler.d.ts.map +1 -1
- package/types/reactrouterv6.d.ts.map +1 -1
- package/types/redux.d.ts +5 -0
- package/types/redux.d.ts.map +1 -1
- package/types-ts3.8/constants.d.ts +4 -0
- package/types-ts3.8/errorboundary.d.ts +70 -0
- package/types-ts3.8/index.d.ts +10 -0
- package/types-ts3.8/profiler.d.ts +60 -0
- package/types-ts3.8/reactrouter.d.ts +25 -0
- package/types-ts3.8/reactrouterv3.d.ts +26 -0
- package/types-ts3.8/reactrouterv6.d.ts +8 -0
- package/types-ts3.8/redux.d.ts +38 -0
- package/types-ts3.8/sdk.d.ts +6 -0
- package/types-ts3.8/types.d.ts +163 -0
package/esm/reactrouterv6.js
CHANGED
|
@@ -183,14 +183,14 @@ function withSentryReactRouterV6Routing(Routes) {
|
|
|
183
183
|
[location, navigationType],
|
|
184
184
|
);
|
|
185
185
|
|
|
186
|
-
// @ts-
|
|
186
|
+
// @ts-expect-error Setting more specific React Component typing for `R` generic above
|
|
187
187
|
// will break advanced type inference done by react router params
|
|
188
188
|
return React.createElement(Routes, { ...props, __self: this, __source: {fileName: _jsxFileName, lineNumber: 207}} );
|
|
189
189
|
};
|
|
190
190
|
|
|
191
191
|
hoistNonReactStatics(SentryRoutes, Routes);
|
|
192
192
|
|
|
193
|
-
// @ts-
|
|
193
|
+
// @ts-expect-error Setting more specific React Component typing for `R` generic above
|
|
194
194
|
// will break advanced type inference done by react router params
|
|
195
195
|
return SentryRoutes;
|
|
196
196
|
}
|
|
@@ -207,36 +207,40 @@ function wrapUseRoutes(origUseRoutes) {
|
|
|
207
207
|
|
|
208
208
|
let isMountRenderPass = true;
|
|
209
209
|
|
|
210
|
-
|
|
211
|
-
return (routes, locationArg) => {
|
|
212
|
-
const SentryRoutes = () => {
|
|
213
|
-
const Routes = origUseRoutes(routes, locationArg);
|
|
210
|
+
const SentryRoutes
|
|
214
211
|
|
|
215
|
-
|
|
216
|
-
|
|
212
|
+
= (props) => {
|
|
213
|
+
const { routes, locationArg } = props;
|
|
217
214
|
|
|
218
|
-
|
|
219
|
-
const stableLocationParam =
|
|
220
|
-
typeof locationArg === 'string' || (locationArg && locationArg.pathname)
|
|
221
|
-
? (locationArg )
|
|
222
|
-
: location;
|
|
215
|
+
const Routes = origUseRoutes(routes, locationArg);
|
|
223
216
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
typeof stableLocationParam === 'string' ? { pathname: stableLocationParam } : stableLocationParam;
|
|
217
|
+
const location = _useLocation();
|
|
218
|
+
const navigationType = _useNavigationType();
|
|
227
219
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
220
|
+
// A value with stable identity to either pick `locationArg` if available or `location` if not
|
|
221
|
+
const stableLocationParam =
|
|
222
|
+
typeof locationArg === 'string' || (locationArg && locationArg.pathname)
|
|
223
|
+
? (locationArg )
|
|
224
|
+
: location;
|
|
225
|
+
|
|
226
|
+
_useEffect(() => {
|
|
227
|
+
const normalizedLocation =
|
|
228
|
+
typeof stableLocationParam === 'string' ? { pathname: stableLocationParam } : stableLocationParam;
|
|
229
|
+
|
|
230
|
+
if (isMountRenderPass) {
|
|
231
|
+
updatePageloadTransaction(normalizedLocation, routes);
|
|
232
|
+
isMountRenderPass = false;
|
|
233
|
+
} else {
|
|
234
|
+
handleNavigation(normalizedLocation, routes, navigationType);
|
|
235
|
+
}
|
|
236
|
+
}, [navigationType, stableLocationParam]);
|
|
235
237
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
+
return Routes;
|
|
239
|
+
};
|
|
238
240
|
|
|
239
|
-
|
|
241
|
+
// eslint-disable-next-line react/display-name
|
|
242
|
+
return (routes, locationArg) => {
|
|
243
|
+
return React.createElement(SentryRoutes, { routes: routes, locationArg: locationArg, __self: this, __source: {fileName: _jsxFileName, lineNumber: 264}} );
|
|
240
244
|
};
|
|
241
245
|
}
|
|
242
246
|
|
package/esm/reactrouterv6.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactrouterv6.js","sources":["../../src/reactrouterv6.tsx"],"sourcesContent":["// Inspired from Donnie McNeal's solution:\n// https://gist.github.com/wontondon/e8c4bdf2888875e4c755712e99279536\n\nimport { WINDOW } from '@sentry/browser';\nimport type { Transaction, TransactionContext, TransactionSource } from '@sentry/types';\nimport { getNumberOfUrlSegments, logger } from '@sentry/utils';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\n\nimport type {\n Action,\n AgnosticDataRouteMatch,\n CreateRouterFunction,\n CreateRoutesFromChildren,\n Location,\n MatchRoutes,\n RouteMatch,\n RouteObject,\n Router,\n RouterState,\n UseEffect,\n UseLocation,\n UseNavigationType,\n UseRoutes,\n} from './types';\n\nlet activeTransaction: Transaction | undefined;\n\nlet _useEffect: UseEffect;\nlet _useLocation: UseLocation;\nlet _useNavigationType: UseNavigationType;\nlet _createRoutesFromChildren: CreateRoutesFromChildren;\nlet _matchRoutes: MatchRoutes;\nlet _customStartTransaction: (context: TransactionContext) => Transaction | undefined;\nlet _startTransactionOnLocationChange: boolean;\n\nconst SENTRY_TAGS = {\n 'routing.instrumentation': 'react-router-v6',\n};\n\nexport function reactRouterV6Instrumentation(\n useEffect: UseEffect,\n useLocation: UseLocation,\n useNavigationType: UseNavigationType,\n createRoutesFromChildren: CreateRoutesFromChildren,\n matchRoutes: MatchRoutes,\n) {\n return (\n customStartTransaction: (context: TransactionContext) => Transaction | undefined,\n startTransactionOnPageLoad = true,\n startTransactionOnLocationChange = true,\n ): void => {\n const initPathName = WINDOW && WINDOW.location && WINDOW.location.pathname;\n if (startTransactionOnPageLoad && initPathName) {\n activeTransaction = customStartTransaction({\n name: initPathName,\n op: 'pageload',\n origin: 'auto.pageload.react.reactrouterv6',\n tags: SENTRY_TAGS,\n metadata: {\n source: 'url',\n },\n });\n }\n\n _useEffect = useEffect;\n _useLocation = useLocation;\n _useNavigationType = useNavigationType;\n _matchRoutes = matchRoutes;\n _createRoutesFromChildren = createRoutesFromChildren;\n\n _customStartTransaction = customStartTransaction;\n _startTransactionOnLocationChange = startTransactionOnLocationChange;\n };\n}\n\nfunction getNormalizedName(\n routes: RouteObject[],\n location: Location,\n branches: RouteMatch[],\n): [string, TransactionSource] {\n if (!routes || routes.length === 0) {\n return [location.pathname, 'url'];\n }\n\n let pathBuilder = '';\n if (branches) {\n // eslint-disable-next-line @typescript-eslint/prefer-for-of\n for (let x = 0; x < branches.length; x++) {\n const branch = branches[x];\n const route = branch.route;\n if (route) {\n // Early return if index route\n if (route.index) {\n return [branch.pathname, 'route'];\n }\n\n const path = route.path;\n if (path) {\n const newPath = path[0] === '/' || pathBuilder[pathBuilder.length - 1] === '/' ? path : `/${path}`;\n pathBuilder += newPath;\n if (branch.pathname === location.pathname) {\n if (\n // If the route defined on the element is something like\n // <Route path=\"/stores/:storeId/products/:productId\" element={<div>Product</div>} />\n // We should check against the branch.pathname for the number of / seperators\n getNumberOfUrlSegments(pathBuilder) !== getNumberOfUrlSegments(branch.pathname) &&\n // We should not count wildcard operators in the url segments calculation\n pathBuilder.slice(-2) !== '/*'\n ) {\n return [newPath, 'route'];\n }\n return [pathBuilder, 'route'];\n }\n }\n }\n }\n }\n\n return [location.pathname, 'url'];\n}\n\nfunction updatePageloadTransaction(\n location: Location,\n routes: RouteObject[],\n matches?: AgnosticDataRouteMatch,\n basename?: string,\n): void {\n const branches = Array.isArray(matches)\n ? matches\n : (_matchRoutes(routes, location, basename) as unknown as RouteMatch[]);\n\n if (activeTransaction && branches) {\n activeTransaction.setName(...getNormalizedName(routes, location, branches));\n }\n}\n\nfunction handleNavigation(\n location: Location,\n routes: RouteObject[],\n navigationType: Action,\n matches?: AgnosticDataRouteMatch,\n basename?: string,\n): void {\n const branches = Array.isArray(matches) ? matches : _matchRoutes(routes, location, basename);\n\n if (_startTransactionOnLocationChange && (navigationType === 'PUSH' || navigationType === 'POP') && branches) {\n if (activeTransaction) {\n activeTransaction.finish();\n }\n\n const [name, source] = getNormalizedName(routes, location, branches);\n activeTransaction = _customStartTransaction({\n name,\n op: 'navigation',\n origin: 'auto.navigation.react.reactrouterv6',\n tags: SENTRY_TAGS,\n metadata: {\n source,\n },\n });\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function withSentryReactRouterV6Routing<P extends Record<string, any>, R extends React.FC<P>>(Routes: R): R {\n if (\n !_useEffect ||\n !_useLocation ||\n !_useNavigationType ||\n !_createRoutesFromChildren ||\n !_matchRoutes ||\n !_customStartTransaction\n ) {\n __DEBUG_BUILD__ &&\n logger.warn(`reactRouterV6Instrumentation was unable to wrap Routes because of one or more missing parameters.\n useEffect: ${_useEffect}. useLocation: ${_useLocation}. useNavigationType: ${_useNavigationType}.\n createRoutesFromChildren: ${_createRoutesFromChildren}. matchRoutes: ${_matchRoutes}. customStartTransaction: ${_customStartTransaction}.`);\n\n return Routes;\n }\n\n let isMountRenderPass: boolean = true;\n\n const SentryRoutes: React.FC<P> = (props: P) => {\n const location = _useLocation();\n const navigationType = _useNavigationType();\n\n _useEffect(\n () => {\n const routes = _createRoutesFromChildren(props.children) as RouteObject[];\n\n if (isMountRenderPass) {\n updatePageloadTransaction(location, routes);\n isMountRenderPass = false;\n } else {\n handleNavigation(location, routes, navigationType);\n }\n },\n // `props.children` is purpusely not included in the dependency array, because we do not want to re-run this effect\n // when the children change. We only want to start transactions when the location or navigation type change.\n [location, navigationType],\n );\n\n // @ts-ignore Setting more specific React Component typing for `R` generic above\n // will break advanced type inference done by react router params\n return <Routes {...props} />;\n };\n\n hoistNonReactStatics(SentryRoutes, Routes);\n\n // @ts-ignore Setting more specific React Component typing for `R` generic above\n // will break advanced type inference done by react router params\n return SentryRoutes;\n}\n\nexport function wrapUseRoutes(origUseRoutes: UseRoutes): UseRoutes {\n if (!_useEffect || !_useLocation || !_useNavigationType || !_matchRoutes || !_customStartTransaction) {\n __DEBUG_BUILD__ &&\n logger.warn(\n 'reactRouterV6Instrumentation was unable to wrap `useRoutes` because of one or more missing parameters.',\n );\n\n return origUseRoutes;\n }\n\n let isMountRenderPass: boolean = true;\n\n // eslint-disable-next-line react/display-name\n return (routes: RouteObject[], locationArg?: Partial<Location> | string): React.ReactElement | null => {\n const SentryRoutes: React.FC<unknown> = () => {\n const Routes = origUseRoutes(routes, locationArg);\n\n const location = _useLocation();\n const navigationType = _useNavigationType();\n\n // A value with stable identity to either pick `locationArg` if available or `location` if not\n const stableLocationParam =\n typeof locationArg === 'string' || (locationArg && locationArg.pathname)\n ? (locationArg as { pathname: string })\n : location;\n\n _useEffect(() => {\n const normalizedLocation =\n typeof stableLocationParam === 'string' ? { pathname: stableLocationParam } : stableLocationParam;\n\n if (isMountRenderPass) {\n updatePageloadTransaction(normalizedLocation, routes);\n isMountRenderPass = false;\n } else {\n handleNavigation(normalizedLocation, routes, navigationType);\n }\n }, [navigationType, stableLocationParam]);\n\n return Routes;\n };\n\n return <SentryRoutes />;\n };\n}\n\nexport function wrapCreateBrowserRouter<\n TState extends RouterState = RouterState,\n TRouter extends Router<TState> = Router<TState>,\n>(createRouterFunction: CreateRouterFunction<TState, TRouter>): CreateRouterFunction<TState, TRouter> {\n // `opts` for createBrowserHistory and createMemoryHistory are different, but also not relevant for us at the moment.\n // `basename` is the only option that is relevant for us, and it is the same for all.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return function (routes: RouteObject[], opts?: Record<string, any> & { basename?: string }): TRouter {\n const router = createRouterFunction(routes, opts);\n const basename = opts && opts.basename;\n\n // The initial load ends when `createBrowserRouter` is called.\n // This is the earliest convenient time to update the transaction name.\n // Callbacks to `router.subscribe` are not called for the initial load.\n if (router.state.historyAction === 'POP' && activeTransaction) {\n updatePageloadTransaction(router.state.location, routes, undefined, basename);\n }\n\n router.subscribe((state: RouterState) => {\n const location = state.location;\n\n if (\n _startTransactionOnLocationChange &&\n (state.historyAction === 'PUSH' || state.historyAction === 'POP') &&\n activeTransaction\n ) {\n handleNavigation(location, routes, state.historyAction, undefined, basename);\n }\n });\n\n return router;\n };\n}\n"],"names":[],"mappings":";;;;;AAAA,MAAA,YAAA,GAAA,4FAAA,CAAA;;AA0BA,IAAA,iBAAA,CAAA;AACA;AACA,IAAA,UAAA,CAAA;AACA,IAAA,YAAA,CAAA;AACA,IAAA,kBAAA,CAAA;AACA,IAAA,yBAAA,CAAA;AACA,IAAA,YAAA,CAAA;AACA,IAAA,uBAAA,CAAA;AACA,IAAA,iCAAA,CAAA;AACA;AACA,MAAA,WAAA,GAAA;AACA,EAAA,yBAAA,EAAA,iBAAA;AACA,CAAA,CAAA;AACA;AACA,SAAA,4BAAA;AACA,EAAA,SAAA;AACA,EAAA,WAAA;AACA,EAAA,iBAAA;AACA,EAAA,wBAAA;AACA,EAAA,WAAA;AACA,EAAA;AACA,EAAA,OAAA;AACA,IAAA,sBAAA;AACA,IAAA,0BAAA,GAAA,IAAA;AACA,IAAA,gCAAA,GAAA,IAAA;AACA,OAAA;AACA,IAAA,MAAA,YAAA,GAAA,MAAA,IAAA,MAAA,CAAA,QAAA,IAAA,MAAA,CAAA,QAAA,CAAA,QAAA,CAAA;AACA,IAAA,IAAA,0BAAA,IAAA,YAAA,EAAA;AACA,MAAA,iB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A,SAAA,uBAAA;;AAGA,CAAA,oBAAA,EAAA;AACA;AACA;AACA;AACA,EAAA,OAAA,UAAA,MAAA,EAAA,IAAA,EAAA;AACA,IAAA,MAAA,MAAA,GAAA,oBAAA,CAAA,MAAA,EAAA,IAAA,CAAA,CAAA;AACA,IAAA,MAAA,QAAA,GAAA,IAAA,IAAA,IAAA,CAAA,QAAA,CAAA;AACA;AACA;AACA;AACA;AACA,IAAA,IAAA,MAAA,CAAA,KAAA,CAAA,aAAA,KAAA,KAAA,IAAA,iBAAA,EAAA;AACA,MAAA,yBAAA,CAAA,MAAA,CAAA,KAAA,CAAA,QAAA,EAAA,MAAA,EAAA,SAAA,EAAA,QAAA,CAAA,CAAA;AACA,KAAA;AACA;AACA,IAAA,MAAA,CAAA,SAAA,CAAA,CAAA,KAAA,KAAA;AACA,MAAA,MAAA,QAAA,GAAA,KAAA,CAAA,QAAA,CAAA;AACA;AACA,MAAA;AACA,QAAA,iCAAA;AACA,SAAA,KAAA,CAAA,aAAA,KAAA,MAAA,IAAA,KAAA,CAAA,aAAA,KAAA,KAAA,CAAA;AACA,QAAA,iBAAA;AACA,QAAA;AACA,QAAA,gBAAA,CAAA,QAAA,EAAA,MAAA,EAAA,KAAA,CAAA,aAAA,EAAA,SAAA,EAAA,QAAA,CAAA,CAAA;AACA,OAAA;AACA,KAAA,CAAA,CAAA;AACA;AACA,IAAA,OAAA,MAAA,CAAA;AACA,GAAA,CAAA;AACA;;;;"}
|
|
1
|
+
{"version":3,"file":"reactrouterv6.js","sources":["../../src/reactrouterv6.tsx"],"sourcesContent":["// Inspired from Donnie McNeal's solution:\n// https://gist.github.com/wontondon/e8c4bdf2888875e4c755712e99279536\n\nimport { WINDOW } from '@sentry/browser';\nimport type { Transaction, TransactionContext, TransactionSource } from '@sentry/types';\nimport { getNumberOfUrlSegments, logger } from '@sentry/utils';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\n\nimport type {\n Action,\n AgnosticDataRouteMatch,\n CreateRouterFunction,\n CreateRoutesFromChildren,\n Location,\n MatchRoutes,\n RouteMatch,\n RouteObject,\n Router,\n RouterState,\n UseEffect,\n UseLocation,\n UseNavigationType,\n UseRoutes,\n} from './types';\n\nlet activeTransaction: Transaction | undefined;\n\nlet _useEffect: UseEffect;\nlet _useLocation: UseLocation;\nlet _useNavigationType: UseNavigationType;\nlet _createRoutesFromChildren: CreateRoutesFromChildren;\nlet _matchRoutes: MatchRoutes;\nlet _customStartTransaction: (context: TransactionContext) => Transaction | undefined;\nlet _startTransactionOnLocationChange: boolean;\n\nconst SENTRY_TAGS = {\n 'routing.instrumentation': 'react-router-v6',\n};\n\nexport function reactRouterV6Instrumentation(\n useEffect: UseEffect,\n useLocation: UseLocation,\n useNavigationType: UseNavigationType,\n createRoutesFromChildren: CreateRoutesFromChildren,\n matchRoutes: MatchRoutes,\n) {\n return (\n customStartTransaction: (context: TransactionContext) => Transaction | undefined,\n startTransactionOnPageLoad = true,\n startTransactionOnLocationChange = true,\n ): void => {\n const initPathName = WINDOW && WINDOW.location && WINDOW.location.pathname;\n if (startTransactionOnPageLoad && initPathName) {\n activeTransaction = customStartTransaction({\n name: initPathName,\n op: 'pageload',\n origin: 'auto.pageload.react.reactrouterv6',\n tags: SENTRY_TAGS,\n metadata: {\n source: 'url',\n },\n });\n }\n\n _useEffect = useEffect;\n _useLocation = useLocation;\n _useNavigationType = useNavigationType;\n _matchRoutes = matchRoutes;\n _createRoutesFromChildren = createRoutesFromChildren;\n\n _customStartTransaction = customStartTransaction;\n _startTransactionOnLocationChange = startTransactionOnLocationChange;\n };\n}\n\nfunction getNormalizedName(\n routes: RouteObject[],\n location: Location,\n branches: RouteMatch[],\n): [string, TransactionSource] {\n if (!routes || routes.length === 0) {\n return [location.pathname, 'url'];\n }\n\n let pathBuilder = '';\n if (branches) {\n // eslint-disable-next-line @typescript-eslint/prefer-for-of\n for (let x = 0; x < branches.length; x++) {\n const branch = branches[x];\n const route = branch.route;\n if (route) {\n // Early return if index route\n if (route.index) {\n return [branch.pathname, 'route'];\n }\n\n const path = route.path;\n if (path) {\n const newPath = path[0] === '/' || pathBuilder[pathBuilder.length - 1] === '/' ? path : `/${path}`;\n pathBuilder += newPath;\n if (branch.pathname === location.pathname) {\n if (\n // If the route defined on the element is something like\n // <Route path=\"/stores/:storeId/products/:productId\" element={<div>Product</div>} />\n // We should check against the branch.pathname for the number of / seperators\n getNumberOfUrlSegments(pathBuilder) !== getNumberOfUrlSegments(branch.pathname) &&\n // We should not count wildcard operators in the url segments calculation\n pathBuilder.slice(-2) !== '/*'\n ) {\n return [newPath, 'route'];\n }\n return [pathBuilder, 'route'];\n }\n }\n }\n }\n }\n\n return [location.pathname, 'url'];\n}\n\nfunction updatePageloadTransaction(\n location: Location,\n routes: RouteObject[],\n matches?: AgnosticDataRouteMatch,\n basename?: string,\n): void {\n const branches = Array.isArray(matches)\n ? matches\n : (_matchRoutes(routes, location, basename) as unknown as RouteMatch[]);\n\n if (activeTransaction && branches) {\n activeTransaction.setName(...getNormalizedName(routes, location, branches));\n }\n}\n\nfunction handleNavigation(\n location: Location,\n routes: RouteObject[],\n navigationType: Action,\n matches?: AgnosticDataRouteMatch,\n basename?: string,\n): void {\n const branches = Array.isArray(matches) ? matches : _matchRoutes(routes, location, basename);\n\n if (_startTransactionOnLocationChange && (navigationType === 'PUSH' || navigationType === 'POP') && branches) {\n if (activeTransaction) {\n activeTransaction.finish();\n }\n\n const [name, source] = getNormalizedName(routes, location, branches);\n activeTransaction = _customStartTransaction({\n name,\n op: 'navigation',\n origin: 'auto.navigation.react.reactrouterv6',\n tags: SENTRY_TAGS,\n metadata: {\n source,\n },\n });\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function withSentryReactRouterV6Routing<P extends Record<string, any>, R extends React.FC<P>>(Routes: R): R {\n if (\n !_useEffect ||\n !_useLocation ||\n !_useNavigationType ||\n !_createRoutesFromChildren ||\n !_matchRoutes ||\n !_customStartTransaction\n ) {\n __DEBUG_BUILD__ &&\n logger.warn(`reactRouterV6Instrumentation was unable to wrap Routes because of one or more missing parameters.\n useEffect: ${_useEffect}. useLocation: ${_useLocation}. useNavigationType: ${_useNavigationType}.\n createRoutesFromChildren: ${_createRoutesFromChildren}. matchRoutes: ${_matchRoutes}. customStartTransaction: ${_customStartTransaction}.`);\n\n return Routes;\n }\n\n let isMountRenderPass: boolean = true;\n\n const SentryRoutes: React.FC<P> = (props: P) => {\n const location = _useLocation();\n const navigationType = _useNavigationType();\n\n _useEffect(\n () => {\n const routes = _createRoutesFromChildren(props.children) as RouteObject[];\n\n if (isMountRenderPass) {\n updatePageloadTransaction(location, routes);\n isMountRenderPass = false;\n } else {\n handleNavigation(location, routes, navigationType);\n }\n },\n // `props.children` is purpusely not included in the dependency array, because we do not want to re-run this effect\n // when the children change. We only want to start transactions when the location or navigation type change.\n [location, navigationType],\n );\n\n // @ts-expect-error Setting more specific React Component typing for `R` generic above\n // will break advanced type inference done by react router params\n return <Routes {...props} />;\n };\n\n hoistNonReactStatics(SentryRoutes, Routes);\n\n // @ts-expect-error Setting more specific React Component typing for `R` generic above\n // will break advanced type inference done by react router params\n return SentryRoutes;\n}\n\nexport function wrapUseRoutes(origUseRoutes: UseRoutes): UseRoutes {\n if (!_useEffect || !_useLocation || !_useNavigationType || !_matchRoutes || !_customStartTransaction) {\n __DEBUG_BUILD__ &&\n logger.warn(\n 'reactRouterV6Instrumentation was unable to wrap `useRoutes` because of one or more missing parameters.',\n );\n\n return origUseRoutes;\n }\n\n let isMountRenderPass: boolean = true;\n\n const SentryRoutes: React.FC<{\n children?: React.ReactNode;\n routes: RouteObject[];\n locationArg?: Partial<Location> | string;\n }> = (props: { children?: React.ReactNode; routes: RouteObject[]; locationArg?: Partial<Location> | string }) => {\n const { routes, locationArg } = props;\n\n const Routes = origUseRoutes(routes, locationArg);\n\n const location = _useLocation();\n const navigationType = _useNavigationType();\n\n // A value with stable identity to either pick `locationArg` if available or `location` if not\n const stableLocationParam =\n typeof locationArg === 'string' || (locationArg && locationArg.pathname)\n ? (locationArg as { pathname: string })\n : location;\n\n _useEffect(() => {\n const normalizedLocation =\n typeof stableLocationParam === 'string' ? { pathname: stableLocationParam } : stableLocationParam;\n\n if (isMountRenderPass) {\n updatePageloadTransaction(normalizedLocation, routes);\n isMountRenderPass = false;\n } else {\n handleNavigation(normalizedLocation, routes, navigationType);\n }\n }, [navigationType, stableLocationParam]);\n\n return Routes;\n };\n\n // eslint-disable-next-line react/display-name\n return (routes: RouteObject[], locationArg?: Partial<Location> | string): React.ReactElement | null => {\n return <SentryRoutes routes={routes} locationArg={locationArg} />;\n };\n}\n\nexport function wrapCreateBrowserRouter<\n TState extends RouterState = RouterState,\n TRouter extends Router<TState> = Router<TState>,\n>(createRouterFunction: CreateRouterFunction<TState, TRouter>): CreateRouterFunction<TState, TRouter> {\n // `opts` for createBrowserHistory and createMemoryHistory are different, but also not relevant for us at the moment.\n // `basename` is the only option that is relevant for us, and it is the same for all.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return function (routes: RouteObject[], opts?: Record<string, any> & { basename?: string }): TRouter {\n const router = createRouterFunction(routes, opts);\n const basename = opts && opts.basename;\n\n // The initial load ends when `createBrowserRouter` is called.\n // This is the earliest convenient time to update the transaction name.\n // Callbacks to `router.subscribe` are not called for the initial load.\n if (router.state.historyAction === 'POP' && activeTransaction) {\n updatePageloadTransaction(router.state.location, routes, undefined, basename);\n }\n\n router.subscribe((state: RouterState) => {\n const location = state.location;\n\n if (\n _startTransactionOnLocationChange &&\n (state.historyAction === 'PUSH' || state.historyAction === 'POP') &&\n activeTransaction\n ) {\n handleNavigation(location, routes, state.historyAction, undefined, basename);\n }\n });\n\n return router;\n };\n}\n"],"names":[],"mappings":";;;;;AAAA,MAAA,YAAA,GAAA,4FAAA,CAAA;;AA0BA,IAAA,iBAAA,CAAA;AACA;AACA,IAAA,UAAA,CAAA;AACA,IAAA,YAAA,CAAA;AACA,IAAA,kBAAA,CAAA;AACA,IAAA,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AA,CAAA;AACA;AACA,MAAA;AACA,QAAA,iCAAA;AACA,SAAA,KAAA,CAAA,aAAA,KAAA,MAAA,IAAA,KAAA,CAAA,aAAA,KAAA,KAAA,CAAA;AACA,QAAA,iBAAA;AACA,QAAA;AACA,QAAA,gBAAA,CAAA,QAAA,EAAA,MAAA,EAAA,KAAA,CAAA,aAAA,EAAA,SAAA,EAAA,QAAA,CAAA,CAAA;AACA,OAAA;AACA,KAAA,CAAA,CAAA;AACA;AACA,IAAA,OAAA,MAAA,CAAA;AACA,GAAA,CAAA;AACA;;;;"}
|
package/esm/redux.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { configureScope, getCurrentHub } from '@sentry/browser';
|
|
1
|
+
import { addGlobalEventProcessor, configureScope, getCurrentHub } from '@sentry/browser';
|
|
2
2
|
import { addNonEnumerableProperty } from '@sentry/utils';
|
|
3
3
|
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
@@ -7,6 +7,7 @@ const ACTION_BREADCRUMB_CATEGORY = 'redux.action';
|
|
|
7
7
|
const ACTION_BREADCRUMB_TYPE = 'info';
|
|
8
8
|
|
|
9
9
|
const defaultOptions = {
|
|
10
|
+
attachReduxState: true,
|
|
10
11
|
actionTransformer: action => action,
|
|
11
12
|
stateTransformer: state => state || null,
|
|
12
13
|
};
|
|
@@ -25,6 +26,23 @@ function createReduxEnhancer(enhancerOptions) {
|
|
|
25
26
|
|
|
26
27
|
return (next) =>
|
|
27
28
|
(reducer, initialState) => {
|
|
29
|
+
options.attachReduxState &&
|
|
30
|
+
addGlobalEventProcessor((event, hint) => {
|
|
31
|
+
try {
|
|
32
|
+
// @ts-expect-error try catch to reduce bundle size
|
|
33
|
+
if (event.type === undefined && event.contexts.state.state.type === 'redux') {
|
|
34
|
+
hint.attachments = [
|
|
35
|
+
...(hint.attachments || []),
|
|
36
|
+
// @ts-expect-error try catch to reduce bundle size
|
|
37
|
+
{ filename: 'redux_state.json', data: JSON.stringify(event.contexts.state.state.value) },
|
|
38
|
+
];
|
|
39
|
+
}
|
|
40
|
+
} catch (_) {
|
|
41
|
+
// empty
|
|
42
|
+
}
|
|
43
|
+
return event;
|
|
44
|
+
});
|
|
45
|
+
|
|
28
46
|
const sentryReducer = (state, action) => {
|
|
29
47
|
const newState = reducer(state, action);
|
|
30
48
|
|
package/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 { configureScope, getCurrentHub } from '@sentry/browser';\nimport type { Scope } from '@sentry/types';\nimport { addNonEnumerableProperty } from '@sentry/utils';\n\ninterface Action<T = any> {\n type: T;\n}\n\ninterface AnyAction extends Action {\n [extraProps: string]: any;\n}\n\ntype Reducer<S = any, A extends Action = AnyAction> = (state: S | undefined, action: A) => S;\n\ntype Dispatch<A extends Action = AnyAction> = <T extends A>(action: T, ...extraArgs: any[]) => T;\n\ntype ExtendState<State, Extension> = [Extension] extends [never] ? State : State & Extension;\n\ntype Unsubscribe = () => void;\n\ninterface Store<S = any, A extends Action = AnyAction, StateExt = never, Ext = Record<string, unknown>> {\n dispatch: Dispatch<A>;\n getState(): S;\n subscribe(listener: () => void): Unsubscribe;\n replaceReducer<NewState, NewActions extends Action>(\n nextReducer: Reducer<NewState, NewActions>,\n ): Store<ExtendState<NewState, StateExt>, NewActions, StateExt, Ext> & Ext;\n}\n\ndeclare const $CombinedState: unique symbol;\n\ntype CombinedState<S> = { readonly [$CombinedState]?: undefined } & S;\n\ntype PreloadedState<S> = Required<S> extends {\n [$CombinedState]: undefined;\n}\n ? S extends CombinedState<infer S1>\n ? { [K in keyof S1]?: S1[K] extends Record<string, unknown> ? PreloadedState<S1[K]> : S1[K] }\n : never\n : { [K in keyof S]: S[K] extends string | number | boolean | symbol ? S[K] : PreloadedState<S[K]> };\n\ntype StoreEnhancerStoreCreator<Ext = Record<string, unknown>, StateExt = never> = <\n S = any,\n A extends Action = AnyAction,\n>(\n reducer: Reducer<S, A>,\n preloadedState?: PreloadedState<S>,\n) => Store<ExtendState<S, StateExt>, A, StateExt, Ext> & Ext;\n\nexport interface SentryEnhancerOptions<S = any> {\n /**\n * 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 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 const sentryReducer: Reducer<S, A> = (state, action): S => {\n const newState = reducer(state, action);\n\n configureScope(scope => {\n /* Action breadcrumbs */\n const transformedAction = options.actionTransformer(action);\n if (typeof transformedAction !== 'undefined' && transformedAction !== null) {\n scope.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 = getCurrentHub().getClient();\n const options = client && client.getOptions();\n const normalizationDepth = (options && options.normalizeDepth) || 3; // default state normalization depth to 3\n\n // Set the normalization depth of the redux state to the configured `normalizeDepth` option or a sane number as a fallback\n const newStateContext = { state: { type: 'redux', value: transformedState } };\n addNonEnumerableProperty(\n newStateContext,\n '__sentry_override_normalization_depth__',\n 3 + // 3 layers for `state.value.transformedState`\n normalizationDepth, // rest for the actual state\n );\n\n scope.setContext('state', newStateContext);\n } else {\n scope.setContext('state', null);\n }\n\n /* Allow user to configure scope with latest state */\n const { configureScopeWithState } = options;\n if (typeof configureScopeWithState === 'function') {\n configureScopeWithState(scope, newState);\n }\n });\n\n return newState;\n };\n\n return next(sentryReducer, initialState);\n };\n}\n\nexport { createReduxEnhancer };\n"],"names":[],"mappings":";;;AAAA;;
|
|
1
|
+
{"version":3,"file":"redux.js","sources":["../../src/redux.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { addGlobalEventProcessor, configureScope, getCurrentHub } from '@sentry/browser';\nimport type { Scope } from '@sentry/types';\nimport { addNonEnumerableProperty } from '@sentry/utils';\n\ninterface Action<T = any> {\n type: T;\n}\n\ninterface AnyAction extends Action {\n [extraProps: string]: any;\n}\n\ntype Reducer<S = any, A extends Action = AnyAction> = (state: S | undefined, action: A) => S;\n\ntype Dispatch<A extends Action = AnyAction> = <T extends A>(action: T, ...extraArgs: any[]) => T;\n\ntype ExtendState<State, Extension> = [Extension] extends [never] ? State : State & Extension;\n\ntype Unsubscribe = () => void;\n\ninterface Store<S = any, A extends Action = AnyAction, StateExt = never, Ext = Record<string, unknown>> {\n dispatch: Dispatch<A>;\n getState(): S;\n subscribe(listener: () => void): Unsubscribe;\n replaceReducer<NewState, NewActions extends Action>(\n nextReducer: Reducer<NewState, NewActions>,\n ): Store<ExtendState<NewState, StateExt>, NewActions, StateExt, Ext> & Ext;\n}\n\ndeclare const $CombinedState: unique symbol;\n\ntype CombinedState<S> = { readonly [$CombinedState]?: undefined } & S;\n\ntype PreloadedState<S> = Required<S> extends {\n [$CombinedState]: undefined;\n}\n ? S extends CombinedState<infer S1>\n ? { [K in keyof S1]?: S1[K] extends Record<string, unknown> ? PreloadedState<S1[K]> : S1[K] }\n : never\n : { [K in keyof S]: S[K] extends string | number | boolean | symbol ? S[K] : PreloadedState<S[K]> };\n\ntype StoreEnhancerStoreCreator<Ext = Record<string, unknown>, StateExt = never> = <\n S = any,\n A extends Action = AnyAction,\n>(\n reducer: Reducer<S, A>,\n preloadedState?: PreloadedState<S>,\n) => Store<ExtendState<S, StateExt>, A, StateExt, Ext> & Ext;\n\nexport interface SentryEnhancerOptions<S = any> {\n /**\n * Redux state in attachments or not.\n * @default true\n */\n attachReduxState?: boolean;\n\n /**\n * Transforms the state before attaching it to an event.\n * Use this to remove any private data before sending it to Sentry.\n * Return null to not attach the state.\n */\n stateTransformer(state: S | undefined): (S & any) | null;\n /**\n * Transforms the action before sending it as a breadcrumb.\n * Use this to remove any private data before sending it to Sentry.\n * Return null to not send the breadcrumb.\n */\n actionTransformer(action: AnyAction): AnyAction | null;\n /**\n * Called on every state update, configure the Sentry Scope with the redux state.\n */\n configureScopeWithState?(scope: Scope, state: S): void;\n}\n\nconst ACTION_BREADCRUMB_CATEGORY = 'redux.action';\nconst ACTION_BREADCRUMB_TYPE = 'info';\n\nconst defaultOptions: SentryEnhancerOptions = {\n attachReduxState: true,\n actionTransformer: action => action,\n stateTransformer: state => state || null,\n};\n\n/**\n * Creates an enhancer that would be passed to Redux's createStore to log actions and the latest state to Sentry.\n *\n * @param enhancerOptions Options to pass to the enhancer\n */\nfunction createReduxEnhancer(enhancerOptions?: Partial<SentryEnhancerOptions>): any {\n // Note: We return an any type as to not have type conflicts.\n const options = {\n ...defaultOptions,\n ...enhancerOptions,\n };\n\n return (next: StoreEnhancerStoreCreator): StoreEnhancerStoreCreator =>\n <S = any, A extends Action = AnyAction>(reducer: Reducer<S, A>, initialState?: PreloadedState<S>) => {\n options.attachReduxState &&\n addGlobalEventProcessor((event, hint) => {\n try {\n // @ts-expect-error try catch to reduce bundle size\n if (event.type === undefined && event.contexts.state.state.type === 'redux') {\n hint.attachments = [\n ...(hint.attachments || []),\n // @ts-expect-error try catch to reduce bundle size\n { filename: 'redux_state.json', data: JSON.stringify(event.contexts.state.state.value) },\n ];\n }\n } catch (_) {\n // empty\n }\n return event;\n });\n\n const sentryReducer: Reducer<S, A> = (state, action): S => {\n const newState = reducer(state, action);\n\n configureScope(scope => {\n /* Action breadcrumbs */\n const transformedAction = options.actionTransformer(action);\n if (typeof transformedAction !== 'undefined' && transformedAction !== null) {\n scope.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 = getCurrentHub().getClient();\n const options = client && client.getOptions();\n const normalizationDepth = (options && options.normalizeDepth) || 3; // default state normalization depth to 3\n\n // Set the normalization depth of the redux state to the configured `normalizeDepth` option or a sane number as a fallback\n const newStateContext = { state: { type: 'redux', value: transformedState } };\n addNonEnumerableProperty(\n newStateContext,\n '__sentry_override_normalization_depth__',\n 3 + // 3 layers for `state.value.transformedState`\n normalizationDepth, // rest for the actual state\n );\n\n scope.setContext('state', newStateContext);\n } else {\n scope.setContext('state', null);\n }\n\n /* Allow user to configure scope with latest state */\n const { configureScopeWithState } = options;\n if (typeof configureScopeWithState === 'function') {\n configureScopeWithState(scope, newState);\n }\n });\n\n return newState;\n };\n\n return next(sentryReducer, initialState);\n };\n}\n\nexport { createReduxEnhancer };\n"],"names":[],"mappings":";;;AAAA;;AA2EA,MAAA,0BAAA,GAAA,cAAA,CAAA;AACA,MAAA,sBAAA,GAAA,MAAA,CAAA;AACA;AACA,MAAA,cAAA,GAAA;AACA,EAAA,gBAAA,EAAA,IAAA;AACA,EAAA,iBAAA,EAAA,MAAA,IAAA,MAAA;AACA,EAAA,gBAAA,EAAA,KAAA,I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;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/react",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.69.0",
|
|
4
4
|
"description": "Official Sentry SDK for React.js",
|
|
5
5
|
"repository": "git://github.com/getsentry/sentry-javascript.git",
|
|
6
6
|
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/react",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"types": "types/index.d.ts",
|
|
15
15
|
"typesVersions": {
|
|
16
16
|
"<4.9": {
|
|
17
|
-
"
|
|
17
|
+
"types/index.d.ts": [
|
|
18
18
|
"types-ts3.8/index.d.ts"
|
|
19
19
|
]
|
|
20
20
|
}
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@sentry/browser": "7.
|
|
27
|
-
"@sentry/types": "7.
|
|
28
|
-
"@sentry/utils": "7.
|
|
26
|
+
"@sentry/browser": "7.69.0",
|
|
27
|
+
"@sentry/types": "7.69.0",
|
|
28
|
+
"@sentry/utils": "7.69.0",
|
|
29
29
|
"hoist-non-react-statics": "^3.3.2",
|
|
30
30
|
"tslib": "^2.4.1 || ^1.9.3"
|
|
31
31
|
},
|
package/types/profiler.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiler.d.ts","sourceRoot":"","sources":["../../src/profiler.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGvD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAE3C,MAAM,MAAM,aAAa,GAAG;IAE1B,IAAI,EAAE,MAAM,CAAC;IAGb,QAAQ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M,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,EAC/C,oBAAoB,EAAE,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC,CA6BpG"}
|
package/types/redux.d.ts
CHANGED
|
@@ -6,6 +6,11 @@ interface AnyAction extends Action {
|
|
|
6
6
|
[extraProps: string]: any;
|
|
7
7
|
}
|
|
8
8
|
export interface SentryEnhancerOptions<S = any> {
|
|
9
|
+
/**
|
|
10
|
+
* Redux state in attachments or not.
|
|
11
|
+
* @default true
|
|
12
|
+
*/
|
|
13
|
+
attachReduxState?: boolean;
|
|
9
14
|
/**
|
|
10
15
|
* Transforms the state before attaching it to an event.
|
|
11
16
|
* Use this to remove any private data before sending it to Sentry.
|
package/types/redux.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redux.d.ts","sourceRoot":"","sources":["../../src/redux.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAG3C,UAAU,MAAM,CAAC,CAAC,GAAG,GAAG;IACtB,IAAI,EAAE,CAAC,CAAC;CACT;AAED,UAAU,SAAU,SAAQ,MAAM;IAChC,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAC;CAC3B;AAuCD,MAAM,WAAW,qBAAqB,CAAC,CAAC,GAAG,GAAG;IAC5C;;;;OAIG;IACH,gBAAgB,CAAC,KAAK,EAAE,CAAC,GAAG,SAAS,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC;IACzD;;;;OAIG;IACH,iBAAiB,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,IAAI,CAAC;IACvD;;OAEG;IACH,uBAAuB,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;CACxD;
|
|
1
|
+
{"version":3,"file":"redux.d.ts","sourceRoot":"","sources":["../../src/redux.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAG3C,UAAU,MAAM,CAAC,CAAC,GAAG,GAAG;IACtB,IAAI,EAAE,CAAC,CAAC;CACT;AAED,UAAU,SAAU,SAAQ,MAAM;IAChC,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAC;CAC3B;AAuCD,MAAM,WAAW,qBAAqB,CAAC,CAAC,GAAG,GAAG;IAC5C;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;;;OAIG;IACH,gBAAgB,CAAC,KAAK,EAAE,CAAC,GAAG,SAAS,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC;IACzD;;;;OAIG;IACH,iBAAiB,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,IAAI,CAAC;IACvD;;OAEG;IACH,uBAAuB,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;CACxD;AAWD;;;;GAIG;AACH,iBAAS,mBAAmB,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,GAAG,GAAG,CAyElF;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { ReportDialogOptions, Scope } from '@sentry/browser';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
export declare function isAtLeastReact17(version: string): boolean;
|
|
4
|
+
export declare const UNKNOWN_COMPONENT = "unknown";
|
|
5
|
+
export type FallbackRender = (errorData: {
|
|
6
|
+
error: Error;
|
|
7
|
+
componentStack: string;
|
|
8
|
+
eventId: string;
|
|
9
|
+
resetError(): void;
|
|
10
|
+
}) => React.ReactElement;
|
|
11
|
+
export type ErrorBoundaryProps = {
|
|
12
|
+
children?: React.ReactNode | (() => React.ReactNode);
|
|
13
|
+
/** If a Sentry report dialog should be rendered on error */
|
|
14
|
+
showDialog?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Options to be passed into the Sentry report dialog.
|
|
17
|
+
* No-op if {@link showDialog} is false.
|
|
18
|
+
*/
|
|
19
|
+
dialogOptions?: ReportDialogOptions;
|
|
20
|
+
/**
|
|
21
|
+
* A fallback component that gets rendered when the error boundary encounters an error.
|
|
22
|
+
*
|
|
23
|
+
* Can either provide a React Component, or a function that returns React Component as
|
|
24
|
+
* a valid fallback prop. If a function is provided, the function will be called with
|
|
25
|
+
* the error, the component stack, and an function that resets the error boundary on error.
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
28
|
+
fallback?: React.ReactElement | FallbackRender;
|
|
29
|
+
/** Called when the error boundary encounters an error */
|
|
30
|
+
onError?(error: Error, componentStack: string, eventId: string): void;
|
|
31
|
+
/** Called on componentDidMount() */
|
|
32
|
+
onMount?(): void;
|
|
33
|
+
/** Called if resetError() is called from the fallback render props function */
|
|
34
|
+
onReset?(error: Error | null, componentStack: string | null, eventId: string | null): void;
|
|
35
|
+
/** Called on componentWillUnmount() */
|
|
36
|
+
onUnmount?(error: Error | null, componentStack: string | null, eventId: string | null): void;
|
|
37
|
+
/** Called before the error is captured by Sentry, allows for you to add tags or context using the scope */
|
|
38
|
+
beforeCapture?(scope: Scope, error: Error | null, componentStack: string | null): void;
|
|
39
|
+
};
|
|
40
|
+
type ErrorBoundaryState = {
|
|
41
|
+
componentStack: null;
|
|
42
|
+
error: null;
|
|
43
|
+
eventId: null;
|
|
44
|
+
} | {
|
|
45
|
+
componentStack: React.ErrorInfo['componentStack'];
|
|
46
|
+
error: Error;
|
|
47
|
+
eventId: string;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* A ErrorBoundary component that logs errors to Sentry. Requires React >= 16.
|
|
51
|
+
* NOTE: If you are a Sentry user, and you are seeing this stack frame, it means the
|
|
52
|
+
* Sentry React SDK ErrorBoundary caught an error invoking your application code. This
|
|
53
|
+
* is expected behavior and NOT indicative of a bug with the Sentry React SDK.
|
|
54
|
+
*/
|
|
55
|
+
declare class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
56
|
+
state: ErrorBoundaryState;
|
|
57
|
+
private readonly _openFallbackReportDialog;
|
|
58
|
+
private _lastEventId?;
|
|
59
|
+
constructor(props: ErrorBoundaryProps);
|
|
60
|
+
componentDidCatch(error: Error & {
|
|
61
|
+
cause?: Error;
|
|
62
|
+
}, { componentStack }: React.ErrorInfo): void;
|
|
63
|
+
componentDidMount(): void;
|
|
64
|
+
componentWillUnmount(): void;
|
|
65
|
+
resetErrorBoundary: () => void;
|
|
66
|
+
render(): React.ReactNode;
|
|
67
|
+
}
|
|
68
|
+
declare function withErrorBoundary<P extends Record<string, any>>(WrappedComponent: React.ComponentType<P>, errorBoundaryOptions: ErrorBoundaryProps): React.FC<P>;
|
|
69
|
+
export { ErrorBoundary, withErrorBoundary };
|
|
70
|
+
//# sourceMappingURL=errorboundary.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from '@sentry/browser';
|
|
2
|
+
export { init } from './sdk';
|
|
3
|
+
export { Profiler, withProfiler, useProfiler } from './profiler';
|
|
4
|
+
export { ErrorBoundaryProps, FallbackRender } from './errorboundary';
|
|
5
|
+
export { ErrorBoundary, withErrorBoundary } from './errorboundary';
|
|
6
|
+
export { createReduxEnhancer } from './redux';
|
|
7
|
+
export { reactRouterV3Instrumentation } from './reactrouterv3';
|
|
8
|
+
export { reactRouterV4Instrumentation, reactRouterV5Instrumentation, withSentryRouting } from './reactrouter';
|
|
9
|
+
export { reactRouterV6Instrumentation, withSentryReactRouterV6Routing, wrapUseRoutes, wrapCreateBrowserRouter, } from './reactrouterv6';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Hub } from '@sentry/browser';
|
|
2
|
+
import { Span, Transaction } from '@sentry/types';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
export declare const UNKNOWN_COMPONENT = "unknown";
|
|
5
|
+
export type ProfilerProps = {
|
|
6
|
+
name: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
includeRender?: boolean;
|
|
9
|
+
includeUpdates?: boolean;
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
updateProps: {
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* The Profiler component leverages Sentry's Tracing integration to generate
|
|
17
|
+
* spans based on component lifecycles.
|
|
18
|
+
*/
|
|
19
|
+
declare class Profiler extends React.Component<ProfilerProps> {
|
|
20
|
+
/**
|
|
21
|
+
* The span of the mount activity
|
|
22
|
+
* Made protected for the React Native SDK to access
|
|
23
|
+
*/
|
|
24
|
+
protected _mountSpan: Span | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* The span that represents the duration of time between shouldComponentUpdate and componentDidUpdate
|
|
27
|
+
*/
|
|
28
|
+
protected _updateSpan: Span | undefined;
|
|
29
|
+
static defaultProps: Partial<ProfilerProps>;
|
|
30
|
+
constructor(props: ProfilerProps);
|
|
31
|
+
componentDidMount(): void;
|
|
32
|
+
shouldComponentUpdate({ updateProps, includeUpdates }: ProfilerProps): boolean;
|
|
33
|
+
componentDidUpdate(): void;
|
|
34
|
+
componentWillUnmount(): void;
|
|
35
|
+
render(): React.ReactNode;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* withProfiler is a higher order component that wraps a
|
|
39
|
+
* component in a {@link Profiler} component. It is recommended that
|
|
40
|
+
* the higher order component be used over the regular {@link Profiler} component.
|
|
41
|
+
*
|
|
42
|
+
* @param WrappedComponent component that is wrapped by Profiler
|
|
43
|
+
* @param options the {@link ProfilerProps} you can pass into the Profiler
|
|
44
|
+
*/
|
|
45
|
+
declare function withProfiler<P extends Record<string, any>>(WrappedComponent: React.ComponentType<P>, options?: Pick<Partial<ProfilerProps>, Exclude<keyof ProfilerProps, 'updateProps' | 'children'>>): React.FC<P>;
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
* `useProfiler` is a React hook that profiles a React component.
|
|
49
|
+
*
|
|
50
|
+
* Requires React 16.8 or above.
|
|
51
|
+
* @param name displayName of component being profiled
|
|
52
|
+
*/
|
|
53
|
+
declare function useProfiler(name: string, options?: {
|
|
54
|
+
disabled?: boolean;
|
|
55
|
+
hasRenderSpan?: boolean;
|
|
56
|
+
}): void;
|
|
57
|
+
export { withProfiler, Profiler, useProfiler };
|
|
58
|
+
/** Grabs active transaction off scope */
|
|
59
|
+
export declare function getActiveTransaction<T extends Transaction>(hub?: Hub): T | undefined;
|
|
60
|
+
//# sourceMappingURL=profiler.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Action, Location, ReactRouterInstrumentation } from './types';
|
|
3
|
+
type Match = {
|
|
4
|
+
path: string;
|
|
5
|
+
url: string;
|
|
6
|
+
params: Record<string, any>;
|
|
7
|
+
isExact: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type RouterHistory = {
|
|
10
|
+
location?: Location;
|
|
11
|
+
listen?(cb: (location: Location, action: Action) => void): void;
|
|
12
|
+
} & Record<string, any>;
|
|
13
|
+
export type RouteConfig = {
|
|
14
|
+
[propName: string]: unknown;
|
|
15
|
+
path?: string | string[];
|
|
16
|
+
exact?: boolean;
|
|
17
|
+
component?: JSX.Element;
|
|
18
|
+
routes?: RouteConfig[];
|
|
19
|
+
};
|
|
20
|
+
type MatchPath = (pathname: string, props: string | string[] | any, parent?: Match | null) => Match | null;
|
|
21
|
+
export declare function reactRouterV4Instrumentation(history: RouterHistory, routes?: RouteConfig[], matchPath?: MatchPath): ReactRouterInstrumentation;
|
|
22
|
+
export declare function reactRouterV5Instrumentation(history: RouterHistory, routes?: RouteConfig[], matchPath?: MatchPath): ReactRouterInstrumentation;
|
|
23
|
+
export declare function withSentryRouting<P extends Record<string, any>, R extends React.ComponentType<P>>(Route: R): R;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=reactrouter.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Location, ReactRouterInstrumentation } from './types';
|
|
2
|
+
type HistoryV3 = {
|
|
3
|
+
location?: Location;
|
|
4
|
+
listen?(cb: (location: Location) => void): void;
|
|
5
|
+
} & Record<string, any>;
|
|
6
|
+
export type Route = {
|
|
7
|
+
path?: string;
|
|
8
|
+
childRoutes?: Route[];
|
|
9
|
+
};
|
|
10
|
+
export type Match = (props: {
|
|
11
|
+
location: Location;
|
|
12
|
+
routes: Route[];
|
|
13
|
+
}, cb: (error?: Error, _redirectLocation?: Location, renderProps?: {
|
|
14
|
+
routes?: Route[];
|
|
15
|
+
}) => void) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Creates routing instrumentation for React Router v3
|
|
18
|
+
* Works for React Router >= 3.2.0 and < 4.0.0
|
|
19
|
+
*
|
|
20
|
+
* @param history object from the `history` library
|
|
21
|
+
* @param routes a list of all routes, should be
|
|
22
|
+
* @param match `Router.match` utility
|
|
23
|
+
*/
|
|
24
|
+
export declare function reactRouterV3Instrumentation(history: HistoryV3, routes: Route[], match: Match): ReactRouterInstrumentation;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=reactrouterv3.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Transaction, TransactionContext } from '@sentry/types';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { CreateRouterFunction, CreateRoutesFromChildren, MatchRoutes, Router, RouterState, UseEffect, UseLocation, UseNavigationType, UseRoutes } from './types';
|
|
4
|
+
export declare function reactRouterV6Instrumentation(useEffect: UseEffect, useLocation: UseLocation, useNavigationType: UseNavigationType, createRoutesFromChildren: CreateRoutesFromChildren, matchRoutes: MatchRoutes): (customStartTransaction: (context: TransactionContext) => Transaction | undefined, startTransactionOnPageLoad?: boolean, startTransactionOnLocationChange?: boolean) => void;
|
|
5
|
+
export declare function withSentryReactRouterV6Routing<P extends Record<string, any>, R extends React.FC<P>>(Routes: R): R;
|
|
6
|
+
export declare function wrapUseRoutes(origUseRoutes: UseRoutes): UseRoutes;
|
|
7
|
+
export declare function wrapCreateBrowserRouter<TState extends RouterState = RouterState, TRouter extends Router<TState> = Router<TState>>(createRouterFunction: CreateRouterFunction<TState, TRouter>): CreateRouterFunction<TState, TRouter>;
|
|
8
|
+
//# sourceMappingURL=reactrouterv6.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Scope } from '@sentry/types';
|
|
2
|
+
interface Action<T = any> {
|
|
3
|
+
type: T;
|
|
4
|
+
}
|
|
5
|
+
interface AnyAction extends Action {
|
|
6
|
+
[extraProps: string]: any;
|
|
7
|
+
}
|
|
8
|
+
export interface SentryEnhancerOptions<S = any> {
|
|
9
|
+
/**
|
|
10
|
+
* Redux state in attachments or not.
|
|
11
|
+
* @default true
|
|
12
|
+
*/
|
|
13
|
+
attachReduxState?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Transforms the state before attaching it to an event.
|
|
16
|
+
* Use this to remove any private data before sending it to Sentry.
|
|
17
|
+
* Return null to not attach the state.
|
|
18
|
+
*/
|
|
19
|
+
stateTransformer(state: S | undefined): (S & any) | null;
|
|
20
|
+
/**
|
|
21
|
+
* Transforms the action before sending it as a breadcrumb.
|
|
22
|
+
* Use this to remove any private data before sending it to Sentry.
|
|
23
|
+
* Return null to not send the breadcrumb.
|
|
24
|
+
*/
|
|
25
|
+
actionTransformer(action: AnyAction): AnyAction | null;
|
|
26
|
+
/**
|
|
27
|
+
* Called on every state update, configure the Sentry Scope with the redux state.
|
|
28
|
+
*/
|
|
29
|
+
configureScopeWithState?(scope: Scope, state: S): void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Creates an enhancer that would be passed to Redux's createStore to log actions and the latest state to Sentry.
|
|
33
|
+
*
|
|
34
|
+
* @param enhancerOptions Options to pass to the enhancer
|
|
35
|
+
*/
|
|
36
|
+
declare function createReduxEnhancer(enhancerOptions?: Partial<SentryEnhancerOptions>): any;
|
|
37
|
+
export { createReduxEnhancer };
|
|
38
|
+
//# sourceMappingURL=redux.d.ts.map
|