@sentry/react 8.9.2 → 8.10.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/reactrouter.js +5 -5
- package/cjs/reactrouter.js.map +1 -1
- package/cjs/reactrouterv3.js +1 -0
- package/cjs/reactrouterv3.js.map +1 -1
- package/cjs/reactrouterv6.js +1 -3
- package/cjs/reactrouterv6.js.map +1 -1
- package/cjs/sdk.js +2 -1
- package/cjs/sdk.js.map +1 -1
- package/cjs/tanstackrouter.js +3 -3
- package/cjs/tanstackrouter.js.map +1 -1
- package/esm/reactrouter.js +5 -5
- package/esm/reactrouter.js.map +1 -1
- package/esm/reactrouterv3.js +1 -0
- package/esm/reactrouterv3.js.map +1 -1
- package/esm/reactrouterv6.js +1 -3
- package/esm/reactrouterv6.js.map +1 -1
- package/esm/sdk.js +3 -2
- package/esm/sdk.js.map +1 -1
- package/esm/tanstackrouter.js +3 -3
- package/esm/tanstackrouter.js.map +1 -1
- package/package.json +5 -5
- package/types/reactrouterv6.d.ts.map +1 -1
- package/types/sdk.d.ts.map +1 -1
package/cjs/reactrouter.js
CHANGED
|
@@ -112,10 +112,9 @@ function instrumentReactRouter(
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
const branches = matchRoutes(allRoutes, pathname, matchPath);
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
return [branches[x].match.path, 'route'];
|
|
115
|
+
for (const branch of branches) {
|
|
116
|
+
if (branch.match.isExact) {
|
|
117
|
+
return [branch.match.path, 'route'];
|
|
119
118
|
}
|
|
120
119
|
}
|
|
121
120
|
|
|
@@ -168,7 +167,8 @@ function matchRoutes(
|
|
|
168
167
|
const match = route.path
|
|
169
168
|
? matchPath(pathname, route)
|
|
170
169
|
: branch.length
|
|
171
|
-
?
|
|
170
|
+
? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
171
|
+
branch[branch.length - 1].match // use parent match
|
|
172
172
|
: computeRootMatch(pathname); // use default "root" match
|
|
173
173
|
|
|
174
174
|
if (match) {
|
package/cjs/reactrouter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactrouter.js","sources":["../../src/reactrouter.tsx"],"sourcesContent":["import {\n WINDOW,\n browserTracingIntegration,\n startBrowserTracingNavigationSpan,\n startBrowserTracingPageLoadSpan,\n} from '@sentry/browser';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n getActiveSpan,\n getCurrentScope,\n getRootSpan,\n spanToJSON,\n} from '@sentry/core';\nimport type { Client, Integration, Span, TransactionSource } from '@sentry/types';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\n\nimport type { Action, Location } from './types';\n\n// We need to disable eslint no-explict-any because any is required for the\n// react-router typings.\ntype Match = { path: string; url: string; params: Record<string, any>; isExact: boolean }; // eslint-disable-line @typescript-eslint/no-explicit-any\n\nexport type RouterHistory = {\n location?: Location;\n listen?(cb: (location: Location, action: Action) => void): void;\n} & Record<string, any>; // eslint-disable-line @typescript-eslint/no-explicit-any\n\nexport type RouteConfig = {\n [propName: string]: unknown;\n path?: string | string[];\n exact?: boolean;\n component?: JSX.Element;\n routes?: RouteConfig[];\n};\n\nexport type MatchPath = (pathname: string, props: string | string[] | any, parent?: Match | null) => Match | null; // eslint-disable-line @typescript-eslint/no-explicit-any\n\ninterface ReactRouterOptions {\n history: RouterHistory;\n routes?: RouteConfig[];\n matchPath?: MatchPath;\n}\n\n/**\n * A browser tracing integration that uses React Router v4 to instrument navigations.\n * Expects `history` (and optionally `routes` and `matchPath`) to be passed as options.\n */\nexport function reactRouterV4BrowserTracingIntegration(\n options: Parameters<typeof browserTracingIntegration>[0] & ReactRouterOptions,\n): Integration {\n const integration = browserTracingIntegration({\n ...options,\n instrumentPageLoad: false,\n instrumentNavigation: false,\n });\n\n const { history, routes, matchPath, instrumentPageLoad = true, instrumentNavigation = true } = options;\n\n return {\n ...integration,\n afterAllSetup(client) {\n integration.afterAllSetup(client);\n\n instrumentReactRouter(\n client,\n instrumentPageLoad,\n instrumentNavigation,\n history,\n 'reactrouter_v4',\n routes,\n matchPath,\n );\n },\n };\n}\n\n/**\n * A browser tracing integration that uses React Router v5 to instrument navigations.\n * Expects `history` (and optionally `routes` and `matchPath`) to be passed as options.\n */\nexport function reactRouterV5BrowserTracingIntegration(\n options: Parameters<typeof browserTracingIntegration>[0] & ReactRouterOptions,\n): Integration {\n const integration = browserTracingIntegration({\n ...options,\n instrumentPageLoad: false,\n instrumentNavigation: false,\n });\n\n const { history, routes, matchPath, instrumentPageLoad = true, instrumentNavigation = true } = options;\n\n return {\n ...integration,\n afterAllSetup(client) {\n integration.afterAllSetup(client);\n\n instrumentReactRouter(\n client,\n instrumentPageLoad,\n instrumentNavigation,\n history,\n 'reactrouter_v5',\n routes,\n matchPath,\n );\n },\n };\n}\n\nfunction instrumentReactRouter(\n client: Client,\n instrumentPageLoad: boolean,\n instrumentNavigation: boolean,\n history: RouterHistory,\n instrumentationName: string,\n allRoutes: RouteConfig[] = [],\n matchPath?: MatchPath,\n): void {\n function getInitPathName(): string | undefined {\n if (history && history.location) {\n return history.location.pathname;\n }\n\n if (WINDOW && WINDOW.location) {\n return WINDOW.location.pathname;\n }\n\n return undefined;\n }\n\n /**\n * Normalizes a transaction name. Returns the new name as well as the\n * source of the transaction.\n *\n * @param pathname The initial pathname we normalize\n */\n function normalizeTransactionName(pathname: string): [string, TransactionSource] {\n if (allRoutes.length === 0 || !matchPath) {\n return [pathname, 'url'];\n }\n\n const branches = matchRoutes(allRoutes, pathname, matchPath);\n // eslint-disable-next-line @typescript-eslint/prefer-for-of\n for (let x = 0; x < branches.length; x++) {\n if (branches[x].match.isExact) {\n return [branches[x].match.path, 'route'];\n }\n }\n\n return [pathname, 'url'];\n }\n\n if (instrumentPageLoad) {\n const initPathName = getInitPathName();\n if (initPathName) {\n const [name, source] = normalizeTransactionName(initPathName);\n startBrowserTracingPageLoadSpan(client, {\n name,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'pageload',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: `auto.pageload.react.${instrumentationName}`,\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,\n },\n });\n }\n }\n\n if (instrumentNavigation && history.listen) {\n history.listen((location, action) => {\n if (action && (action === 'PUSH' || action === 'POP')) {\n const [name, source] = normalizeTransactionName(location.pathname);\n startBrowserTracingNavigationSpan(client, {\n name,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: `auto.navigation.react.${instrumentationName}`,\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,\n },\n });\n }\n });\n }\n}\n\n/**\n * Matches a set of routes to a pathname\n * Based on implementation from\n */\nfunction matchRoutes(\n routes: RouteConfig[],\n pathname: string,\n matchPath: MatchPath,\n branch: Array<{ route: RouteConfig; match: Match }> = [],\n): Array<{ route: RouteConfig; match: Match }> {\n routes.some(route => {\n const match = route.path\n ? matchPath(pathname, route)\n : branch.length\n ? branch[branch.length - 1].match // use parent match\n : computeRootMatch(pathname); // use default \"root\" match\n\n if (match) {\n branch.push({ route, match });\n\n if (route.routes) {\n matchRoutes(route.routes, pathname, matchPath, branch);\n }\n }\n\n return !!match;\n });\n\n return branch;\n}\n\nfunction computeRootMatch(pathname: string): Match {\n return { path: '/', url: '/', params: {}, isExact: pathname === '/' };\n}\n\n/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */\nexport function withSentryRouting<P extends Record<string, any>, R extends React.ComponentType<P>>(Route: R): R {\n const componentDisplayName = (Route as any).displayName || (Route as any).name;\n\n const WrappedRoute: React.FC<P> = (props: P) => {\n if (props && props.computedMatch && props.computedMatch.isExact) {\n const route = props.computedMatch.path;\n const activeRootSpan = getActiveRootSpan();\n\n getCurrentScope().setTransactionName(route);\n\n if (activeRootSpan) {\n activeRootSpan.updateName(route);\n activeRootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'route');\n }\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 // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/13dc4235c069e25fe7ee16e11f529d909f9f3ff8/types/react-router/index.d.ts#L154-L164\n return <Route {...props} />;\n };\n\n WrappedRoute.displayName = `sentryRoute(${componentDisplayName})`;\n hoistNonReactStatics(WrappedRoute, Route);\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 // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/13dc4235c069e25fe7ee16e11f529d909f9f3ff8/types/react-router/index.d.ts#L154-L164\n return WrappedRoute;\n}\n/* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */\n\nfunction getActiveRootSpan(): Span | undefined {\n const span = getActiveSpan();\n const rootSpan = span && getRootSpan(span);\n\n if (!rootSpan) {\n return undefined;\n }\n\n const op = spanToJSON(rootSpan).op;\n\n // Only use this root span if it is a pageload or navigation span\n return op === 'navigation' || op === 'pageload' ? rootSpan : undefined;\n}\n"],"names":["browserTracingIntegration","WINDOW","startBrowserTracingPageLoadSpan","SEMANTIC_ATTRIBUTE_SENTRY_OP","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","startBrowserTracingNavigationSpan","getCurrentScope","_jsx","hoistNonReactStatics","getActiveSpan","getRootSpan","spanToJSON"],"mappings":";;;;;;;;;;;;AAqBA;AACA;;AAwBA;AACA;AACA;AACA;AACO,SAAS,sCAAsC;AACtD,EAAE,OAAO;AACT,EAAe;AACf,EAAE,MAAM,WAAA,GAAcA,iCAAyB,CAAC;AAChD,IAAI,GAAG,OAA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A,CAAA,IAAA,CAAA;AACA,MAAA,MAAA,cAAA,GAAA,iBAAA,EAAA,CAAA;AACA;AACA,MAAAE,oBAAA,EAAA,CAAA,kBAAA,CAAA,KAAA,CAAA,CAAA;AACA;AACA,MAAA,IAAA,cAAA,EAAA;AACA,QAAA,cAAA,CAAA,UAAA,CAAA,KAAA,CAAA,CAAA;AACA,QAAA,cAAA,CAAA,YAAA,CAAAF,qCAAA,EAAA,OAAA,CAAA,CAAA;AACA,OAAA;AACA,KAAA;AACA;AACA;AACA;AACA;AACA,IAAA,OAAAG,cAAA,CAAA,KAAA,EAAA,EAAA,GAAA,KAAA,EAAA,EAAA,CAAA;AACA,GAAA,CAAA;AACA;AACA,EAAA,YAAA,CAAA,WAAA,GAAA,CAAA,YAAA,EAAA,oBAAA,CAAA,CAAA,CAAA,CAAA;AACA,EAAAC,6BAAA,CAAA,YAAA,EAAA,KAAA,CAAA,CAAA;AACA;AACA;AACA;AACA,EAAA,OAAA,YAAA,CAAA;AACA,CAAA;AACA;AACA;AACA,SAAA,iBAAA,GAAA;AACA,EAAA,MAAA,IAAA,GAAAC,kBAAA,EAAA,CAAA;AACA,EAAA,MAAA,QAAA,GAAA,IAAA,IAAAC,gBAAA,CAAA,IAAA,CAAA,CAAA;AACA;AACA,EAAA,IAAA,CAAA,QAAA,EAAA;AACA,IAAA,OAAA,SAAA,CAAA;AACA,GAAA;AACA;AACA,EAAA,MAAA,EAAA,GAAAC,eAAA,CAAA,QAAA,CAAA,CAAA,EAAA,CAAA;AACA;AACA;AACA,EAAA,OAAA,EAAA,KAAA,YAAA,IAAA,EAAA,KAAA,UAAA,GAAA,QAAA,GAAA,SAAA,CAAA;AACA;;;;;;"}
|
|
1
|
+
{"version":3,"file":"reactrouter.js","sources":["../../src/reactrouter.tsx"],"sourcesContent":["import {\n WINDOW,\n browserTracingIntegration,\n startBrowserTracingNavigationSpan,\n startBrowserTracingPageLoadSpan,\n} from '@sentry/browser';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n getActiveSpan,\n getCurrentScope,\n getRootSpan,\n spanToJSON,\n} from '@sentry/core';\nimport type { Client, Integration, Span, TransactionSource } from '@sentry/types';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\n\nimport type { Action, Location } from './types';\n\n// We need to disable eslint no-explict-any because any is required for the\n// react-router typings.\ntype Match = { path: string; url: string; params: Record<string, any>; isExact: boolean }; // eslint-disable-line @typescript-eslint/no-explicit-any\n\nexport type RouterHistory = {\n location?: Location;\n listen?(cb: (location: Location, action: Action) => void): void;\n} & Record<string, any>; // eslint-disable-line @typescript-eslint/no-explicit-any\n\nexport type RouteConfig = {\n [propName: string]: unknown;\n path?: string | string[];\n exact?: boolean;\n component?: JSX.Element;\n routes?: RouteConfig[];\n};\n\nexport type MatchPath = (pathname: string, props: string | string[] | any, parent?: Match | null) => Match | null; // eslint-disable-line @typescript-eslint/no-explicit-any\n\ninterface ReactRouterOptions {\n history: RouterHistory;\n routes?: RouteConfig[];\n matchPath?: MatchPath;\n}\n\n/**\n * A browser tracing integration that uses React Router v4 to instrument navigations.\n * Expects `history` (and optionally `routes` and `matchPath`) to be passed as options.\n */\nexport function reactRouterV4BrowserTracingIntegration(\n options: Parameters<typeof browserTracingIntegration>[0] & ReactRouterOptions,\n): Integration {\n const integration = browserTracingIntegration({\n ...options,\n instrumentPageLoad: false,\n instrumentNavigation: false,\n });\n\n const { history, routes, matchPath, instrumentPageLoad = true, instrumentNavigation = true } = options;\n\n return {\n ...integration,\n afterAllSetup(client) {\n integration.afterAllSetup(client);\n\n instrumentReactRouter(\n client,\n instrumentPageLoad,\n instrumentNavigation,\n history,\n 'reactrouter_v4',\n routes,\n matchPath,\n );\n },\n };\n}\n\n/**\n * A browser tracing integration that uses React Router v5 to instrument navigations.\n * Expects `history` (and optionally `routes` and `matchPath`) to be passed as options.\n */\nexport function reactRouterV5BrowserTracingIntegration(\n options: Parameters<typeof browserTracingIntegration>[0] & ReactRouterOptions,\n): Integration {\n const integration = browserTracingIntegration({\n ...options,\n instrumentPageLoad: false,\n instrumentNavigation: false,\n });\n\n const { history, routes, matchPath, instrumentPageLoad = true, instrumentNavigation = true } = options;\n\n return {\n ...integration,\n afterAllSetup(client) {\n integration.afterAllSetup(client);\n\n instrumentReactRouter(\n client,\n instrumentPageLoad,\n instrumentNavigation,\n history,\n 'reactrouter_v5',\n routes,\n matchPath,\n );\n },\n };\n}\n\nfunction instrumentReactRouter(\n client: Client,\n instrumentPageLoad: boolean,\n instrumentNavigation: boolean,\n history: RouterHistory,\n instrumentationName: string,\n allRoutes: RouteConfig[] = [],\n matchPath?: MatchPath,\n): void {\n function getInitPathName(): string | undefined {\n if (history && history.location) {\n return history.location.pathname;\n }\n\n if (WINDOW && WINDOW.location) {\n return WINDOW.location.pathname;\n }\n\n return undefined;\n }\n\n /**\n * Normalizes a transaction name. Returns the new name as well as the\n * source of the transaction.\n *\n * @param pathname The initial pathname we normalize\n */\n function normalizeTransactionName(pathname: string): [string, TransactionSource] {\n if (allRoutes.length === 0 || !matchPath) {\n return [pathname, 'url'];\n }\n\n const branches = matchRoutes(allRoutes, pathname, matchPath);\n for (const branch of branches) {\n if (branch.match.isExact) {\n return [branch.match.path, 'route'];\n }\n }\n\n return [pathname, 'url'];\n }\n\n if (instrumentPageLoad) {\n const initPathName = getInitPathName();\n if (initPathName) {\n const [name, source] = normalizeTransactionName(initPathName);\n startBrowserTracingPageLoadSpan(client, {\n name,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'pageload',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: `auto.pageload.react.${instrumentationName}`,\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,\n },\n });\n }\n }\n\n if (instrumentNavigation && history.listen) {\n history.listen((location, action) => {\n if (action && (action === 'PUSH' || action === 'POP')) {\n const [name, source] = normalizeTransactionName(location.pathname);\n startBrowserTracingNavigationSpan(client, {\n name,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: `auto.navigation.react.${instrumentationName}`,\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,\n },\n });\n }\n });\n }\n}\n\n/**\n * Matches a set of routes to a pathname\n * Based on implementation from\n */\nfunction matchRoutes(\n routes: RouteConfig[],\n pathname: string,\n matchPath: MatchPath,\n branch: Array<{ route: RouteConfig; match: Match }> = [],\n): Array<{ route: RouteConfig; match: Match }> {\n routes.some(route => {\n const match = route.path\n ? matchPath(pathname, route)\n : branch.length\n ? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n branch[branch.length - 1]!.match // use parent match\n : computeRootMatch(pathname); // use default \"root\" match\n\n if (match) {\n branch.push({ route, match });\n\n if (route.routes) {\n matchRoutes(route.routes, pathname, matchPath, branch);\n }\n }\n\n return !!match;\n });\n\n return branch;\n}\n\nfunction computeRootMatch(pathname: string): Match {\n return { path: '/', url: '/', params: {}, isExact: pathname === '/' };\n}\n\n/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */\nexport function withSentryRouting<P extends Record<string, any>, R extends React.ComponentType<P>>(Route: R): R {\n const componentDisplayName = (Route as any).displayName || (Route as any).name;\n\n const WrappedRoute: React.FC<P> = (props: P) => {\n if (props && props.computedMatch && props.computedMatch.isExact) {\n const route = props.computedMatch.path;\n const activeRootSpan = getActiveRootSpan();\n\n getCurrentScope().setTransactionName(route);\n\n if (activeRootSpan) {\n activeRootSpan.updateName(route);\n activeRootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'route');\n }\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 // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/13dc4235c069e25fe7ee16e11f529d909f9f3ff8/types/react-router/index.d.ts#L154-L164\n return <Route {...props} />;\n };\n\n WrappedRoute.displayName = `sentryRoute(${componentDisplayName})`;\n hoistNonReactStatics(WrappedRoute, Route);\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 // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/13dc4235c069e25fe7ee16e11f529d909f9f3ff8/types/react-router/index.d.ts#L154-L164\n return WrappedRoute;\n}\n/* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */\n\nfunction getActiveRootSpan(): Span | undefined {\n const span = getActiveSpan();\n const rootSpan = span && getRootSpan(span);\n\n if (!rootSpan) {\n return undefined;\n }\n\n const op = spanToJSON(rootSpan).op;\n\n // Only use this root span if it is a pageload or navigation span\n return op === 'navigation' || op === 'pageload' ? rootSpan : undefined;\n}\n"],"names":["browserTracingIntegration","WINDOW","startBrowserTracingPageLoadSpan","SEMANTIC_ATTRIBUTE_SENTRY_OP","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","startBrowserTracingNavigationSpan","getCurrentScope","_jsx","hoistNonReactStatics","getActiveSpan","getRootSpan","spanToJSON"],"mappings":";;;;;;;;;;;;AAqBA;AACA;;AAwBA;AACA;AACA;AACA;AACO,SAAS,sCAAsC;AACtD,EAAE,OAAO;AACT,EAAe;AACf,EAAE,MAAM,WAAA,GAAcA,iCAAyB,CAAC;AAChD,IAAI,GAAG,OAAO;AACd,IAAI,kBAAkB,EAAE,KAAK;AAC7B,IAAI,oBAAoB,EAAE,KAAK;AAC/B,GAAG,CAAC,CAAA;AACJ;AACA,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,kBAAmB,GAAE,IAAI,EAAE,oBAAA,GAAuB,IAAK,EAAA,GAAI,OAAO,CAAA;AACxG;AACA,EAAE,OAAO;AACT,IAAI,GAAG,WAAW;AAClB,IAAI,aAAa,CAA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A,EAAA,EAAA,CAAA;AACA,GAAA,CAAA;AACA;AACA,EAAA,YAAA,CAAA,WAAA,GAAA,CAAA,YAAA,EAAA,oBAAA,CAAA,CAAA,CAAA,CAAA;AACA,EAAAC,6BAAA,CAAA,YAAA,EAAA,KAAA,CAAA,CAAA;AACA;AACA;AACA;AACA,EAAA,OAAA,YAAA,CAAA;AACA,CAAA;AACA;AACA;AACA,SAAA,iBAAA,GAAA;AACA,EAAA,MAAA,IAAA,GAAAC,kBAAA,EAAA,CAAA;AACA,EAAA,MAAA,QAAA,GAAA,IAAA,IAAAC,gBAAA,CAAA,IAAA,CAAA,CAAA;AACA;AACA,EAAA,IAAA,CAAA,QAAA,EAAA;AACA,IAAA,OAAA,SAAA,CAAA;AACA,GAAA;AACA;AACA,EAAA,MAAA,EAAA,GAAAC,eAAA,CAAA,QAAA,CAAA,CAAA,EAAA,CAAA;AACA;AACA;AACA,EAAA,OAAA,EAAA,KAAA,YAAA,IAAA,EAAA,KAAA,UAAA,GAAA,QAAA,GAAA,SAAA,CAAA;AACA;;;;;;"}
|
package/cjs/reactrouterv3.js
CHANGED
|
@@ -112,6 +112,7 @@ function getRouteStringFromRoutes(routes) {
|
|
|
112
112
|
|
|
113
113
|
let index = -1;
|
|
114
114
|
for (let x = routesWithPaths.length - 1; x >= 0; x--) {
|
|
115
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
115
116
|
const route = routesWithPaths[x];
|
|
116
117
|
if (route.path && route.path.startsWith('/')) {
|
|
117
118
|
index = x;
|
package/cjs/reactrouterv3.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactrouterv3.js","sources":["../../src/reactrouterv3.ts"],"sourcesContent":["import {\n WINDOW,\n browserTracingIntegration,\n startBrowserTracingNavigationSpan,\n startBrowserTracingPageLoadSpan,\n} from '@sentry/browser';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n} from '@sentry/core';\nimport type { Integration, TransactionSource } from '@sentry/types';\n\nimport type { Location } from './types';\n\n// Many of the types below had to be mocked out to prevent typescript issues\n// these types are required for correct functionality.\n\ntype HistoryV3 = {\n location?: Location;\n listen?(cb: (location: Location) => void): void;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n} & Record<string, any>;\n\nexport type Route = { path?: string; childRoutes?: Route[] };\n\nexport type Match = (\n props: { location: Location; routes: Route[] },\n cb: (error?: Error, _redirectLocation?: Location, renderProps?: { routes?: Route[] }) => void,\n) => void;\n\ntype ReactRouterV3TransactionSource = Extract<TransactionSource, 'url' | 'route'>;\n\ninterface ReactRouterOptions {\n history: HistoryV3;\n routes: Route[];\n match: Match;\n}\n\n/**\n * A browser tracing integration that uses React Router v3 to instrument navigations.\n * Expects `history` (and optionally `routes` and `matchPath`) to be passed as options.\n */\nexport function reactRouterV3BrowserTracingIntegration(\n options: Parameters<typeof browserTracingIntegration>[0] & ReactRouterOptions,\n): Integration {\n const integration = browserTracingIntegration({\n ...options,\n instrumentPageLoad: false,\n instrumentNavigation: false,\n });\n\n const { history, routes, match, instrumentPageLoad = true, instrumentNavigation = true } = options;\n\n return {\n ...integration,\n afterAllSetup(client) {\n integration.afterAllSetup(client);\n\n if (instrumentPageLoad && WINDOW && WINDOW.location) {\n normalizeTransactionName(\n routes,\n WINDOW.location as unknown as Location,\n match,\n (localName: string, source: ReactRouterV3TransactionSource = 'url') => {\n startBrowserTracingPageLoadSpan(client, {\n name: localName,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'pageload',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.pageload.react.reactrouter_v3',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,\n },\n });\n },\n );\n }\n\n if (instrumentNavigation && history.listen) {\n history.listen(location => {\n if (location.action === 'PUSH' || location.action === 'POP') {\n normalizeTransactionName(\n routes,\n location,\n match,\n (localName: string, source: TransactionSource = 'url') => {\n startBrowserTracingNavigationSpan(client, {\n name: localName,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.react.reactrouter_v3',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,\n },\n });\n },\n );\n }\n });\n }\n },\n };\n}\n\n/**\n * Normalize transaction names using `Router.match`\n */\nfunction normalizeTransactionName(\n appRoutes: Route[],\n location: Location,\n match: Match,\n callback: (pathname: string, source?: ReactRouterV3TransactionSource) => void,\n): void {\n let name = location.pathname;\n match(\n {\n location,\n routes: appRoutes,\n },\n (error, _redirectLocation, renderProps) => {\n if (error || !renderProps) {\n return callback(name);\n }\n\n const routePath = getRouteStringFromRoutes(renderProps.routes || []);\n if (routePath.length === 0 || routePath === '/*') {\n return callback(name);\n }\n\n name = routePath;\n return callback(name, 'route');\n },\n );\n}\n\n/**\n * Generate route name from array of routes\n */\nfunction getRouteStringFromRoutes(routes: Route[]): string {\n if (!Array.isArray(routes) || routes.length === 0) {\n return '';\n }\n\n const routesWithPaths: Route[] = routes.filter((route: Route) => !!route.path);\n\n let index = -1;\n for (let x = routesWithPaths.length - 1; x >= 0; x--) {\n const route = routesWithPaths[x]
|
|
1
|
+
{"version":3,"file":"reactrouterv3.js","sources":["../../src/reactrouterv3.ts"],"sourcesContent":["import {\n WINDOW,\n browserTracingIntegration,\n startBrowserTracingNavigationSpan,\n startBrowserTracingPageLoadSpan,\n} from '@sentry/browser';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n} from '@sentry/core';\nimport type { Integration, TransactionSource } from '@sentry/types';\n\nimport type { Location } from './types';\n\n// Many of the types below had to be mocked out to prevent typescript issues\n// these types are required for correct functionality.\n\ntype HistoryV3 = {\n location?: Location;\n listen?(cb: (location: Location) => void): void;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n} & Record<string, any>;\n\nexport type Route = { path?: string; childRoutes?: Route[] };\n\nexport type Match = (\n props: { location: Location; routes: Route[] },\n cb: (error?: Error, _redirectLocation?: Location, renderProps?: { routes?: Route[] }) => void,\n) => void;\n\ntype ReactRouterV3TransactionSource = Extract<TransactionSource, 'url' | 'route'>;\n\ninterface ReactRouterOptions {\n history: HistoryV3;\n routes: Route[];\n match: Match;\n}\n\n/**\n * A browser tracing integration that uses React Router v3 to instrument navigations.\n * Expects `history` (and optionally `routes` and `matchPath`) to be passed as options.\n */\nexport function reactRouterV3BrowserTracingIntegration(\n options: Parameters<typeof browserTracingIntegration>[0] & ReactRouterOptions,\n): Integration {\n const integration = browserTracingIntegration({\n ...options,\n instrumentPageLoad: false,\n instrumentNavigation: false,\n });\n\n const { history, routes, match, instrumentPageLoad = true, instrumentNavigation = true } = options;\n\n return {\n ...integration,\n afterAllSetup(client) {\n integration.afterAllSetup(client);\n\n if (instrumentPageLoad && WINDOW && WINDOW.location) {\n normalizeTransactionName(\n routes,\n WINDOW.location as unknown as Location,\n match,\n (localName: string, source: ReactRouterV3TransactionSource = 'url') => {\n startBrowserTracingPageLoadSpan(client, {\n name: localName,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'pageload',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.pageload.react.reactrouter_v3',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,\n },\n });\n },\n );\n }\n\n if (instrumentNavigation && history.listen) {\n history.listen(location => {\n if (location.action === 'PUSH' || location.action === 'POP') {\n normalizeTransactionName(\n routes,\n location,\n match,\n (localName: string, source: TransactionSource = 'url') => {\n startBrowserTracingNavigationSpan(client, {\n name: localName,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.react.reactrouter_v3',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,\n },\n });\n },\n );\n }\n });\n }\n },\n };\n}\n\n/**\n * Normalize transaction names using `Router.match`\n */\nfunction normalizeTransactionName(\n appRoutes: Route[],\n location: Location,\n match: Match,\n callback: (pathname: string, source?: ReactRouterV3TransactionSource) => void,\n): void {\n let name = location.pathname;\n match(\n {\n location,\n routes: appRoutes,\n },\n (error, _redirectLocation, renderProps) => {\n if (error || !renderProps) {\n return callback(name);\n }\n\n const routePath = getRouteStringFromRoutes(renderProps.routes || []);\n if (routePath.length === 0 || routePath === '/*') {\n return callback(name);\n }\n\n name = routePath;\n return callback(name, 'route');\n },\n );\n}\n\n/**\n * Generate route name from array of routes\n */\nfunction getRouteStringFromRoutes(routes: Route[]): string {\n if (!Array.isArray(routes) || routes.length === 0) {\n return '';\n }\n\n const routesWithPaths: Route[] = routes.filter((route: Route) => !!route.path);\n\n let index = -1;\n for (let x = routesWithPaths.length - 1; x >= 0; x--) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const route = routesWithPaths[x]!;\n if (route.path && route.path.startsWith('/')) {\n index = x;\n break;\n }\n }\n\n return routesWithPaths\n .slice(index)\n .filter(({ path }) => !!path)\n .map(({ path }) => path)\n .join('');\n}\n"],"names":["browserTracingIntegration","WINDOW","startBrowserTracingPageLoadSpan","SEMANTIC_ATTRIBUTE_SENTRY_OP","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","startBrowserTracingNavigationSpan"],"mappings":";;;;;AAeA;AACA;;AAuBA;AACA;AACA;AACA;AACO,SAAS,sCAAsC;AACtD,EAAE,OAAO;AACT,EAAe;AACf,EAAE,MAAM,WAAA,GAAcA,iCAAyB,CAAC;AAChD,IAAI,GAAG,OAAO;AACd,IAAI,kBAAkB,EAAE,KAAK;AAC7B,IAAI,oBAAoB,EAAE,KAAK;AAC/B,GAAG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,KAAI,CAAC,EAAE;AACrD,IAAI,OAAO,EAAE,CAAA;AACb,GAAE;AACF;AACA,EAAE,MAAM,eAAe,GAAY,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,KAAY,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;AAChF;AACA,EAAE,IAAI,KAAA,GAAQ,CAAC,CAAC,CAAA;AAChB,EAAE,KAAK,IAAI,CAAE,GAAE,eAAe,CAAC,MAAA,GAAS,CAAC,EAAE,CAAE,IAAG,CAAC,EAAE,CAAC,EAAE,EAAE;AACxD;AACA,IAAI,MAAM,KAAM,GAAE,eAAe,CAAC,CAAC,CAAC,CAAA;AACpC,IAAI,IAAI,KAAK,CAAC,QAAQ,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;AAClD,MAAM,KAAA,GAAQ,CAAC,CAAA;AACf,MAAM,MAAK;AACX,KAAI;AACJ,GAAE;AACF;AACA,EAAE,OAAO,eAAA;AACT,KAAK,KAAK,CAAC,KAAK,CAAA;AAChB,KAAK,MAAM,CAAC,CAAC,EAAE,IAAK,EAAC,KAAK,CAAC,CAAC,IAAI,CAAA;AAChC,KAAK,GAAG,CAAC,CAAC,EAAE,IAAK,EAAC,KAAK,IAAI,CAAA;AAC3B,KAAK,IAAI,CAAC,EAAE,CAAC,CAAA;AACb;;;;"}
|
package/cjs/reactrouterv6.js
CHANGED
|
@@ -116,9 +116,7 @@ function getNormalizedName(
|
|
|
116
116
|
|
|
117
117
|
let pathBuilder = '';
|
|
118
118
|
if (branches) {
|
|
119
|
-
|
|
120
|
-
for (let x = 0; x < branches.length; x++) {
|
|
121
|
-
const branch = branches[x];
|
|
119
|
+
for (const branch of branches) {
|
|
122
120
|
const route = branch.route;
|
|
123
121
|
if (route) {
|
|
124
122
|
// Early return if index route
|
package/cjs/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 {\n WINDOW,\n browserTracingIntegration,\n startBrowserTracingNavigationSpan,\n startBrowserTracingPageLoadSpan,\n} from '@sentry/browser';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n getActiveSpan,\n getClient,\n getCurrentScope,\n getRootSpan,\n spanToJSON,\n} from '@sentry/core';\nimport type { Client, Integration, Span, TransactionSource } from '@sentry/types';\nimport { getNumberOfUrlSegments, logger } from '@sentry/utils';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\n\nimport { DEBUG_BUILD } from './debug-build';\nimport type {\n Action,\n AgnosticDataRouteMatch,\n CreateRouterFunction,\n CreateRoutesFromChildren,\n Location,\n MatchRoutes,\n RouteMatch,\n RouteObject,\n Router,\n RouterState,\n UseEffect,\n UseLocation,\n UseNavigationType,\n UseRoutes,\n} from './types';\n\nlet _useEffect: UseEffect;\nlet _useLocation: UseLocation;\nlet _useNavigationType: UseNavigationType;\nlet _createRoutesFromChildren: CreateRoutesFromChildren;\nlet _matchRoutes: MatchRoutes;\nlet _stripBasename: boolean = false;\n\nconst CLIENTS_WITH_INSTRUMENT_NAVIGATION = new WeakSet<Client>();\n\ninterface ReactRouterOptions {\n useEffect: UseEffect;\n useLocation: UseLocation;\n useNavigationType: UseNavigationType;\n createRoutesFromChildren: CreateRoutesFromChildren;\n matchRoutes: MatchRoutes;\n stripBasename?: boolean;\n}\n\n/**\n * A browser tracing integration that uses React Router v6 to instrument navigations.\n * Expects `useEffect`, `useLocation`, `useNavigationType`, `createRoutesFromChildren` and `matchRoutes` to be passed as options.\n */\nexport function reactRouterV6BrowserTracingIntegration(\n options: Parameters<typeof browserTracingIntegration>[0] & ReactRouterOptions,\n): Integration {\n const integration = browserTracingIntegration({\n ...options,\n instrumentPageLoad: false,\n instrumentNavigation: false,\n });\n\n const {\n useEffect,\n useLocation,\n useNavigationType,\n createRoutesFromChildren,\n matchRoutes,\n stripBasename,\n instrumentPageLoad = true,\n instrumentNavigation = true,\n } = options;\n\n return {\n ...integration,\n setup() {\n _useEffect = useEffect;\n _useLocation = useLocation;\n _useNavigationType = useNavigationType;\n _matchRoutes = matchRoutes;\n _createRoutesFromChildren = createRoutesFromChildren;\n _stripBasename = stripBasename || false;\n },\n afterAllSetup(client) {\n integration.afterAllSetup(client);\n\n const initPathName = WINDOW && WINDOW.location && WINDOW.location.pathname;\n if (instrumentPageLoad && initPathName) {\n startBrowserTracingPageLoadSpan(client, {\n name: initPathName,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'pageload',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.pageload.react.reactrouter_v6',\n },\n });\n }\n\n if (instrumentNavigation) {\n CLIENTS_WITH_INSTRUMENT_NAVIGATION.add(client);\n }\n },\n };\n}\n\n/**\n * Strip the basename from a pathname if exists.\n *\n * Vendored and modified from `react-router`\n * https://github.com/remix-run/react-router/blob/462bb712156a3f739d6139a0f14810b76b002df6/packages/router/utils.ts#L1038\n */\nfunction stripBasenameFromPathname(pathname: string, basename: string): string {\n if (!basename || basename === '/') {\n return pathname;\n }\n\n if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) {\n return pathname;\n }\n\n // We want to leave trailing slash behavior in the user's control, so if they\n // specify a basename with a trailing slash, we should support it\n const startIndex = basename.endsWith('/') ? basename.length - 1 : basename.length;\n const nextChar = pathname.charAt(startIndex);\n if (nextChar && nextChar !== '/') {\n // pathname does not start with basename/\n return pathname;\n }\n\n return pathname.slice(startIndex) || '/';\n}\n\nfunction getNormalizedName(\n routes: RouteObject[],\n location: Location,\n branches: RouteMatch[],\n basename: string = '',\n): [string, TransactionSource] {\n if (!routes || routes.length === 0) {\n return [_stripBasename ? stripBasenameFromPathname(location.pathname, basename) : location.pathname, 'url'];\n }\n\n let pathBuilder = '';\n if (branches) {\n // eslint-disable-next-line @typescript-eslint/prefer-for-of\n for (let x = 0; x < branches.length; x++) {\n const branch = branches[x];\n const route = branch.route;\n if (route) {\n // Early return if index route\n if (route.index) {\n return [_stripBasename ? stripBasenameFromPathname(branch.pathname, basename) : branch.pathname, 'route'];\n }\n\n const path = route.path;\n if (path) {\n const newPath = path[0] === '/' || pathBuilder[pathBuilder.length - 1] === '/' ? path : `/${path}`;\n pathBuilder += newPath;\n\n if (basename + branch.pathname === location.pathname) {\n if (\n // If the route defined on the element is something like\n // <Route path=\"/stores/:storeId/products/:productId\" element={<div>Product</div>} />\n // We should check against the branch.pathname for the number of / seperators\n getNumberOfUrlSegments(pathBuilder) !== getNumberOfUrlSegments(branch.pathname) &&\n // We should not count wildcard operators in the url segments calculation\n pathBuilder.slice(-2) !== '/*'\n ) {\n return [(_stripBasename ? '' : basename) + newPath, 'route'];\n }\n return [(_stripBasename ? '' : basename) + pathBuilder, 'route'];\n }\n }\n }\n }\n }\n\n return [_stripBasename ? stripBasenameFromPathname(location.pathname, basename) : location.pathname, 'url'];\n}\n\nfunction updatePageloadTransaction(\n activeRootSpan: Span | undefined,\n location: Location,\n routes: RouteObject[],\n matches?: AgnosticDataRouteMatch,\n basename?: string,\n): void {\n const branches = Array.isArray(matches)\n ? matches\n : (_matchRoutes(routes, location, basename) as unknown as RouteMatch[]);\n\n if (branches) {\n const [name, source] = getNormalizedName(routes, location, branches, basename);\n\n getCurrentScope().setTransactionName(name);\n\n if (activeRootSpan) {\n activeRootSpan.updateName(name);\n activeRootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, source);\n }\n }\n}\n\nfunction handleNavigation(\n location: Location,\n routes: RouteObject[],\n navigationType: Action,\n matches?: AgnosticDataRouteMatch,\n basename?: string,\n): void {\n const branches = Array.isArray(matches) ? matches : _matchRoutes(routes, location, basename);\n\n const client = getClient();\n if (!client || !CLIENTS_WITH_INSTRUMENT_NAVIGATION.has(client)) {\n return;\n }\n\n if ((navigationType === 'PUSH' || navigationType === 'POP') && branches) {\n const [name, source] = getNormalizedName(routes, location, branches, basename);\n\n startBrowserTracingNavigationSpan(client, {\n name,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.react.reactrouter_v6',\n },\n });\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function withSentryReactRouterV6Routing<P extends Record<string, any>, R extends React.FC<P>>(Routes: R): R {\n if (!_useEffect || !_useLocation || !_useNavigationType || !_createRoutesFromChildren || !_matchRoutes) {\n DEBUG_BUILD &&\n logger.warn(`reactRouterV6Instrumentation was unable to wrap Routes because of one or more missing parameters.\n useEffect: ${_useEffect}. useLocation: ${_useLocation}. useNavigationType: ${_useNavigationType}.\n createRoutesFromChildren: ${_createRoutesFromChildren}. matchRoutes: ${_matchRoutes}.`);\n\n return Routes;\n }\n\n let isMountRenderPass: boolean = true;\n\n const SentryRoutes: React.FC<P> = (props: P) => {\n const location = _useLocation();\n const navigationType = _useNavigationType();\n\n _useEffect(\n () => {\n const routes = _createRoutesFromChildren(props.children) as RouteObject[];\n\n if (isMountRenderPass) {\n updatePageloadTransaction(getActiveRootSpan(), location, routes);\n isMountRenderPass = false;\n } else {\n handleNavigation(location, routes, navigationType);\n }\n },\n // `props.children` is purpusely not included in the dependency array, because we do not want to re-run this effect\n // when the children change. We only want to start transactions when the location or navigation type change.\n [location, navigationType],\n );\n\n // @ts-expect-error Setting more specific React Component typing for `R` generic above\n // will break advanced type inference done by react router params\n return <Routes {...props} />;\n };\n\n hoistNonReactStatics(SentryRoutes, Routes);\n\n // @ts-expect-error Setting more specific React Component typing for `R` generic above\n // will break advanced type inference done by react router params\n return SentryRoutes;\n}\n\nexport function wrapUseRoutes(origUseRoutes: UseRoutes): UseRoutes {\n if (!_useEffect || !_useLocation || !_useNavigationType || !_matchRoutes) {\n DEBUG_BUILD &&\n logger.warn(\n 'reactRouterV6Instrumentation was unable to wrap `useRoutes` because of one or more missing parameters.',\n );\n\n return origUseRoutes;\n }\n\n let isMountRenderPass: boolean = true;\n\n const SentryRoutes: React.FC<{\n children?: React.ReactNode;\n routes: RouteObject[];\n locationArg?: Partial<Location> | string;\n }> = (props: { children?: React.ReactNode; routes: RouteObject[]; locationArg?: Partial<Location> | string }) => {\n const { routes, locationArg } = props;\n\n const Routes = origUseRoutes(routes, locationArg);\n\n const location = _useLocation();\n const navigationType = _useNavigationType();\n\n // A value with stable identity to either pick `locationArg` if available or `location` if not\n const stableLocationParam =\n typeof locationArg === 'string' || (locationArg && locationArg.pathname)\n ? (locationArg as { pathname: string })\n : location;\n\n _useEffect(() => {\n const normalizedLocation =\n typeof stableLocationParam === 'string' ? { pathname: stableLocationParam } : stableLocationParam;\n\n if (isMountRenderPass) {\n updatePageloadTransaction(getActiveRootSpan(), normalizedLocation, routes);\n isMountRenderPass = false;\n } else {\n handleNavigation(normalizedLocation, routes, navigationType);\n }\n }, [navigationType, stableLocationParam]);\n\n return Routes;\n };\n\n // eslint-disable-next-line react/display-name\n return (routes: RouteObject[], locationArg?: Partial<Location> | string): React.ReactElement | null => {\n return <SentryRoutes routes={routes} locationArg={locationArg} />;\n };\n}\n\nexport function wrapCreateBrowserRouter<\n TState extends RouterState = RouterState,\n TRouter extends Router<TState> = Router<TState>,\n>(createRouterFunction: CreateRouterFunction<TState, TRouter>): CreateRouterFunction<TState, TRouter> {\n if (!_useEffect || !_useLocation || !_useNavigationType || !_matchRoutes) {\n DEBUG_BUILD &&\n logger.warn(\n 'reactRouterV6Instrumentation was unable to wrap the `createRouter` function because of one or more missing parameters.',\n );\n\n return createRouterFunction;\n }\n\n // `opts` for createBrowserHistory and createMemoryHistory are different, but also not relevant for us at the moment.\n // `basename` is the only option that is relevant for us, and it is the same for all.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return function (routes: RouteObject[], opts?: Record<string, any> & { basename?: string }): TRouter {\n const router = createRouterFunction(routes, opts);\n const basename = opts && opts.basename;\n\n const activeRootSpan = getActiveRootSpan();\n\n // The initial load ends when `createBrowserRouter` is called.\n // This is the earliest convenient time to update the transaction name.\n // Callbacks to `router.subscribe` are not called for the initial load.\n if (router.state.historyAction === 'POP' && activeRootSpan) {\n updatePageloadTransaction(activeRootSpan, router.state.location, routes, undefined, basename);\n }\n\n router.subscribe((state: RouterState) => {\n const location = state.location;\n if (state.historyAction === 'PUSH' || state.historyAction === 'POP') {\n handleNavigation(location, routes, state.historyAction, undefined, basename);\n }\n });\n\n return router;\n };\n}\n\nfunction getActiveRootSpan(): Span | undefined {\n const span = getActiveSpan();\n const rootSpan = span ? getRootSpan(span) : undefined;\n\n if (!rootSpan) {\n return undefined;\n }\n\n const op = spanToJSON(rootSpan).op;\n\n // Only use this root span if it is a pageload or navigation span\n return op === 'navigation' || op === 'pageload' ? rootSpan : undefined;\n}\n"],"names":["browserTracingIntegration","WINDOW","startBrowserTracingPageLoadSpan","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","SEMANTIC_ATTRIBUTE_SENTRY_OP","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","getNumberOfUrlSegments","getCurrentScope","getClient","startBrowserTracingNavigationSpan","DEBUG_BUILD","logger","_jsx","hoistNonReactStatics","getActiveSpan","getRootSpan","spanToJSON"],"mappings":";;;;;;;;;;;;;;AA0CA,IAAI,UAAU,CAAA;AACd,IAAI,YAAY,CAAA;AAChB,IAAI,kBAAkB,CAAA;AACtB,IAAI,yBAAyB,CAAA;AAC7B,IAAI,YAAY,CAAA;AAChB,IAAI,cAAc,GAAY,KAAK,CAAA;AACnC;AACA,MAAM,kCAAmC,GAAE,IAAI,OAAO,EAAU,CAAA;;AAWhE;AACA;AACA;AACA;AACO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A;AACA;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"reactrouterv6.js","sources":["../../src/reactrouterv6.tsx"],"sourcesContent":["// Inspired from Donnie McNeal's solution:\n// https://gist.github.com/wontondon/e8c4bdf2888875e4c755712e99279536\n\nimport {\n WINDOW,\n browserTracingIntegration,\n startBrowserTracingNavigationSpan,\n startBrowserTracingPageLoadSpan,\n} from '@sentry/browser';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n getActiveSpan,\n getClient,\n getCurrentScope,\n getRootSpan,\n spanToJSON,\n} from '@sentry/core';\nimport type { Client, Integration, Span, TransactionSource } from '@sentry/types';\nimport { getNumberOfUrlSegments, logger } from '@sentry/utils';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\n\nimport { DEBUG_BUILD } from './debug-build';\nimport type {\n Action,\n AgnosticDataRouteMatch,\n CreateRouterFunction,\n CreateRoutesFromChildren,\n Location,\n MatchRoutes,\n RouteMatch,\n RouteObject,\n Router,\n RouterState,\n UseEffect,\n UseLocation,\n UseNavigationType,\n UseRoutes,\n} from './types';\n\nlet _useEffect: UseEffect;\nlet _useLocation: UseLocation;\nlet _useNavigationType: UseNavigationType;\nlet _createRoutesFromChildren: CreateRoutesFromChildren;\nlet _matchRoutes: MatchRoutes;\nlet _stripBasename: boolean = false;\n\nconst CLIENTS_WITH_INSTRUMENT_NAVIGATION = new WeakSet<Client>();\n\ninterface ReactRouterOptions {\n useEffect: UseEffect;\n useLocation: UseLocation;\n useNavigationType: UseNavigationType;\n createRoutesFromChildren: CreateRoutesFromChildren;\n matchRoutes: MatchRoutes;\n stripBasename?: boolean;\n}\n\n/**\n * A browser tracing integration that uses React Router v6 to instrument navigations.\n * Expects `useEffect`, `useLocation`, `useNavigationType`, `createRoutesFromChildren` and `matchRoutes` to be passed as options.\n */\nexport function reactRouterV6BrowserTracingIntegration(\n options: Parameters<typeof browserTracingIntegration>[0] & ReactRouterOptions,\n): Integration {\n const integration = browserTracingIntegration({\n ...options,\n instrumentPageLoad: false,\n instrumentNavigation: false,\n });\n\n const {\n useEffect,\n useLocation,\n useNavigationType,\n createRoutesFromChildren,\n matchRoutes,\n stripBasename,\n instrumentPageLoad = true,\n instrumentNavigation = true,\n } = options;\n\n return {\n ...integration,\n setup() {\n _useEffect = useEffect;\n _useLocation = useLocation;\n _useNavigationType = useNavigationType;\n _matchRoutes = matchRoutes;\n _createRoutesFromChildren = createRoutesFromChildren;\n _stripBasename = stripBasename || false;\n },\n afterAllSetup(client) {\n integration.afterAllSetup(client);\n\n const initPathName = WINDOW && WINDOW.location && WINDOW.location.pathname;\n if (instrumentPageLoad && initPathName) {\n startBrowserTracingPageLoadSpan(client, {\n name: initPathName,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'pageload',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.pageload.react.reactrouter_v6',\n },\n });\n }\n\n if (instrumentNavigation) {\n CLIENTS_WITH_INSTRUMENT_NAVIGATION.add(client);\n }\n },\n };\n}\n\n/**\n * Strip the basename from a pathname if exists.\n *\n * Vendored and modified from `react-router`\n * https://github.com/remix-run/react-router/blob/462bb712156a3f739d6139a0f14810b76b002df6/packages/router/utils.ts#L1038\n */\nfunction stripBasenameFromPathname(pathname: string, basename: string): string {\n if (!basename || basename === '/') {\n return pathname;\n }\n\n if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) {\n return pathname;\n }\n\n // We want to leave trailing slash behavior in the user's control, so if they\n // specify a basename with a trailing slash, we should support it\n const startIndex = basename.endsWith('/') ? basename.length - 1 : basename.length;\n const nextChar = pathname.charAt(startIndex);\n if (nextChar && nextChar !== '/') {\n // pathname does not start with basename/\n return pathname;\n }\n\n return pathname.slice(startIndex) || '/';\n}\n\nfunction getNormalizedName(\n routes: RouteObject[],\n location: Location,\n branches: RouteMatch[],\n basename: string = '',\n): [string, TransactionSource] {\n if (!routes || routes.length === 0) {\n return [_stripBasename ? stripBasenameFromPathname(location.pathname, basename) : location.pathname, 'url'];\n }\n\n let pathBuilder = '';\n if (branches) {\n for (const branch of branches) {\n const route = branch.route;\n if (route) {\n // Early return if index route\n if (route.index) {\n return [_stripBasename ? stripBasenameFromPathname(branch.pathname, basename) : branch.pathname, 'route'];\n }\n\n const path = route.path;\n if (path) {\n const newPath = path[0] === '/' || pathBuilder[pathBuilder.length - 1] === '/' ? path : `/${path}`;\n pathBuilder += newPath;\n\n if (basename + branch.pathname === location.pathname) {\n if (\n // If the route defined on the element is something like\n // <Route path=\"/stores/:storeId/products/:productId\" element={<div>Product</div>} />\n // We should check against the branch.pathname for the number of / seperators\n getNumberOfUrlSegments(pathBuilder) !== getNumberOfUrlSegments(branch.pathname) &&\n // We should not count wildcard operators in the url segments calculation\n pathBuilder.slice(-2) !== '/*'\n ) {\n return [(_stripBasename ? '' : basename) + newPath, 'route'];\n }\n return [(_stripBasename ? '' : basename) + pathBuilder, 'route'];\n }\n }\n }\n }\n }\n\n return [_stripBasename ? stripBasenameFromPathname(location.pathname, basename) : location.pathname, 'url'];\n}\n\nfunction updatePageloadTransaction(\n activeRootSpan: Span | undefined,\n location: Location,\n routes: RouteObject[],\n matches?: AgnosticDataRouteMatch,\n basename?: string,\n): void {\n const branches = Array.isArray(matches)\n ? matches\n : (_matchRoutes(routes, location, basename) as unknown as RouteMatch[]);\n\n if (branches) {\n const [name, source] = getNormalizedName(routes, location, branches, basename);\n\n getCurrentScope().setTransactionName(name);\n\n if (activeRootSpan) {\n activeRootSpan.updateName(name);\n activeRootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, source);\n }\n }\n}\n\nfunction handleNavigation(\n location: Location,\n routes: RouteObject[],\n navigationType: Action,\n matches?: AgnosticDataRouteMatch,\n basename?: string,\n): void {\n const branches = Array.isArray(matches) ? matches : _matchRoutes(routes, location, basename);\n\n const client = getClient();\n if (!client || !CLIENTS_WITH_INSTRUMENT_NAVIGATION.has(client)) {\n return;\n }\n\n if ((navigationType === 'PUSH' || navigationType === 'POP') && branches) {\n const [name, source] = getNormalizedName(routes, location, branches, basename);\n\n startBrowserTracingNavigationSpan(client, {\n name,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.react.reactrouter_v6',\n },\n });\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function withSentryReactRouterV6Routing<P extends Record<string, any>, R extends React.FC<P>>(Routes: R): R {\n if (!_useEffect || !_useLocation || !_useNavigationType || !_createRoutesFromChildren || !_matchRoutes) {\n DEBUG_BUILD &&\n logger.warn(`reactRouterV6Instrumentation was unable to wrap Routes because of one or more missing parameters.\n useEffect: ${_useEffect}. useLocation: ${_useLocation}. useNavigationType: ${_useNavigationType}.\n createRoutesFromChildren: ${_createRoutesFromChildren}. matchRoutes: ${_matchRoutes}.`);\n\n return Routes;\n }\n\n let isMountRenderPass: boolean = true;\n\n const SentryRoutes: React.FC<P> = (props: P) => {\n const location = _useLocation();\n const navigationType = _useNavigationType();\n\n _useEffect(\n () => {\n const routes = _createRoutesFromChildren(props.children) as RouteObject[];\n\n if (isMountRenderPass) {\n updatePageloadTransaction(getActiveRootSpan(), location, routes);\n isMountRenderPass = false;\n } else {\n handleNavigation(location, routes, navigationType);\n }\n },\n // `props.children` is purpusely not included in the dependency array, because we do not want to re-run this effect\n // when the children change. We only want to start transactions when the location or navigation type change.\n [location, navigationType],\n );\n\n // @ts-expect-error Setting more specific React Component typing for `R` generic above\n // will break advanced type inference done by react router params\n return <Routes {...props} />;\n };\n\n hoistNonReactStatics(SentryRoutes, Routes);\n\n // @ts-expect-error Setting more specific React Component typing for `R` generic above\n // will break advanced type inference done by react router params\n return SentryRoutes;\n}\n\nexport function wrapUseRoutes(origUseRoutes: UseRoutes): UseRoutes {\n if (!_useEffect || !_useLocation || !_useNavigationType || !_matchRoutes) {\n DEBUG_BUILD &&\n logger.warn(\n 'reactRouterV6Instrumentation was unable to wrap `useRoutes` because of one or more missing parameters.',\n );\n\n return origUseRoutes;\n }\n\n let isMountRenderPass: boolean = true;\n\n const SentryRoutes: React.FC<{\n children?: React.ReactNode;\n routes: RouteObject[];\n locationArg?: Partial<Location> | string;\n }> = (props: { children?: React.ReactNode; routes: RouteObject[]; locationArg?: Partial<Location> | string }) => {\n const { routes, locationArg } = props;\n\n const Routes = origUseRoutes(routes, locationArg);\n\n const location = _useLocation();\n const navigationType = _useNavigationType();\n\n // A value with stable identity to either pick `locationArg` if available or `location` if not\n const stableLocationParam =\n typeof locationArg === 'string' || (locationArg && locationArg.pathname)\n ? (locationArg as { pathname: string })\n : location;\n\n _useEffect(() => {\n const normalizedLocation =\n typeof stableLocationParam === 'string' ? { pathname: stableLocationParam } : stableLocationParam;\n\n if (isMountRenderPass) {\n updatePageloadTransaction(getActiveRootSpan(), normalizedLocation, routes);\n isMountRenderPass = false;\n } else {\n handleNavigation(normalizedLocation, routes, navigationType);\n }\n }, [navigationType, stableLocationParam]);\n\n return Routes;\n };\n\n // eslint-disable-next-line react/display-name\n return (routes: RouteObject[], locationArg?: Partial<Location> | string): React.ReactElement | null => {\n return <SentryRoutes routes={routes} locationArg={locationArg} />;\n };\n}\n\nexport function wrapCreateBrowserRouter<\n TState extends RouterState = RouterState,\n TRouter extends Router<TState> = Router<TState>,\n>(createRouterFunction: CreateRouterFunction<TState, TRouter>): CreateRouterFunction<TState, TRouter> {\n if (!_useEffect || !_useLocation || !_useNavigationType || !_matchRoutes) {\n DEBUG_BUILD &&\n logger.warn(\n 'reactRouterV6Instrumentation was unable to wrap the `createRouter` function because of one or more missing parameters.',\n );\n\n return createRouterFunction;\n }\n\n // `opts` for createBrowserHistory and createMemoryHistory are different, but also not relevant for us at the moment.\n // `basename` is the only option that is relevant for us, and it is the same for all.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return function (routes: RouteObject[], opts?: Record<string, any> & { basename?: string }): TRouter {\n const router = createRouterFunction(routes, opts);\n const basename = opts && opts.basename;\n\n const activeRootSpan = getActiveRootSpan();\n\n // The initial load ends when `createBrowserRouter` is called.\n // This is the earliest convenient time to update the transaction name.\n // Callbacks to `router.subscribe` are not called for the initial load.\n if (router.state.historyAction === 'POP' && activeRootSpan) {\n updatePageloadTransaction(activeRootSpan, router.state.location, routes, undefined, basename);\n }\n\n router.subscribe((state: RouterState) => {\n const location = state.location;\n if (state.historyAction === 'PUSH' || state.historyAction === 'POP') {\n handleNavigation(location, routes, state.historyAction, undefined, basename);\n }\n });\n\n return router;\n };\n}\n\nfunction getActiveRootSpan(): Span | undefined {\n const span = getActiveSpan();\n const rootSpan = span ? getRootSpan(span) : undefined;\n\n if (!rootSpan) {\n return undefined;\n }\n\n const op = spanToJSON(rootSpan).op;\n\n // Only use this root span if it is a pageload or navigation span\n return op === 'navigation' || op === 'pageload' ? rootSpan : undefined;\n}\n"],"names":["browserTracingIntegration","WINDOW","startBrowserTracingPageLoadSpan","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","SEMANTIC_ATTRIBUTE_SENTRY_OP","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","getNumberOfUrlSegments","getCurrentScope","getClient","startBrowserTracingNavigationSpan","DEBUG_BUILD","logger","_jsx","hoistNonReactStatics","getActiveSpan","getRootSpan","spanToJSON"],"mappings":";;;;;;;;;;;;;;AA0CA,IAAI,UAAU,CAAA;AACd,IAAI,YAAY,CAAA;AAChB,IAAI,kBAAkB,CAAA;AACtB,IAAI,yBAAyB,CAAA;AAC7B,IAAI,YAAY,CAAA;AAChB,IAAI,cAAc,GAAY,KAAK,CAAA;AACnC;AACA,MAAM,kCAAmC,GAAE,IAAI,OAAO,EAAU,CAAA;;AAWhE;AACA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|
|
3
3
|
const browser = require('@sentry/browser');
|
|
4
4
|
const core = require('@sentry/core');
|
|
5
|
+
const React = require('react');
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Inits the React SDK
|
|
@@ -12,7 +13,7 @@ function init(options) {
|
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
core.applySdkMetadata(opts, 'react');
|
|
15
|
-
|
|
16
|
+
browser.setContext('react', { version: React.version });
|
|
16
17
|
browser.init(opts);
|
|
17
18
|
}
|
|
18
19
|
|
package/cjs/sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import type { BrowserOptions } from '@sentry/browser';\nimport { init as browserInit } from '@sentry/browser';\nimport { applySdkMetadata } from '@sentry/core';\n\n/**\n * Inits the React SDK\n */\nexport function init(options: BrowserOptions): void {\n const opts = {\n ...options,\n };\n\n applySdkMetadata(opts, 'react');\n
|
|
1
|
+
{"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import type { BrowserOptions } from '@sentry/browser';\nimport { init as browserInit, setContext } from '@sentry/browser';\nimport { applySdkMetadata } from '@sentry/core';\n\nimport { version } from 'react';\n\n/**\n * Inits the React SDK\n */\nexport function init(options: BrowserOptions): void {\n const opts = {\n ...options,\n };\n\n applySdkMetadata(opts, 'react');\n setContext('react', { version });\n browserInit(opts);\n}\n"],"names":["applySdkMetadata","setContext","version","browserInit"],"mappings":";;;;;;AAMA;AACA;AACA;AACO,SAAS,IAAI,CAAC,OAAO,EAAwB;AACpD,EAAE,MAAM,OAAO;AACf,IAAI,GAAG,OAAO;AACd,GAAG,CAAA;AACH;AACA,EAAEA,qBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;AACjC,EAAEC,kBAAU,CAAC,OAAO,EAAE,WAAEC,aAAA,EAAS,CAAC,CAAA;AAClC,EAAEC,YAAW,CAAC,IAAI,CAAC,CAAA;AACnB;;;;"}
|
package/cjs/tanstackrouter.js
CHANGED
|
@@ -109,9 +109,9 @@ function routeMatchToParamSpanAttributes(match) {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
const paramAttributes = {};
|
|
112
|
-
|
|
113
|
-
paramAttributes[`url.path.params.${key}`] =
|
|
114
|
-
}
|
|
112
|
+
Object.entries(match.params).forEach(([key, value]) => {
|
|
113
|
+
paramAttributes[`url.path.params.${key}`] = value;
|
|
114
|
+
});
|
|
115
115
|
|
|
116
116
|
return paramAttributes;
|
|
117
117
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tanstackrouter.js","sources":["../../src/tanstackrouter.ts"],"sourcesContent":["import { WINDOW, startBrowserTracingNavigationSpan, startBrowserTracingPageLoadSpan } from '@sentry/browser';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n} from '@sentry/core';\n\nimport { browserTracingIntegration as originalBrowserTracingIntegration } from '@sentry/browser';\nimport type { Integration } from '@sentry/types';\nimport type { VendoredTanstackRouter, VendoredTanstackRouterRouteMatch } from './vendor/tanstackrouter-types';\n\n/**\n * A custom browser tracing integration for TanStack Router.\n *\n * The minimum compatible version of `@tanstack/router` is `1.34.5`.\n *\n * @param router A TanStack Router `Router` instance that should be used for routing instrumentation.\n * @param options Sentry browser tracing configuration.\n */\nexport function tanstackRouterBrowserTracingIntegration(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n router: any, // This is `any` because we don't want any type mismatches if TanStack Router changes their types\n options: Parameters<typeof originalBrowserTracingIntegration>[0] = {},\n): Integration {\n const castRouterInstance: VendoredTanstackRouter = router;\n\n const browserTracingIntegrationInstance = originalBrowserTracingIntegration({\n ...options,\n instrumentNavigation: false,\n instrumentPageLoad: false,\n });\n\n const { instrumentPageLoad = true, instrumentNavigation = true } = options;\n\n return {\n ...browserTracingIntegrationInstance,\n afterAllSetup(client) {\n browserTracingIntegrationInstance.afterAllSetup(client);\n\n const initialWindowLocation = WINDOW.location;\n if (instrumentPageLoad && initialWindowLocation) {\n const matchedRoutes = castRouterInstance.matchRoutes(\n initialWindowLocation.pathname,\n initialWindowLocation.search,\n { preload: false, throwOnError: false },\n );\n\n const lastMatch = matchedRoutes[matchedRoutes.length - 1];\n\n startBrowserTracingPageLoadSpan(client, {\n name: lastMatch ? lastMatch.routeId : initialWindowLocation.pathname,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'pageload',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.pageload.react.tanstack_router',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: lastMatch ? 'route' : 'url',\n ...routeMatchToParamSpanAttributes(lastMatch),\n },\n });\n }\n\n if (instrumentNavigation) {\n // The onBeforeNavigate hook is called at the very beginning of a navigation and is only called once per navigation, even when the user is redirected\n castRouterInstance.subscribe('onBeforeNavigate', onBeforeNavigateArgs => {\n // onBeforeNavigate is called during pageloads. We can avoid creating navigation spans by comparing the states of the to and from arguments.\n if (onBeforeNavigateArgs.toLocation.state === onBeforeNavigateArgs.fromLocation.state) {\n return;\n }\n\n const onResolvedMatchedRoutes = castRouterInstance.matchRoutes(\n onBeforeNavigateArgs.toLocation.pathname,\n onBeforeNavigateArgs.toLocation.search,\n { preload: false, throwOnError: false },\n );\n\n const onBeforeNavigateLastMatch = onResolvedMatchedRoutes[onResolvedMatchedRoutes.length - 1];\n\n const navigationLocation = WINDOW.location;\n const navigationSpan = startBrowserTracingNavigationSpan(client, {\n name: onBeforeNavigateLastMatch ? onBeforeNavigateLastMatch.routeId : navigationLocation.pathname,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.react.tanstack_router',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: onBeforeNavigateLastMatch ? 'route' : 'url',\n },\n });\n\n // In case the user is redirected during navigation we want to update the span with the right value.\n const unsubscribeOnResolved = castRouterInstance.subscribe('onResolved', onResolvedArgs => {\n unsubscribeOnResolved();\n if (navigationSpan) {\n const onResolvedMatchedRoutes = castRouterInstance.matchRoutes(\n onResolvedArgs.toLocation.pathname,\n onResolvedArgs.toLocation.search,\n { preload: false, throwOnError: false },\n );\n\n const onResolvedLastMatch = onResolvedMatchedRoutes[onResolvedMatchedRoutes.length - 1];\n\n if (onResolvedLastMatch) {\n navigationSpan.updateName(onResolvedLastMatch.routeId);\n navigationSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'route');\n navigationSpan.setAttributes(routeMatchToParamSpanAttributes(onResolvedLastMatch));\n }\n }\n });\n });\n }\n },\n };\n}\n\nfunction routeMatchToParamSpanAttributes(match: VendoredTanstackRouterRouteMatch | undefined): Record<string, string> {\n if (!match) {\n return {};\n }\n\n const paramAttributes: Record<string, string> = {};\n
|
|
1
|
+
{"version":3,"file":"tanstackrouter.js","sources":["../../src/tanstackrouter.ts"],"sourcesContent":["import { WINDOW, startBrowserTracingNavigationSpan, startBrowserTracingPageLoadSpan } from '@sentry/browser';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n} from '@sentry/core';\n\nimport { browserTracingIntegration as originalBrowserTracingIntegration } from '@sentry/browser';\nimport type { Integration } from '@sentry/types';\nimport type { VendoredTanstackRouter, VendoredTanstackRouterRouteMatch } from './vendor/tanstackrouter-types';\n\n/**\n * A custom browser tracing integration for TanStack Router.\n *\n * The minimum compatible version of `@tanstack/router` is `1.34.5`.\n *\n * @param router A TanStack Router `Router` instance that should be used for routing instrumentation.\n * @param options Sentry browser tracing configuration.\n */\nexport function tanstackRouterBrowserTracingIntegration(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n router: any, // This is `any` because we don't want any type mismatches if TanStack Router changes their types\n options: Parameters<typeof originalBrowserTracingIntegration>[0] = {},\n): Integration {\n const castRouterInstance: VendoredTanstackRouter = router;\n\n const browserTracingIntegrationInstance = originalBrowserTracingIntegration({\n ...options,\n instrumentNavigation: false,\n instrumentPageLoad: false,\n });\n\n const { instrumentPageLoad = true, instrumentNavigation = true } = options;\n\n return {\n ...browserTracingIntegrationInstance,\n afterAllSetup(client) {\n browserTracingIntegrationInstance.afterAllSetup(client);\n\n const initialWindowLocation = WINDOW.location;\n if (instrumentPageLoad && initialWindowLocation) {\n const matchedRoutes = castRouterInstance.matchRoutes(\n initialWindowLocation.pathname,\n initialWindowLocation.search,\n { preload: false, throwOnError: false },\n );\n\n const lastMatch = matchedRoutes[matchedRoutes.length - 1];\n\n startBrowserTracingPageLoadSpan(client, {\n name: lastMatch ? lastMatch.routeId : initialWindowLocation.pathname,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'pageload',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.pageload.react.tanstack_router',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: lastMatch ? 'route' : 'url',\n ...routeMatchToParamSpanAttributes(lastMatch),\n },\n });\n }\n\n if (instrumentNavigation) {\n // The onBeforeNavigate hook is called at the very beginning of a navigation and is only called once per navigation, even when the user is redirected\n castRouterInstance.subscribe('onBeforeNavigate', onBeforeNavigateArgs => {\n // onBeforeNavigate is called during pageloads. We can avoid creating navigation spans by comparing the states of the to and from arguments.\n if (onBeforeNavigateArgs.toLocation.state === onBeforeNavigateArgs.fromLocation.state) {\n return;\n }\n\n const onResolvedMatchedRoutes = castRouterInstance.matchRoutes(\n onBeforeNavigateArgs.toLocation.pathname,\n onBeforeNavigateArgs.toLocation.search,\n { preload: false, throwOnError: false },\n );\n\n const onBeforeNavigateLastMatch = onResolvedMatchedRoutes[onResolvedMatchedRoutes.length - 1];\n\n const navigationLocation = WINDOW.location;\n const navigationSpan = startBrowserTracingNavigationSpan(client, {\n name: onBeforeNavigateLastMatch ? onBeforeNavigateLastMatch.routeId : navigationLocation.pathname,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.react.tanstack_router',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: onBeforeNavigateLastMatch ? 'route' : 'url',\n },\n });\n\n // In case the user is redirected during navigation we want to update the span with the right value.\n const unsubscribeOnResolved = castRouterInstance.subscribe('onResolved', onResolvedArgs => {\n unsubscribeOnResolved();\n if (navigationSpan) {\n const onResolvedMatchedRoutes = castRouterInstance.matchRoutes(\n onResolvedArgs.toLocation.pathname,\n onResolvedArgs.toLocation.search,\n { preload: false, throwOnError: false },\n );\n\n const onResolvedLastMatch = onResolvedMatchedRoutes[onResolvedMatchedRoutes.length - 1];\n\n if (onResolvedLastMatch) {\n navigationSpan.updateName(onResolvedLastMatch.routeId);\n navigationSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'route');\n navigationSpan.setAttributes(routeMatchToParamSpanAttributes(onResolvedLastMatch));\n }\n }\n });\n });\n }\n },\n };\n}\n\nfunction routeMatchToParamSpanAttributes(match: VendoredTanstackRouterRouteMatch | undefined): Record<string, string> {\n if (!match) {\n return {};\n }\n\n const paramAttributes: Record<string, string> = {};\n Object.entries(match.params).forEach(([key, value]) => {\n paramAttributes[`url.path.params.${key}`] = value;\n });\n\n return paramAttributes;\n}\n"],"names":["originalBrowserTracingIntegration","WINDOW","startBrowserTracingPageLoadSpan","SEMANTIC_ATTRIBUTE_SENTRY_OP","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","startBrowserTracingNavigationSpan"],"mappings":";;;;;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,uCAAuC;AACvD;AACA,EAAE,MAAM;AACR,E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cAAc,CAAC,UAAU,CAAC,QAAQ;AAClD,gBAAgB,cAAc,CAAC,UAAU,CAAC,MAAM;AAChD,gBAAgB,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO;AACvD,eAAe,CAAA;AACf;AACA,cAAc,MAAM,mBAAoB,GAAE,uBAAuB,CAAC,uBAAuB,CAAC,MAAA,GAAS,CAAC,CAAC,CAAA;AACrG;AACA,cAAc,IAAI,mBAAmB,EAAE;AACvC,gBAAgB,cAAc,CAAC,UAAU,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAA;AACtE,gBAAgB,cAAc,CAAC,YAAY,CAACA,qCAAgC,EAAE,OAAO,CAAC,CAAA;AACtF,gBAAgB,cAAc,CAAC,aAAa,CAAC,+BAA+B,CAAC,mBAAmB,CAAC,CAAC,CAAA;AAClG,eAAc;AACd,aAAY;AACZ,WAAW,CAAC,CAAA;AACZ,SAAS,CAAC,CAAA;AACV,OAAM;AACN,KAAK;AACL,GAAG,CAAA;AACH,CAAA;AACA;AACA,SAAS,+BAA+B,CAAC,KAAK,EAAwE;AACtH,EAAE,IAAI,CAAC,KAAK,EAAE;AACd,IAAI,OAAO,EAAE,CAAA;AACb,GAAE;AACF;AACA,EAAE,MAAM,eAAe,GAA2B,EAAE,CAAA;AACpD,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK;AACzD,IAAI,eAAe,CAAC,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAA,CAAA,GAAA,KAAA,CAAA;AACA,GAAA,CAAA,CAAA;AACA;AACA,EAAA,OAAA,eAAA,CAAA;AACA;;;;"}
|
package/esm/reactrouter.js
CHANGED
|
@@ -106,10 +106,9 @@ function instrumentReactRouter(
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
const branches = matchRoutes(allRoutes, pathname, matchPath);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return [branches[x].match.path, 'route'];
|
|
109
|
+
for (const branch of branches) {
|
|
110
|
+
if (branch.match.isExact) {
|
|
111
|
+
return [branch.match.path, 'route'];
|
|
113
112
|
}
|
|
114
113
|
}
|
|
115
114
|
|
|
@@ -162,7 +161,8 @@ function matchRoutes(
|
|
|
162
161
|
const match = route.path
|
|
163
162
|
? matchPath(pathname, route)
|
|
164
163
|
: branch.length
|
|
165
|
-
?
|
|
164
|
+
? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
165
|
+
branch[branch.length - 1].match // use parent match
|
|
166
166
|
: computeRootMatch(pathname); // use default "root" match
|
|
167
167
|
|
|
168
168
|
if (match) {
|
package/esm/reactrouter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactrouter.js","sources":["../../src/reactrouter.tsx"],"sourcesContent":["import {\n WINDOW,\n browserTracingIntegration,\n startBrowserTracingNavigationSpan,\n startBrowserTracingPageLoadSpan,\n} from '@sentry/browser';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n getActiveSpan,\n getCurrentScope,\n getRootSpan,\n spanToJSON,\n} from '@sentry/core';\nimport type { Client, Integration, Span, TransactionSource } from '@sentry/types';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\n\nimport type { Action, Location } from './types';\n\n// We need to disable eslint no-explict-any because any is required for the\n// react-router typings.\ntype Match = { path: string; url: string; params: Record<string, any>; isExact: boolean }; // eslint-disable-line @typescript-eslint/no-explicit-any\n\nexport type RouterHistory = {\n location?: Location;\n listen?(cb: (location: Location, action: Action) => void): void;\n} & Record<string, any>; // eslint-disable-line @typescript-eslint/no-explicit-any\n\nexport type RouteConfig = {\n [propName: string]: unknown;\n path?: string | string[];\n exact?: boolean;\n component?: JSX.Element;\n routes?: RouteConfig[];\n};\n\nexport type MatchPath = (pathname: string, props: string | string[] | any, parent?: Match | null) => Match | null; // eslint-disable-line @typescript-eslint/no-explicit-any\n\ninterface ReactRouterOptions {\n history: RouterHistory;\n routes?: RouteConfig[];\n matchPath?: MatchPath;\n}\n\n/**\n * A browser tracing integration that uses React Router v4 to instrument navigations.\n * Expects `history` (and optionally `routes` and `matchPath`) to be passed as options.\n */\nexport function reactRouterV4BrowserTracingIntegration(\n options: Parameters<typeof browserTracingIntegration>[0] & ReactRouterOptions,\n): Integration {\n const integration = browserTracingIntegration({\n ...options,\n instrumentPageLoad: false,\n instrumentNavigation: false,\n });\n\n const { history, routes, matchPath, instrumentPageLoad = true, instrumentNavigation = true } = options;\n\n return {\n ...integration,\n afterAllSetup(client) {\n integration.afterAllSetup(client);\n\n instrumentReactRouter(\n client,\n instrumentPageLoad,\n instrumentNavigation,\n history,\n 'reactrouter_v4',\n routes,\n matchPath,\n );\n },\n };\n}\n\n/**\n * A browser tracing integration that uses React Router v5 to instrument navigations.\n * Expects `history` (and optionally `routes` and `matchPath`) to be passed as options.\n */\nexport function reactRouterV5BrowserTracingIntegration(\n options: Parameters<typeof browserTracingIntegration>[0] & ReactRouterOptions,\n): Integration {\n const integration = browserTracingIntegration({\n ...options,\n instrumentPageLoad: false,\n instrumentNavigation: false,\n });\n\n const { history, routes, matchPath, instrumentPageLoad = true, instrumentNavigation = true } = options;\n\n return {\n ...integration,\n afterAllSetup(client) {\n integration.afterAllSetup(client);\n\n instrumentReactRouter(\n client,\n instrumentPageLoad,\n instrumentNavigation,\n history,\n 'reactrouter_v5',\n routes,\n matchPath,\n );\n },\n };\n}\n\nfunction instrumentReactRouter(\n client: Client,\n instrumentPageLoad: boolean,\n instrumentNavigation: boolean,\n history: RouterHistory,\n instrumentationName: string,\n allRoutes: RouteConfig[] = [],\n matchPath?: MatchPath,\n): void {\n function getInitPathName(): string | undefined {\n if (history && history.location) {\n return history.location.pathname;\n }\n\n if (WINDOW && WINDOW.location) {\n return WINDOW.location.pathname;\n }\n\n return undefined;\n }\n\n /**\n * Normalizes a transaction name. Returns the new name as well as the\n * source of the transaction.\n *\n * @param pathname The initial pathname we normalize\n */\n function normalizeTransactionName(pathname: string): [string, TransactionSource] {\n if (allRoutes.length === 0 || !matchPath) {\n return [pathname, 'url'];\n }\n\n const branches = matchRoutes(allRoutes, pathname, matchPath);\n // eslint-disable-next-line @typescript-eslint/prefer-for-of\n for (let x = 0; x < branches.length; x++) {\n if (branches[x].match.isExact) {\n return [branches[x].match.path, 'route'];\n }\n }\n\n return [pathname, 'url'];\n }\n\n if (instrumentPageLoad) {\n const initPathName = getInitPathName();\n if (initPathName) {\n const [name, source] = normalizeTransactionName(initPathName);\n startBrowserTracingPageLoadSpan(client, {\n name,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'pageload',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: `auto.pageload.react.${instrumentationName}`,\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,\n },\n });\n }\n }\n\n if (instrumentNavigation && history.listen) {\n history.listen((location, action) => {\n if (action && (action === 'PUSH' || action === 'POP')) {\n const [name, source] = normalizeTransactionName(location.pathname);\n startBrowserTracingNavigationSpan(client, {\n name,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: `auto.navigation.react.${instrumentationName}`,\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,\n },\n });\n }\n });\n }\n}\n\n/**\n * Matches a set of routes to a pathname\n * Based on implementation from\n */\nfunction matchRoutes(\n routes: RouteConfig[],\n pathname: string,\n matchPath: MatchPath,\n branch: Array<{ route: RouteConfig; match: Match }> = [],\n): Array<{ route: RouteConfig; match: Match }> {\n routes.some(route => {\n const match = route.path\n ? matchPath(pathname, route)\n : branch.length\n ? branch[branch.length - 1].match // use parent match\n : computeRootMatch(pathname); // use default \"root\" match\n\n if (match) {\n branch.push({ route, match });\n\n if (route.routes) {\n matchRoutes(route.routes, pathname, matchPath, branch);\n }\n }\n\n return !!match;\n });\n\n return branch;\n}\n\nfunction computeRootMatch(pathname: string): Match {\n return { path: '/', url: '/', params: {}, isExact: pathname === '/' };\n}\n\n/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */\nexport function withSentryRouting<P extends Record<string, any>, R extends React.ComponentType<P>>(Route: R): R {\n const componentDisplayName = (Route as any).displayName || (Route as any).name;\n\n const WrappedRoute: React.FC<P> = (props: P) => {\n if (props && props.computedMatch && props.computedMatch.isExact) {\n const route = props.computedMatch.path;\n const activeRootSpan = getActiveRootSpan();\n\n getCurrentScope().setTransactionName(route);\n\n if (activeRootSpan) {\n activeRootSpan.updateName(route);\n activeRootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'route');\n }\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 // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/13dc4235c069e25fe7ee16e11f529d909f9f3ff8/types/react-router/index.d.ts#L154-L164\n return <Route {...props} />;\n };\n\n WrappedRoute.displayName = `sentryRoute(${componentDisplayName})`;\n hoistNonReactStatics(WrappedRoute, Route);\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 // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/13dc4235c069e25fe7ee16e11f529d909f9f3ff8/types/react-router/index.d.ts#L154-L164\n return WrappedRoute;\n}\n/* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */\n\nfunction getActiveRootSpan(): Span | undefined {\n const span = getActiveSpan();\n const rootSpan = span && getRootSpan(span);\n\n if (!rootSpan) {\n return undefined;\n }\n\n const op = spanToJSON(rootSpan).op;\n\n // Only use this root span if it is a pageload or navigation span\n return op === 'navigation' || op === 'pageload' ? rootSpan : undefined;\n}\n"],"names":["_jsx"],"m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ter.tsx"],"sourcesContent":["import {\n WINDOW,\n browserTracingIntegration,\n startBrowserTracingNavigationSpan,\n startBrowserTracingPageLoadSpan,\n} from '@sentry/browser';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n getActiveSpan,\n getCurrentScope,\n getRootSpan,\n spanToJSON,\n} from '@sentry/core';\nimport type { Client, Integration, Span, TransactionSource } from '@sentry/types';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\n\nimport type { Action, Location } from './types';\n\n// We need to disable eslint no-explict-any because any is required for the\n// react-router typings.\ntype Match = { path: string; url: string; params: Record<string, any>; isExact: boolean }; // eslint-disable-line @typescript-eslint/no-explicit-any\n\nexport type RouterHistory = {\n location?: Location;\n listen?(cb: (location: Location, action: Action) => void): void;\n} & Record<string, any>; // eslint-disable-line @typescript-eslint/no-explicit-any\n\nexport type RouteConfig = {\n [propName: string]: unknown;\n path?: string | string[];\n exact?: boolean;\n component?: JSX.Element;\n routes?: RouteConfig[];\n};\n\nexport type MatchPath = (pathname: string, props: string | string[] | any, parent?: Match | null) => Match | null; // eslint-disable-line @typescript-eslint/no-explicit-any\n\ninterface ReactRouterOptions {\n history: RouterHistory;\n routes?: RouteConfig[];\n matchPath?: MatchPath;\n}\n\n/**\n * A browser tracing integration that uses React Router v4 to instrument navigations.\n * Expects `history` (and optionally `routes` and `matchPath`) to be passed as options.\n */\nexport function reactRouterV4BrowserTracingIntegration(\n options: Parameters<typeof browserTracingIntegration>[0] & ReactRouterOptions,\n): Integration {\n const integration = browserTracingIntegration({\n ...options,\n instrumentPageLoad: false,\n instrumentNavigation: false,\n });\n\n const { history, routes, matchPath, instrumentPageLoad = true, instrumentNavigation = true } = options;\n\n return {\n ...integration,\n afterAllSetup(client) {\n integration.afterAllSetup(client);\n\n instrumentReactRouter(\n client,\n instrumentPageLoad,\n instrumentNavigation,\n history,\n 'reactrouter_v4',\n routes,\n matchPath,\n );\n },\n };\n}\n\n/**\n * A browser tracing integration that uses React Router v5 to instrument navigations.\n * Expects `history` (and optionally `routes` and `matchPath`) to be passed as options.\n */\nexport function reactRouterV5BrowserTracingIntegration(\n options: Parameters<typeof browserTracingIntegration>[0] & ReactRouterOptions,\n): Integration {\n const integration = browserTracingIntegration({\n ...options,\n instrumentPageLoad: false,\n instrumentNavigation: false,\n });\n\n const { history, routes, matchPath, instrumentPageLoad = true, instrumentNavigation = true } = options;\n\n return {\n ...integration,\n afterAllSetup(client) {\n integration.afterAllSetup(client);\n\n instrumentReactRouter(\n client,\n instrumentPageLoad,\n instrumentNavigation,\n history,\n 'reactrouter_v5',\n routes,\n matchPath,\n );\n },\n };\n}\n\nfunction instrumentReactRouter(\n client: Client,\n instrumentPageLoad: boolean,\n instrumentNavigation: boolean,\n history: RouterHistory,\n instrumentationName: string,\n allRoutes: RouteConfig[] = [],\n matchPath?: MatchPath,\n): void {\n function getInitPathName(): string | undefined {\n if (history && history.location) {\n return history.location.pathname;\n }\n\n if (WINDOW && WINDOW.location) {\n return WINDOW.location.pathname;\n }\n\n return undefined;\n }\n\n /**\n * Normalizes a transaction name. Returns the new name as well as the\n * source of the transaction.\n *\n * @param pathname The initial pathname we normalize\n */\n function normalizeTransactionName(pathname: string): [string, TransactionSource] {\n if (allRoutes.length === 0 || !matchPath) {\n return [pathname, 'url'];\n }\n\n const branches = matchRoutes(allRoutes, pathname, matchPath);\n for (const branch of branches) {\n if (branch.match.isExact) {\n return [branch.match.path, 'route'];\n }\n }\n\n return [pathname, 'url'];\n }\n\n if (instrumentPageLoad) {\n const initPathName = getInitPathName();\n if (initPathName) {\n const [name, source] = normalizeTransactionName(initPathName);\n startBrowserTracingPageLoadSpan(client, {\n name,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'pageload',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: `auto.pageload.react.${instrumentationName}`,\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,\n },\n });\n }\n }\n\n if (instrumentNavigation && history.listen) {\n history.listen((location, action) => {\n if (action && (action === 'PUSH' || action === 'POP')) {\n const [name, source] = normalizeTransactionName(location.pathname);\n startBrowserTracingNavigationSpan(client, {\n name,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: `auto.navigation.react.${instrumentationName}`,\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,\n },\n });\n }\n });\n }\n}\n\n/**\n * Matches a set of routes to a pathname\n * Based on implementation from\n */\nfunction matchRoutes(\n routes: RouteConfig[],\n pathname: string,\n matchPath: MatchPath,\n branch: Array<{ route: RouteConfig; match: Match }> = [],\n): Array<{ route: RouteConfig; match: Match }> {\n routes.some(route => {\n const match = route.path\n ? matchPath(pathname, route)\n : branch.length\n ? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n branch[branch.length - 1]!.match // use parent match\n : computeRootMatch(pathname); // use default \"root\" match\n\n if (match) {\n branch.push({ route, match });\n\n if (route.routes) {\n matchRoutes(route.routes, pathname, matchPath, branch);\n }\n }\n\n return !!match;\n });\n\n return branch;\n}\n\nfunction computeRootMatch(pathname: string): Match {\n return { path: '/', url: '/', params: {}, isExact: pathname === '/' };\n}\n\n/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */\nexport function withSentryRouting<P extends Record<string, any>, R extends React.ComponentType<P>>(Route: R): R {\n const componentDisplayName = (Route as any).displayName || (Route as any).name;\n\n const WrappedRoute: React.FC<P> = (props: P) => {\n if (props && props.computedMatch && props.computedMatch.isExact) {\n const route = props.computedMatch.path;\n const activeRootSpan = getActiveRootSpan();\n\n getCurrentScope().setTransactionName(route);\n\n if (activeRootSpan) {\n activeRootSpan.updateName(route);\n activeRootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'route');\n }\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 // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/13dc4235c069e25fe7ee16e11f529d909f9f3ff8/types/react-router/index.d.ts#L154-L164\n return <Route {...props} />;\n };\n\n WrappedRoute.displayName = `sentryRoute(${componentDisplayName})`;\n hoistNonReactStatics(WrappedRoute, Route);\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 // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/13dc4235c069e25fe7ee16e11f529d909f9f3ff8/types/react-router/index.d.ts#L154-L164\n return WrappedRoute;\n}\n/* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */\n\nfunction getActiveRootSpan(): Span | undefined {\n const span = getActiveSpan();\n const rootSpan = span && getRootSpan(span);\n\n if (!rootSpan) {\n return undefined;\n }\n\n const op = spanToJSON(rootSpan).op;\n\n // Only use this root span if it is a pageload or navigation span\n return op === 'navigation' || op === 'pageload' ? rootSpan : undefined;\n}\n"],"names":["_jsx"],"mappings":";;;;;;AAqBA;AACA;;AAwBA;AACA;AACA;AACA;AACO,SAAS,sCAAsC;AACtD,EAAE,OAAO;AACT,EAAe;AACf,EAAE,MAAM,WAAA,GAAc,yBAAyB,CAAC;AAChD,IAAI,GAAG,OAAO;AACd,IAAI,kBAAkB,EAAE,KAAK;AAC7B,IAAI,oBAAoB,EAAE,KAAK;AAC/B,GAAG,CAAC,CAAA;AACJ;AACA,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,kBAAmB,GAAE,IAAI,EAAE,oBAAA,GAAuB,IAAK,EAAA,GAAI,OAAO,CAAA;AACxG;AACA,EAAE,OAAO;AACT,IAAI,GAAG,WAAW;AAClB,IAAI,aAAa,CAAC,MAAM,EAAE;AAC1B,MAAM,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;AACvC;AACA,MAAM,qB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AA,CAAA,CAAA,CAAA;AACA,EAAA,oBAAA,CAAA,YAAA,EAAA,KAAA,CAAA,CAAA;AACA;AACA;AACA;AACA,EAAA,OAAA,YAAA,CAAA;AACA,CAAA;AACA;AACA;AACA,SAAA,iBAAA,GAAA;AACA,EAAA,MAAA,IAAA,GAAA,aAAA,EAAA,CAAA;AACA,EAAA,MAAA,QAAA,GAAA,IAAA,IAAA,WAAA,CAAA,IAAA,CAAA,CAAA;AACA;AACA,EAAA,IAAA,CAAA,QAAA,EAAA;AACA,IAAA,OAAA,SAAA,CAAA;AACA,GAAA;AACA;AACA,EAAA,MAAA,EAAA,GAAA,UAAA,CAAA,QAAA,CAAA,CAAA,EAAA,CAAA;AACA;AACA;AACA,EAAA,OAAA,EAAA,KAAA,YAAA,IAAA,EAAA,KAAA,UAAA,GAAA,QAAA,GAAA,SAAA,CAAA;AACA;;;;"}
|
package/esm/reactrouterv3.js
CHANGED
|
@@ -110,6 +110,7 @@ function getRouteStringFromRoutes(routes) {
|
|
|
110
110
|
|
|
111
111
|
let index = -1;
|
|
112
112
|
for (let x = routesWithPaths.length - 1; x >= 0; x--) {
|
|
113
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
113
114
|
const route = routesWithPaths[x];
|
|
114
115
|
if (route.path && route.path.startsWith('/')) {
|
|
115
116
|
index = x;
|
package/esm/reactrouterv3.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactrouterv3.js","sources":["../../src/reactrouterv3.ts"],"sourcesContent":["import {\n WINDOW,\n browserTracingIntegration,\n startBrowserTracingNavigationSpan,\n startBrowserTracingPageLoadSpan,\n} from '@sentry/browser';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n} from '@sentry/core';\nimport type { Integration, TransactionSource } from '@sentry/types';\n\nimport type { Location } from './types';\n\n// Many of the types below had to be mocked out to prevent typescript issues\n// these types are required for correct functionality.\n\ntype HistoryV3 = {\n location?: Location;\n listen?(cb: (location: Location) => void): void;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n} & Record<string, any>;\n\nexport type Route = { path?: string; childRoutes?: Route[] };\n\nexport type Match = (\n props: { location: Location; routes: Route[] },\n cb: (error?: Error, _redirectLocation?: Location, renderProps?: { routes?: Route[] }) => void,\n) => void;\n\ntype ReactRouterV3TransactionSource = Extract<TransactionSource, 'url' | 'route'>;\n\ninterface ReactRouterOptions {\n history: HistoryV3;\n routes: Route[];\n match: Match;\n}\n\n/**\n * A browser tracing integration that uses React Router v3 to instrument navigations.\n * Expects `history` (and optionally `routes` and `matchPath`) to be passed as options.\n */\nexport function reactRouterV3BrowserTracingIntegration(\n options: Parameters<typeof browserTracingIntegration>[0] & ReactRouterOptions,\n): Integration {\n const integration = browserTracingIntegration({\n ...options,\n instrumentPageLoad: false,\n instrumentNavigation: false,\n });\n\n const { history, routes, match, instrumentPageLoad = true, instrumentNavigation = true } = options;\n\n return {\n ...integration,\n afterAllSetup(client) {\n integration.afterAllSetup(client);\n\n if (instrumentPageLoad && WINDOW && WINDOW.location) {\n normalizeTransactionName(\n routes,\n WINDOW.location as unknown as Location,\n match,\n (localName: string, source: ReactRouterV3TransactionSource = 'url') => {\n startBrowserTracingPageLoadSpan(client, {\n name: localName,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'pageload',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.pageload.react.reactrouter_v3',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,\n },\n });\n },\n );\n }\n\n if (instrumentNavigation && history.listen) {\n history.listen(location => {\n if (location.action === 'PUSH' || location.action === 'POP') {\n normalizeTransactionName(\n routes,\n location,\n match,\n (localName: string, source: TransactionSource = 'url') => {\n startBrowserTracingNavigationSpan(client, {\n name: localName,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.react.reactrouter_v3',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,\n },\n });\n },\n );\n }\n });\n }\n },\n };\n}\n\n/**\n * Normalize transaction names using `Router.match`\n */\nfunction normalizeTransactionName(\n appRoutes: Route[],\n location: Location,\n match: Match,\n callback: (pathname: string, source?: ReactRouterV3TransactionSource) => void,\n): void {\n let name = location.pathname;\n match(\n {\n location,\n routes: appRoutes,\n },\n (error, _redirectLocation, renderProps) => {\n if (error || !renderProps) {\n return callback(name);\n }\n\n const routePath = getRouteStringFromRoutes(renderProps.routes || []);\n if (routePath.length === 0 || routePath === '/*') {\n return callback(name);\n }\n\n name = routePath;\n return callback(name, 'route');\n },\n );\n}\n\n/**\n * Generate route name from array of routes\n */\nfunction getRouteStringFromRoutes(routes: Route[]): string {\n if (!Array.isArray(routes) || routes.length === 0) {\n return '';\n }\n\n const routesWithPaths: Route[] = routes.filter((route: Route) => !!route.path);\n\n let index = -1;\n for (let x = routesWithPaths.length - 1; x >= 0; x--) {\n const route = routesWithPaths[x]
|
|
1
|
+
{"version":3,"file":"reactrouterv3.js","sources":["../../src/reactrouterv3.ts"],"sourcesContent":["import {\n WINDOW,\n browserTracingIntegration,\n startBrowserTracingNavigationSpan,\n startBrowserTracingPageLoadSpan,\n} from '@sentry/browser';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n} from '@sentry/core';\nimport type { Integration, TransactionSource } from '@sentry/types';\n\nimport type { Location } from './types';\n\n// Many of the types below had to be mocked out to prevent typescript issues\n// these types are required for correct functionality.\n\ntype HistoryV3 = {\n location?: Location;\n listen?(cb: (location: Location) => void): void;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n} & Record<string, any>;\n\nexport type Route = { path?: string; childRoutes?: Route[] };\n\nexport type Match = (\n props: { location: Location; routes: Route[] },\n cb: (error?: Error, _redirectLocation?: Location, renderProps?: { routes?: Route[] }) => void,\n) => void;\n\ntype ReactRouterV3TransactionSource = Extract<TransactionSource, 'url' | 'route'>;\n\ninterface ReactRouterOptions {\n history: HistoryV3;\n routes: Route[];\n match: Match;\n}\n\n/**\n * A browser tracing integration that uses React Router v3 to instrument navigations.\n * Expects `history` (and optionally `routes` and `matchPath`) to be passed as options.\n */\nexport function reactRouterV3BrowserTracingIntegration(\n options: Parameters<typeof browserTracingIntegration>[0] & ReactRouterOptions,\n): Integration {\n const integration = browserTracingIntegration({\n ...options,\n instrumentPageLoad: false,\n instrumentNavigation: false,\n });\n\n const { history, routes, match, instrumentPageLoad = true, instrumentNavigation = true } = options;\n\n return {\n ...integration,\n afterAllSetup(client) {\n integration.afterAllSetup(client);\n\n if (instrumentPageLoad && WINDOW && WINDOW.location) {\n normalizeTransactionName(\n routes,\n WINDOW.location as unknown as Location,\n match,\n (localName: string, source: ReactRouterV3TransactionSource = 'url') => {\n startBrowserTracingPageLoadSpan(client, {\n name: localName,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'pageload',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.pageload.react.reactrouter_v3',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,\n },\n });\n },\n );\n }\n\n if (instrumentNavigation && history.listen) {\n history.listen(location => {\n if (location.action === 'PUSH' || location.action === 'POP') {\n normalizeTransactionName(\n routes,\n location,\n match,\n (localName: string, source: TransactionSource = 'url') => {\n startBrowserTracingNavigationSpan(client, {\n name: localName,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.react.reactrouter_v3',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,\n },\n });\n },\n );\n }\n });\n }\n },\n };\n}\n\n/**\n * Normalize transaction names using `Router.match`\n */\nfunction normalizeTransactionName(\n appRoutes: Route[],\n location: Location,\n match: Match,\n callback: (pathname: string, source?: ReactRouterV3TransactionSource) => void,\n): void {\n let name = location.pathname;\n match(\n {\n location,\n routes: appRoutes,\n },\n (error, _redirectLocation, renderProps) => {\n if (error || !renderProps) {\n return callback(name);\n }\n\n const routePath = getRouteStringFromRoutes(renderProps.routes || []);\n if (routePath.length === 0 || routePath === '/*') {\n return callback(name);\n }\n\n name = routePath;\n return callback(name, 'route');\n },\n );\n}\n\n/**\n * Generate route name from array of routes\n */\nfunction getRouteStringFromRoutes(routes: Route[]): string {\n if (!Array.isArray(routes) || routes.length === 0) {\n return '';\n }\n\n const routesWithPaths: Route[] = routes.filter((route: Route) => !!route.path);\n\n let index = -1;\n for (let x = routesWithPaths.length - 1; x >= 0; x--) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const route = routesWithPaths[x]!;\n if (route.path && route.path.startsWith('/')) {\n index = x;\n break;\n }\n }\n\n return routesWithPaths\n .slice(index)\n .filter(({ path }) => !!path)\n .map(({ path }) => path)\n .join('');\n}\n"],"names":[],"mappings":";;;AAeA;AACA;;AAuBA;AACA;AACA;AACA;AACO,SAAS,sCAAsC;AACtD,EAAE,OAAO;AACT,EAAe;AACf,EAAE,MAAM,WAAA,GAAc,yBAAyB,CAAC;AAChD,IAAI,GAAG,OAAO;AACd,IAAI,kBAAkB,EAAE,KAAK;AAC7B,IAAI,oBAAoB,EAAE,KAAK;AAC/B,GAAG,CAAC,CAAA;AACJ;AACA,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAmB,GAAE,IAAI,EAAE,oBAAA,GAAuB,IAAK,EAAA,GAAI,OAAO,CAAA;AACpG;AACA,EAAE,OAAO;AACT,IAAI,GAAG,WAAW;AAClB,IAAI,aAAa,CAAC,MAAM,EAAE;AAC1B,MAAM,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA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CAAC,EAAE,CAAE,IAAG,CAAC,EAAE,CAAC,EAAE,EAAE;AACxD;AACA,IAAI,MAAM,KAAM,GAAE,eAAe,CAAC,CAAC,CAAC,CAAA;AACpC,IAAI,IAAI,KAAK,CAAC,QAAQ,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;AAClD,MAAM,KAAA,GAAQ,CAAC,CAAA;AACf,MAAM,MAAK;AACX,KAAI;AACJ,GAAE;AACF;AACA,EAAE,OAAO,eAAA;AACT,KAAK,KAAK,CAAC,KAAK,CAAA;AAChB,KAAK,MAAM,CAAC,CAAC,EAAE,IAAK,EAAC,KAAK,CAAC,CAAC,IAAI,CAAA;AAChC,KAAK,GAAG,CAAC,CAAC,EAAE,IAAK,EAAC,KAAK,IAAI,CAAA;AAC3B,KAAK,IAAI,CAAC,EAAE,CAAC,CAAA;AACb;;;;"}
|
package/esm/reactrouterv6.js
CHANGED
|
@@ -110,9 +110,7 @@ function getNormalizedName(
|
|
|
110
110
|
|
|
111
111
|
let pathBuilder = '';
|
|
112
112
|
if (branches) {
|
|
113
|
-
|
|
114
|
-
for (let x = 0; x < branches.length; x++) {
|
|
115
|
-
const branch = branches[x];
|
|
113
|
+
for (const branch of branches) {
|
|
116
114
|
const route = branch.route;
|
|
117
115
|
if (route) {
|
|
118
116
|
// Early return if index route
|
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 {\n WINDOW,\n browserTracingIntegration,\n startBrowserTracingNavigationSpan,\n startBrowserTracingPageLoadSpan,\n} from '@sentry/browser';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n getActiveSpan,\n getClient,\n getCurrentScope,\n getRootSpan,\n spanToJSON,\n} from '@sentry/core';\nimport type { Client, Integration, Span, TransactionSource } from '@sentry/types';\nimport { getNumberOfUrlSegments, logger } from '@sentry/utils';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\n\nimport { DEBUG_BUILD } from './debug-build';\nimport type {\n Action,\n AgnosticDataRouteMatch,\n CreateRouterFunction,\n CreateRoutesFromChildren,\n Location,\n MatchRoutes,\n RouteMatch,\n RouteObject,\n Router,\n RouterState,\n UseEffect,\n UseLocation,\n UseNavigationType,\n UseRoutes,\n} from './types';\n\nlet _useEffect: UseEffect;\nlet _useLocation: UseLocation;\nlet _useNavigationType: UseNavigationType;\nlet _createRoutesFromChildren: CreateRoutesFromChildren;\nlet _matchRoutes: MatchRoutes;\nlet _stripBasename: boolean = false;\n\nconst CLIENTS_WITH_INSTRUMENT_NAVIGATION = new WeakSet<Client>();\n\ninterface ReactRouterOptions {\n useEffect: UseEffect;\n useLocation: UseLocation;\n useNavigationType: UseNavigationType;\n createRoutesFromChildren: CreateRoutesFromChildren;\n matchRoutes: MatchRoutes;\n stripBasename?: boolean;\n}\n\n/**\n * A browser tracing integration that uses React Router v6 to instrument navigations.\n * Expects `useEffect`, `useLocation`, `useNavigationType`, `createRoutesFromChildren` and `matchRoutes` to be passed as options.\n */\nexport function reactRouterV6BrowserTracingIntegration(\n options: Parameters<typeof browserTracingIntegration>[0] & ReactRouterOptions,\n): Integration {\n const integration = browserTracingIntegration({\n ...options,\n instrumentPageLoad: false,\n instrumentNavigation: false,\n });\n\n const {\n useEffect,\n useLocation,\n useNavigationType,\n createRoutesFromChildren,\n matchRoutes,\n stripBasename,\n instrumentPageLoad = true,\n instrumentNavigation = true,\n } = options;\n\n return {\n ...integration,\n setup() {\n _useEffect = useEffect;\n _useLocation = useLocation;\n _useNavigationType = useNavigationType;\n _matchRoutes = matchRoutes;\n _createRoutesFromChildren = createRoutesFromChildren;\n _stripBasename = stripBasename || false;\n },\n afterAllSetup(client) {\n integration.afterAllSetup(client);\n\n const initPathName = WINDOW && WINDOW.location && WINDOW.location.pathname;\n if (instrumentPageLoad && initPathName) {\n startBrowserTracingPageLoadSpan(client, {\n name: initPathName,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'pageload',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.pageload.react.reactrouter_v6',\n },\n });\n }\n\n if (instrumentNavigation) {\n CLIENTS_WITH_INSTRUMENT_NAVIGATION.add(client);\n }\n },\n };\n}\n\n/**\n * Strip the basename from a pathname if exists.\n *\n * Vendored and modified from `react-router`\n * https://github.com/remix-run/react-router/blob/462bb712156a3f739d6139a0f14810b76b002df6/packages/router/utils.ts#L1038\n */\nfunction stripBasenameFromPathname(pathname: string, basename: string): string {\n if (!basename || basename === '/') {\n return pathname;\n }\n\n if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) {\n return pathname;\n }\n\n // We want to leave trailing slash behavior in the user's control, so if they\n // specify a basename with a trailing slash, we should support it\n const startIndex = basename.endsWith('/') ? basename.length - 1 : basename.length;\n const nextChar = pathname.charAt(startIndex);\n if (nextChar && nextChar !== '/') {\n // pathname does not start with basename/\n return pathname;\n }\n\n return pathname.slice(startIndex) || '/';\n}\n\nfunction getNormalizedName(\n routes: RouteObject[],\n location: Location,\n branches: RouteMatch[],\n basename: string = '',\n): [string, TransactionSource] {\n if (!routes || routes.length === 0) {\n return [_stripBasename ? stripBasenameFromPathname(location.pathname, basename) : location.pathname, 'url'];\n }\n\n let pathBuilder = '';\n if (branches) {\n // eslint-disable-next-line @typescript-eslint/prefer-for-of\n for (let x = 0; x < branches.length; x++) {\n const branch = branches[x];\n const route = branch.route;\n if (route) {\n // Early return if index route\n if (route.index) {\n return [_stripBasename ? stripBasenameFromPathname(branch.pathname, basename) : branch.pathname, 'route'];\n }\n\n const path = route.path;\n if (path) {\n const newPath = path[0] === '/' || pathBuilder[pathBuilder.length - 1] === '/' ? path : `/${path}`;\n pathBuilder += newPath;\n\n if (basename + branch.pathname === location.pathname) {\n if (\n // If the route defined on the element is something like\n // <Route path=\"/stores/:storeId/products/:productId\" element={<div>Product</div>} />\n // We should check against the branch.pathname for the number of / seperators\n getNumberOfUrlSegments(pathBuilder) !== getNumberOfUrlSegments(branch.pathname) &&\n // We should not count wildcard operators in the url segments calculation\n pathBuilder.slice(-2) !== '/*'\n ) {\n return [(_stripBasename ? '' : basename) + newPath, 'route'];\n }\n return [(_stripBasename ? '' : basename) + pathBuilder, 'route'];\n }\n }\n }\n }\n }\n\n return [_stripBasename ? stripBasenameFromPathname(location.pathname, basename) : location.pathname, 'url'];\n}\n\nfunction updatePageloadTransaction(\n activeRootSpan: Span | undefined,\n location: Location,\n routes: RouteObject[],\n matches?: AgnosticDataRouteMatch,\n basename?: string,\n): void {\n const branches = Array.isArray(matches)\n ? matches\n : (_matchRoutes(routes, location, basename) as unknown as RouteMatch[]);\n\n if (branches) {\n const [name, source] = getNormalizedName(routes, location, branches, basename);\n\n getCurrentScope().setTransactionName(name);\n\n if (activeRootSpan) {\n activeRootSpan.updateName(name);\n activeRootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, source);\n }\n }\n}\n\nfunction handleNavigation(\n location: Location,\n routes: RouteObject[],\n navigationType: Action,\n matches?: AgnosticDataRouteMatch,\n basename?: string,\n): void {\n const branches = Array.isArray(matches) ? matches : _matchRoutes(routes, location, basename);\n\n const client = getClient();\n if (!client || !CLIENTS_WITH_INSTRUMENT_NAVIGATION.has(client)) {\n return;\n }\n\n if ((navigationType === 'PUSH' || navigationType === 'POP') && branches) {\n const [name, source] = getNormalizedName(routes, location, branches, basename);\n\n startBrowserTracingNavigationSpan(client, {\n name,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.react.reactrouter_v6',\n },\n });\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function withSentryReactRouterV6Routing<P extends Record<string, any>, R extends React.FC<P>>(Routes: R): R {\n if (!_useEffect || !_useLocation || !_useNavigationType || !_createRoutesFromChildren || !_matchRoutes) {\n DEBUG_BUILD &&\n logger.warn(`reactRouterV6Instrumentation was unable to wrap Routes because of one or more missing parameters.\n useEffect: ${_useEffect}. useLocation: ${_useLocation}. useNavigationType: ${_useNavigationType}.\n createRoutesFromChildren: ${_createRoutesFromChildren}. matchRoutes: ${_matchRoutes}.`);\n\n return Routes;\n }\n\n let isMountRenderPass: boolean = true;\n\n const SentryRoutes: React.FC<P> = (props: P) => {\n const location = _useLocation();\n const navigationType = _useNavigationType();\n\n _useEffect(\n () => {\n const routes = _createRoutesFromChildren(props.children) as RouteObject[];\n\n if (isMountRenderPass) {\n updatePageloadTransaction(getActiveRootSpan(), location, routes);\n isMountRenderPass = false;\n } else {\n handleNavigation(location, routes, navigationType);\n }\n },\n // `props.children` is purpusely not included in the dependency array, because we do not want to re-run this effect\n // when the children change. We only want to start transactions when the location or navigation type change.\n [location, navigationType],\n );\n\n // @ts-expect-error Setting more specific React Component typing for `R` generic above\n // will break advanced type inference done by react router params\n return <Routes {...props} />;\n };\n\n hoistNonReactStatics(SentryRoutes, Routes);\n\n // @ts-expect-error Setting more specific React Component typing for `R` generic above\n // will break advanced type inference done by react router params\n return SentryRoutes;\n}\n\nexport function wrapUseRoutes(origUseRoutes: UseRoutes): UseRoutes {\n if (!_useEffect || !_useLocation || !_useNavigationType || !_matchRoutes) {\n DEBUG_BUILD &&\n logger.warn(\n 'reactRouterV6Instrumentation was unable to wrap `useRoutes` because of one or more missing parameters.',\n );\n\n return origUseRoutes;\n }\n\n let isMountRenderPass: boolean = true;\n\n const SentryRoutes: React.FC<{\n children?: React.ReactNode;\n routes: RouteObject[];\n locationArg?: Partial<Location> | string;\n }> = (props: { children?: React.ReactNode; routes: RouteObject[]; locationArg?: Partial<Location> | string }) => {\n const { routes, locationArg } = props;\n\n const Routes = origUseRoutes(routes, locationArg);\n\n const location = _useLocation();\n const navigationType = _useNavigationType();\n\n // A value with stable identity to either pick `locationArg` if available or `location` if not\n const stableLocationParam =\n typeof locationArg === 'string' || (locationArg && locationArg.pathname)\n ? (locationArg as { pathname: string })\n : location;\n\n _useEffect(() => {\n const normalizedLocation =\n typeof stableLocationParam === 'string' ? { pathname: stableLocationParam } : stableLocationParam;\n\n if (isMountRenderPass) {\n updatePageloadTransaction(getActiveRootSpan(), normalizedLocation, routes);\n isMountRenderPass = false;\n } else {\n handleNavigation(normalizedLocation, routes, navigationType);\n }\n }, [navigationType, stableLocationParam]);\n\n return Routes;\n };\n\n // eslint-disable-next-line react/display-name\n return (routes: RouteObject[], locationArg?: Partial<Location> | string): React.ReactElement | null => {\n return <SentryRoutes routes={routes} locationArg={locationArg} />;\n };\n}\n\nexport function wrapCreateBrowserRouter<\n TState extends RouterState = RouterState,\n TRouter extends Router<TState> = Router<TState>,\n>(createRouterFunction: CreateRouterFunction<TState, TRouter>): CreateRouterFunction<TState, TRouter> {\n if (!_useEffect || !_useLocation || !_useNavigationType || !_matchRoutes) {\n DEBUG_BUILD &&\n logger.warn(\n 'reactRouterV6Instrumentation was unable to wrap the `createRouter` function because of one or more missing parameters.',\n );\n\n return createRouterFunction;\n }\n\n // `opts` for createBrowserHistory and createMemoryHistory are different, but also not relevant for us at the moment.\n // `basename` is the only option that is relevant for us, and it is the same for all.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return function (routes: RouteObject[], opts?: Record<string, any> & { basename?: string }): TRouter {\n const router = createRouterFunction(routes, opts);\n const basename = opts && opts.basename;\n\n const activeRootSpan = getActiveRootSpan();\n\n // The initial load ends when `createBrowserRouter` is called.\n // This is the earliest convenient time to update the transaction name.\n // Callbacks to `router.subscribe` are not called for the initial load.\n if (router.state.historyAction === 'POP' && activeRootSpan) {\n updatePageloadTransaction(activeRootSpan, router.state.location, routes, undefined, basename);\n }\n\n router.subscribe((state: RouterState) => {\n const location = state.location;\n if (state.historyAction === 'PUSH' || state.historyAction === 'POP') {\n handleNavigation(location, routes, state.historyAction, undefined, basename);\n }\n });\n\n return router;\n };\n}\n\nfunction getActiveRootSpan(): Span | undefined {\n const span = getActiveSpan();\n const rootSpan = span ? getRootSpan(span) : undefined;\n\n if (!rootSpan) {\n return undefined;\n }\n\n const op = spanToJSON(rootSpan).op;\n\n // Only use this root span if it is a pageload or navigation span\n return op === 'navigation' || op === 'pageload' ? rootSpan : undefined;\n}\n"],"names":["_jsx"],"mappings":";;;;;;;;AA0CA,IAAI,UAAU,CAAA;AACd,IAAI,YAAY,CAAA;AAChB,IAAI,kBAAkB,CAAA;AACtB,IAAI,yBAAyB,CAAA;AAC7B,IAAI,YAAY,CAAA;AAChB,IAAI,cAAc,GAAY,KAAK,CAAA;AACnC;AACA,MAAM,kCAAmC,GAAE,IAAI,OAAO,EAAU,CAAA;;AAWhE;AACA;AACA;AACA;AACO,SAAS,sCAAsC;AACtD,EAAE,OAAO;AACT,EAAe;AACf,EAAE,MAAM,WAAA,GAAc,yBAAyB,CAAC;AAChD,IAAI,GAAG,OAAO;AACd,IAAI,kBAAkB,EAAE,KAAK;AAC7B,IAAI,oBAAoB,EAAE,KAAK;AAC/B,GAAG,CAAC,CAAA;AACJ;AACA,EAAE,MAAM;AACR,IAAI,SAAS;AACb,IAAI,WAAW;AACf,IAAI,iBAAiB;AACrB,IAAI,wBAAwB;AAC5B,IAAI,WAAW;AACf,IAAI,aAAa;AACjB,IAAI,kBAAA,GAAqB,IAAI;AAC7B,IAAI,oBAAA,GAAuB,IAAI;AAC/B,GAAE,GAAI,OAAO,CAAA;AACb;AACA,EAAE,OAAO;AACT,IAAI,GAAG,WAAW;AAClB,IAAI,KAAK,GAAG;AACZ,MAAM,UAAA,GAAa,SAAS,CAAA;AAC5B,MAAM,YAA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AAA,CAAA,aAAA,KAAA,KAAA,EAAA;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,CAAA;AACA;AACA,SAAA,iBAAA,GAAA;AACA,EAAA,MAAA,IAAA,GAAA,aAAA,EAAA,CAAA;AACA,EAAA,MAAA,QAAA,GAAA,IAAA,GAAA,WAAA,CAAA,IAAA,CAAA,GAAA,SAAA,CAAA;AACA;AACA,EAAA,IAAA,CAAA,QAAA,EAAA;AACA,IAAA,OAAA,SAAA,CAAA;AACA,GAAA;AACA;AACA,EAAA,MAAA,EAAA,GAAA,UAAA,CAAA,QAAA,CAAA,CAAA,EAAA,CAAA;AACA;AACA;AACA,EAAA,OAAA,EAAA,KAAA,YAAA,IAAA,EAAA,KAAA,UAAA,GAAA,QAAA,GAAA,SAAA,CAAA;AACA;;;;"}
|
|
1
|
+
{"version":3,"file":"reactrouterv6.js","sources":["../../src/reactrouterv6.tsx"],"sourcesContent":["// Inspired from Donnie McNeal's solution:\n// https://gist.github.com/wontondon/e8c4bdf2888875e4c755712e99279536\n\nimport {\n WINDOW,\n browserTracingIntegration,\n startBrowserTracingNavigationSpan,\n startBrowserTracingPageLoadSpan,\n} from '@sentry/browser';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n getActiveSpan,\n getClient,\n getCurrentScope,\n getRootSpan,\n spanToJSON,\n} from '@sentry/core';\nimport type { Client, Integration, Span, TransactionSource } from '@sentry/types';\nimport { getNumberOfUrlSegments, logger } from '@sentry/utils';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\n\nimport { DEBUG_BUILD } from './debug-build';\nimport type {\n Action,\n AgnosticDataRouteMatch,\n CreateRouterFunction,\n CreateRoutesFromChildren,\n Location,\n MatchRoutes,\n RouteMatch,\n RouteObject,\n Router,\n RouterState,\n UseEffect,\n UseLocation,\n UseNavigationType,\n UseRoutes,\n} from './types';\n\nlet _useEffect: UseEffect;\nlet _useLocation: UseLocation;\nlet _useNavigationType: UseNavigationType;\nlet _createRoutesFromChildren: CreateRoutesFromChildren;\nlet _matchRoutes: MatchRoutes;\nlet _stripBasename: boolean = false;\n\nconst CLIENTS_WITH_INSTRUMENT_NAVIGATION = new WeakSet<Client>();\n\ninterface ReactRouterOptions {\n useEffect: UseEffect;\n useLocation: UseLocation;\n useNavigationType: UseNavigationType;\n createRoutesFromChildren: CreateRoutesFromChildren;\n matchRoutes: MatchRoutes;\n stripBasename?: boolean;\n}\n\n/**\n * A browser tracing integration that uses React Router v6 to instrument navigations.\n * Expects `useEffect`, `useLocation`, `useNavigationType`, `createRoutesFromChildren` and `matchRoutes` to be passed as options.\n */\nexport function reactRouterV6BrowserTracingIntegration(\n options: Parameters<typeof browserTracingIntegration>[0] & ReactRouterOptions,\n): Integration {\n const integration = browserTracingIntegration({\n ...options,\n instrumentPageLoad: false,\n instrumentNavigation: false,\n });\n\n const {\n useEffect,\n useLocation,\n useNavigationType,\n createRoutesFromChildren,\n matchRoutes,\n stripBasename,\n instrumentPageLoad = true,\n instrumentNavigation = true,\n } = options;\n\n return {\n ...integration,\n setup() {\n _useEffect = useEffect;\n _useLocation = useLocation;\n _useNavigationType = useNavigationType;\n _matchRoutes = matchRoutes;\n _createRoutesFromChildren = createRoutesFromChildren;\n _stripBasename = stripBasename || false;\n },\n afterAllSetup(client) {\n integration.afterAllSetup(client);\n\n const initPathName = WINDOW && WINDOW.location && WINDOW.location.pathname;\n if (instrumentPageLoad && initPathName) {\n startBrowserTracingPageLoadSpan(client, {\n name: initPathName,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'pageload',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.pageload.react.reactrouter_v6',\n },\n });\n }\n\n if (instrumentNavigation) {\n CLIENTS_WITH_INSTRUMENT_NAVIGATION.add(client);\n }\n },\n };\n}\n\n/**\n * Strip the basename from a pathname if exists.\n *\n * Vendored and modified from `react-router`\n * https://github.com/remix-run/react-router/blob/462bb712156a3f739d6139a0f14810b76b002df6/packages/router/utils.ts#L1038\n */\nfunction stripBasenameFromPathname(pathname: string, basename: string): string {\n if (!basename || basename === '/') {\n return pathname;\n }\n\n if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) {\n return pathname;\n }\n\n // We want to leave trailing slash behavior in the user's control, so if they\n // specify a basename with a trailing slash, we should support it\n const startIndex = basename.endsWith('/') ? basename.length - 1 : basename.length;\n const nextChar = pathname.charAt(startIndex);\n if (nextChar && nextChar !== '/') {\n // pathname does not start with basename/\n return pathname;\n }\n\n return pathname.slice(startIndex) || '/';\n}\n\nfunction getNormalizedName(\n routes: RouteObject[],\n location: Location,\n branches: RouteMatch[],\n basename: string = '',\n): [string, TransactionSource] {\n if (!routes || routes.length === 0) {\n return [_stripBasename ? stripBasenameFromPathname(location.pathname, basename) : location.pathname, 'url'];\n }\n\n let pathBuilder = '';\n if (branches) {\n for (const branch of branches) {\n const route = branch.route;\n if (route) {\n // Early return if index route\n if (route.index) {\n return [_stripBasename ? stripBasenameFromPathname(branch.pathname, basename) : branch.pathname, 'route'];\n }\n\n const path = route.path;\n if (path) {\n const newPath = path[0] === '/' || pathBuilder[pathBuilder.length - 1] === '/' ? path : `/${path}`;\n pathBuilder += newPath;\n\n if (basename + branch.pathname === location.pathname) {\n if (\n // If the route defined on the element is something like\n // <Route path=\"/stores/:storeId/products/:productId\" element={<div>Product</div>} />\n // We should check against the branch.pathname for the number of / seperators\n getNumberOfUrlSegments(pathBuilder) !== getNumberOfUrlSegments(branch.pathname) &&\n // We should not count wildcard operators in the url segments calculation\n pathBuilder.slice(-2) !== '/*'\n ) {\n return [(_stripBasename ? '' : basename) + newPath, 'route'];\n }\n return [(_stripBasename ? '' : basename) + pathBuilder, 'route'];\n }\n }\n }\n }\n }\n\n return [_stripBasename ? stripBasenameFromPathname(location.pathname, basename) : location.pathname, 'url'];\n}\n\nfunction updatePageloadTransaction(\n activeRootSpan: Span | undefined,\n location: Location,\n routes: RouteObject[],\n matches?: AgnosticDataRouteMatch,\n basename?: string,\n): void {\n const branches = Array.isArray(matches)\n ? matches\n : (_matchRoutes(routes, location, basename) as unknown as RouteMatch[]);\n\n if (branches) {\n const [name, source] = getNormalizedName(routes, location, branches, basename);\n\n getCurrentScope().setTransactionName(name);\n\n if (activeRootSpan) {\n activeRootSpan.updateName(name);\n activeRootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, source);\n }\n }\n}\n\nfunction handleNavigation(\n location: Location,\n routes: RouteObject[],\n navigationType: Action,\n matches?: AgnosticDataRouteMatch,\n basename?: string,\n): void {\n const branches = Array.isArray(matches) ? matches : _matchRoutes(routes, location, basename);\n\n const client = getClient();\n if (!client || !CLIENTS_WITH_INSTRUMENT_NAVIGATION.has(client)) {\n return;\n }\n\n if ((navigationType === 'PUSH' || navigationType === 'POP') && branches) {\n const [name, source] = getNormalizedName(routes, location, branches, basename);\n\n startBrowserTracingNavigationSpan(client, {\n name,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.react.reactrouter_v6',\n },\n });\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function withSentryReactRouterV6Routing<P extends Record<string, any>, R extends React.FC<P>>(Routes: R): R {\n if (!_useEffect || !_useLocation || !_useNavigationType || !_createRoutesFromChildren || !_matchRoutes) {\n DEBUG_BUILD &&\n logger.warn(`reactRouterV6Instrumentation was unable to wrap Routes because of one or more missing parameters.\n useEffect: ${_useEffect}. useLocation: ${_useLocation}. useNavigationType: ${_useNavigationType}.\n createRoutesFromChildren: ${_createRoutesFromChildren}. matchRoutes: ${_matchRoutes}.`);\n\n return Routes;\n }\n\n let isMountRenderPass: boolean = true;\n\n const SentryRoutes: React.FC<P> = (props: P) => {\n const location = _useLocation();\n const navigationType = _useNavigationType();\n\n _useEffect(\n () => {\n const routes = _createRoutesFromChildren(props.children) as RouteObject[];\n\n if (isMountRenderPass) {\n updatePageloadTransaction(getActiveRootSpan(), location, routes);\n isMountRenderPass = false;\n } else {\n handleNavigation(location, routes, navigationType);\n }\n },\n // `props.children` is purpusely not included in the dependency array, because we do not want to re-run this effect\n // when the children change. We only want to start transactions when the location or navigation type change.\n [location, navigationType],\n );\n\n // @ts-expect-error Setting more specific React Component typing for `R` generic above\n // will break advanced type inference done by react router params\n return <Routes {...props} />;\n };\n\n hoistNonReactStatics(SentryRoutes, Routes);\n\n // @ts-expect-error Setting more specific React Component typing for `R` generic above\n // will break advanced type inference done by react router params\n return SentryRoutes;\n}\n\nexport function wrapUseRoutes(origUseRoutes: UseRoutes): UseRoutes {\n if (!_useEffect || !_useLocation || !_useNavigationType || !_matchRoutes) {\n DEBUG_BUILD &&\n logger.warn(\n 'reactRouterV6Instrumentation was unable to wrap `useRoutes` because of one or more missing parameters.',\n );\n\n return origUseRoutes;\n }\n\n let isMountRenderPass: boolean = true;\n\n const SentryRoutes: React.FC<{\n children?: React.ReactNode;\n routes: RouteObject[];\n locationArg?: Partial<Location> | string;\n }> = (props: { children?: React.ReactNode; routes: RouteObject[]; locationArg?: Partial<Location> | string }) => {\n const { routes, locationArg } = props;\n\n const Routes = origUseRoutes(routes, locationArg);\n\n const location = _useLocation();\n const navigationType = _useNavigationType();\n\n // A value with stable identity to either pick `locationArg` if available or `location` if not\n const stableLocationParam =\n typeof locationArg === 'string' || (locationArg && locationArg.pathname)\n ? (locationArg as { pathname: string })\n : location;\n\n _useEffect(() => {\n const normalizedLocation =\n typeof stableLocationParam === 'string' ? { pathname: stableLocationParam } : stableLocationParam;\n\n if (isMountRenderPass) {\n updatePageloadTransaction(getActiveRootSpan(), normalizedLocation, routes);\n isMountRenderPass = false;\n } else {\n handleNavigation(normalizedLocation, routes, navigationType);\n }\n }, [navigationType, stableLocationParam]);\n\n return Routes;\n };\n\n // eslint-disable-next-line react/display-name\n return (routes: RouteObject[], locationArg?: Partial<Location> | string): React.ReactElement | null => {\n return <SentryRoutes routes={routes} locationArg={locationArg} />;\n };\n}\n\nexport function wrapCreateBrowserRouter<\n TState extends RouterState = RouterState,\n TRouter extends Router<TState> = Router<TState>,\n>(createRouterFunction: CreateRouterFunction<TState, TRouter>): CreateRouterFunction<TState, TRouter> {\n if (!_useEffect || !_useLocation || !_useNavigationType || !_matchRoutes) {\n DEBUG_BUILD &&\n logger.warn(\n 'reactRouterV6Instrumentation was unable to wrap the `createRouter` function because of one or more missing parameters.',\n );\n\n return createRouterFunction;\n }\n\n // `opts` for createBrowserHistory and createMemoryHistory are different, but also not relevant for us at the moment.\n // `basename` is the only option that is relevant for us, and it is the same for all.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return function (routes: RouteObject[], opts?: Record<string, any> & { basename?: string }): TRouter {\n const router = createRouterFunction(routes, opts);\n const basename = opts && opts.basename;\n\n const activeRootSpan = getActiveRootSpan();\n\n // The initial load ends when `createBrowserRouter` is called.\n // This is the earliest convenient time to update the transaction name.\n // Callbacks to `router.subscribe` are not called for the initial load.\n if (router.state.historyAction === 'POP' && activeRootSpan) {\n updatePageloadTransaction(activeRootSpan, router.state.location, routes, undefined, basename);\n }\n\n router.subscribe((state: RouterState) => {\n const location = state.location;\n if (state.historyAction === 'PUSH' || state.historyAction === 'POP') {\n handleNavigation(location, routes, state.historyAction, undefined, basename);\n }\n });\n\n return router;\n };\n}\n\nfunction getActiveRootSpan(): Span | undefined {\n const span = getActiveSpan();\n const rootSpan = span ? getRootSpan(span) : undefined;\n\n if (!rootSpan) {\n return undefined;\n }\n\n const op = spanToJSON(rootSpan).op;\n\n // Only use this root span if it is a pageload or navigation span\n return op === 'navigation' || op === 'pageload' ? rootSpan : undefined;\n}\n"],"names":["_jsx"],"mappings":";;;;;;;;AA0CA,IAAI,UAAU,CAAA;AACd,IAAI,YAAY,CAAA;AAChB,IAAI,kBAAkB,CAAA;AACtB,IAAI,yBAAyB,CAAA;AAC7B,IAAI,YAAY,CAAA;AAChB,IAAI,cAAc,GAAY,KAAK,CAAA;AACnC;AACA,MAAM,kCAAmC,GAAE,IAAI,OAAO,EAAU,CAAA;;AAWhE;AACA;AACA;AACA;AACO,SAAS,sCAAsC;AACtD,EAAE,OAAO;AACT,EAAe;AACf,EAAE,MAAM,WAAA,GAAc,yBAAyB,CAAC;AAChD,IAAI,GAAG,OAAO;AACd,IAAI,kBAAkB,EAAE,KAAK;AAC7B,IAAI,oBAAoB,EAAE,KAAK;AAC/B,GAAG,CAAC,CAAA;AACJ;AACA,EAAE,MAAM;AACR,IAAI,SAAS;AACb,IAAI,WAAW;AACf,IAAI,iBAAiB;AACrB,IAAI,wBAAwB;AAC5B,IAAI,WAAW;AACf,IAAI,aAAa;AACjB,IAAI,kBAAA,GAAqB,IAAI;AAC7B,IAAI,oBAAA,GAAuB,IAAI;AAC/B,GAAE,GAAI,OAAO,CAAA;AACb;AACA,EAAE,OAAO;AACT,IAAI,GAAG,WAAW;AAClB,IAAI,KAAK,GAAG;AACZ,MAAM,UAAA,GAAa,SAAS,CAAA;AAC5B,MAAM,YAAA,GAAe,WAAW,CAAA;AAChC,MAAM,kBAAA,GAAqB,iBAAiB,CAAA;AAC5C,MAAM,YAAA,GAAe,WAAW,CAAA;AAChC,MAAM,yBAAA,GAA4B,wBAAwB,CAAA;AAC1D,MAAM,cAAe,GAAE,aAAc,IAAG,KAAK,CAAA;AAC7C,KAAK;AACL,IAAI,aAAa,CAAC,MAAM,EAAE;AAC1B,MAAM,WAAW,CAAC,aAAa,CAAC,MAAM,CAA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,IAAA,CAAA,QAAA,EAAA;AACA,IAAA,OAAA,SAAA,CAAA;AACA,GAAA;AACA;AACA,EAAA,MAAA,EAAA,GAAA,UAAA,CAAA,QAAA,CAAA,CAAA,EAAA,CAAA;AACA;AACA;AACA,EAAA,OAAA,EAAA,KAAA,YAAA,IAAA,EAAA,KAAA,UAAA,GAAA,QAAA,GAAA,SAAA,CAAA;AACA;;;;"}
|
package/esm/sdk.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { init as init$1 } from '@sentry/browser';
|
|
1
|
+
import { setContext, init as init$1 } from '@sentry/browser';
|
|
2
2
|
import { applySdkMetadata } from '@sentry/core';
|
|
3
|
+
import { version } from 'react';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Inits the React SDK
|
|
@@ -10,7 +11,7 @@ function init(options) {
|
|
|
10
11
|
};
|
|
11
12
|
|
|
12
13
|
applySdkMetadata(opts, 'react');
|
|
13
|
-
|
|
14
|
+
setContext('react', { version });
|
|
14
15
|
init$1(opts);
|
|
15
16
|
}
|
|
16
17
|
|
package/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 { init as browserInit } from '@sentry/browser';\nimport { applySdkMetadata } from '@sentry/core';\n\n/**\n * Inits the React SDK\n */\nexport function init(options: BrowserOptions): void {\n const opts = {\n ...options,\n };\n\n applySdkMetadata(opts, 'react');\n
|
|
1
|
+
{"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import type { BrowserOptions } from '@sentry/browser';\nimport { init as browserInit, setContext } from '@sentry/browser';\nimport { applySdkMetadata } from '@sentry/core';\n\nimport { version } from 'react';\n\n/**\n * Inits the React SDK\n */\nexport function init(options: BrowserOptions): void {\n const opts = {\n ...options,\n };\n\n applySdkMetadata(opts, 'react');\n setContext('react', { version });\n browserInit(opts);\n}\n"],"names":["browserInit"],"mappings":";;;;AAMA;AACA;AACA;AACO,SAAS,IAAI,CAAC,OAAO,EAAwB;AACpD,EAAE,MAAM,OAAO;AACf,IAAI,GAAG,OAAO;AACd,GAAG,CAAA;AACH;AACA,EAAE,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;AACjC,EAAE,UAAU,CAAC,OAAO,EAAE,EAAE,OAAA,EAAS,CAAC,CAAA;AAClC,EAAEA,MAAW,CAAC,IAAI,CAAC,CAAA;AACnB;;;;"}
|
package/esm/tanstackrouter.js
CHANGED
|
@@ -107,9 +107,9 @@ function routeMatchToParamSpanAttributes(match) {
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
const paramAttributes = {};
|
|
110
|
-
|
|
111
|
-
paramAttributes[`url.path.params.${key}`] =
|
|
112
|
-
}
|
|
110
|
+
Object.entries(match.params).forEach(([key, value]) => {
|
|
111
|
+
paramAttributes[`url.path.params.${key}`] = value;
|
|
112
|
+
});
|
|
113
113
|
|
|
114
114
|
return paramAttributes;
|
|
115
115
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tanstackrouter.js","sources":["../../src/tanstackrouter.ts"],"sourcesContent":["import { WINDOW, startBrowserTracingNavigationSpan, startBrowserTracingPageLoadSpan } from '@sentry/browser';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n} from '@sentry/core';\n\nimport { browserTracingIntegration as originalBrowserTracingIntegration } from '@sentry/browser';\nimport type { Integration } from '@sentry/types';\nimport type { VendoredTanstackRouter, VendoredTanstackRouterRouteMatch } from './vendor/tanstackrouter-types';\n\n/**\n * A custom browser tracing integration for TanStack Router.\n *\n * The minimum compatible version of `@tanstack/router` is `1.34.5`.\n *\n * @param router A TanStack Router `Router` instance that should be used for routing instrumentation.\n * @param options Sentry browser tracing configuration.\n */\nexport function tanstackRouterBrowserTracingIntegration(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n router: any, // This is `any` because we don't want any type mismatches if TanStack Router changes their types\n options: Parameters<typeof originalBrowserTracingIntegration>[0] = {},\n): Integration {\n const castRouterInstance: VendoredTanstackRouter = router;\n\n const browserTracingIntegrationInstance = originalBrowserTracingIntegration({\n ...options,\n instrumentNavigation: false,\n instrumentPageLoad: false,\n });\n\n const { instrumentPageLoad = true, instrumentNavigation = true } = options;\n\n return {\n ...browserTracingIntegrationInstance,\n afterAllSetup(client) {\n browserTracingIntegrationInstance.afterAllSetup(client);\n\n const initialWindowLocation = WINDOW.location;\n if (instrumentPageLoad && initialWindowLocation) {\n const matchedRoutes = castRouterInstance.matchRoutes(\n initialWindowLocation.pathname,\n initialWindowLocation.search,\n { preload: false, throwOnError: false },\n );\n\n const lastMatch = matchedRoutes[matchedRoutes.length - 1];\n\n startBrowserTracingPageLoadSpan(client, {\n name: lastMatch ? lastMatch.routeId : initialWindowLocation.pathname,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'pageload',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.pageload.react.tanstack_router',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: lastMatch ? 'route' : 'url',\n ...routeMatchToParamSpanAttributes(lastMatch),\n },\n });\n }\n\n if (instrumentNavigation) {\n // The onBeforeNavigate hook is called at the very beginning of a navigation and is only called once per navigation, even when the user is redirected\n castRouterInstance.subscribe('onBeforeNavigate', onBeforeNavigateArgs => {\n // onBeforeNavigate is called during pageloads. We can avoid creating navigation spans by comparing the states of the to and from arguments.\n if (onBeforeNavigateArgs.toLocation.state === onBeforeNavigateArgs.fromLocation.state) {\n return;\n }\n\n const onResolvedMatchedRoutes = castRouterInstance.matchRoutes(\n onBeforeNavigateArgs.toLocation.pathname,\n onBeforeNavigateArgs.toLocation.search,\n { preload: false, throwOnError: false },\n );\n\n const onBeforeNavigateLastMatch = onResolvedMatchedRoutes[onResolvedMatchedRoutes.length - 1];\n\n const navigationLocation = WINDOW.location;\n const navigationSpan = startBrowserTracingNavigationSpan(client, {\n name: onBeforeNavigateLastMatch ? onBeforeNavigateLastMatch.routeId : navigationLocation.pathname,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.react.tanstack_router',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: onBeforeNavigateLastMatch ? 'route' : 'url',\n },\n });\n\n // In case the user is redirected during navigation we want to update the span with the right value.\n const unsubscribeOnResolved = castRouterInstance.subscribe('onResolved', onResolvedArgs => {\n unsubscribeOnResolved();\n if (navigationSpan) {\n const onResolvedMatchedRoutes = castRouterInstance.matchRoutes(\n onResolvedArgs.toLocation.pathname,\n onResolvedArgs.toLocation.search,\n { preload: false, throwOnError: false },\n );\n\n const onResolvedLastMatch = onResolvedMatchedRoutes[onResolvedMatchedRoutes.length - 1];\n\n if (onResolvedLastMatch) {\n navigationSpan.updateName(onResolvedLastMatch.routeId);\n navigationSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'route');\n navigationSpan.setAttributes(routeMatchToParamSpanAttributes(onResolvedLastMatch));\n }\n }\n });\n });\n }\n },\n };\n}\n\nfunction routeMatchToParamSpanAttributes(match: VendoredTanstackRouterRouteMatch | undefined): Record<string, string> {\n if (!match) {\n return {};\n }\n\n const paramAttributes: Record<string, string> = {};\n
|
|
1
|
+
{"version":3,"file":"tanstackrouter.js","sources":["../../src/tanstackrouter.ts"],"sourcesContent":["import { WINDOW, startBrowserTracingNavigationSpan, startBrowserTracingPageLoadSpan } from '@sentry/browser';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n} from '@sentry/core';\n\nimport { browserTracingIntegration as originalBrowserTracingIntegration } from '@sentry/browser';\nimport type { Integration } from '@sentry/types';\nimport type { VendoredTanstackRouter, VendoredTanstackRouterRouteMatch } from './vendor/tanstackrouter-types';\n\n/**\n * A custom browser tracing integration for TanStack Router.\n *\n * The minimum compatible version of `@tanstack/router` is `1.34.5`.\n *\n * @param router A TanStack Router `Router` instance that should be used for routing instrumentation.\n * @param options Sentry browser tracing configuration.\n */\nexport function tanstackRouterBrowserTracingIntegration(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n router: any, // This is `any` because we don't want any type mismatches if TanStack Router changes their types\n options: Parameters<typeof originalBrowserTracingIntegration>[0] = {},\n): Integration {\n const castRouterInstance: VendoredTanstackRouter = router;\n\n const browserTracingIntegrationInstance = originalBrowserTracingIntegration({\n ...options,\n instrumentNavigation: false,\n instrumentPageLoad: false,\n });\n\n const { instrumentPageLoad = true, instrumentNavigation = true } = options;\n\n return {\n ...browserTracingIntegrationInstance,\n afterAllSetup(client) {\n browserTracingIntegrationInstance.afterAllSetup(client);\n\n const initialWindowLocation = WINDOW.location;\n if (instrumentPageLoad && initialWindowLocation) {\n const matchedRoutes = castRouterInstance.matchRoutes(\n initialWindowLocation.pathname,\n initialWindowLocation.search,\n { preload: false, throwOnError: false },\n );\n\n const lastMatch = matchedRoutes[matchedRoutes.length - 1];\n\n startBrowserTracingPageLoadSpan(client, {\n name: lastMatch ? lastMatch.routeId : initialWindowLocation.pathname,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'pageload',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.pageload.react.tanstack_router',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: lastMatch ? 'route' : 'url',\n ...routeMatchToParamSpanAttributes(lastMatch),\n },\n });\n }\n\n if (instrumentNavigation) {\n // The onBeforeNavigate hook is called at the very beginning of a navigation and is only called once per navigation, even when the user is redirected\n castRouterInstance.subscribe('onBeforeNavigate', onBeforeNavigateArgs => {\n // onBeforeNavigate is called during pageloads. We can avoid creating navigation spans by comparing the states of the to and from arguments.\n if (onBeforeNavigateArgs.toLocation.state === onBeforeNavigateArgs.fromLocation.state) {\n return;\n }\n\n const onResolvedMatchedRoutes = castRouterInstance.matchRoutes(\n onBeforeNavigateArgs.toLocation.pathname,\n onBeforeNavigateArgs.toLocation.search,\n { preload: false, throwOnError: false },\n );\n\n const onBeforeNavigateLastMatch = onResolvedMatchedRoutes[onResolvedMatchedRoutes.length - 1];\n\n const navigationLocation = WINDOW.location;\n const navigationSpan = startBrowserTracingNavigationSpan(client, {\n name: onBeforeNavigateLastMatch ? onBeforeNavigateLastMatch.routeId : navigationLocation.pathname,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.react.tanstack_router',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: onBeforeNavigateLastMatch ? 'route' : 'url',\n },\n });\n\n // In case the user is redirected during navigation we want to update the span with the right value.\n const unsubscribeOnResolved = castRouterInstance.subscribe('onResolved', onResolvedArgs => {\n unsubscribeOnResolved();\n if (navigationSpan) {\n const onResolvedMatchedRoutes = castRouterInstance.matchRoutes(\n onResolvedArgs.toLocation.pathname,\n onResolvedArgs.toLocation.search,\n { preload: false, throwOnError: false },\n );\n\n const onResolvedLastMatch = onResolvedMatchedRoutes[onResolvedMatchedRoutes.length - 1];\n\n if (onResolvedLastMatch) {\n navigationSpan.updateName(onResolvedLastMatch.routeId);\n navigationSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'route');\n navigationSpan.setAttributes(routeMatchToParamSpanAttributes(onResolvedLastMatch));\n }\n }\n });\n });\n }\n },\n };\n}\n\nfunction routeMatchToParamSpanAttributes(match: VendoredTanstackRouterRouteMatch | undefined): Record<string, string> {\n if (!match) {\n return {};\n }\n\n const paramAttributes: Record<string, string> = {};\n Object.entries(match.params).forEach(([key, value]) => {\n paramAttributes[`url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package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/react",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.10.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",
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@sentry/browser": "8.
|
|
46
|
-
"@sentry/core": "8.
|
|
47
|
-
"@sentry/types": "8.
|
|
48
|
-
"@sentry/utils": "8.
|
|
45
|
+
"@sentry/browser": "8.10.0",
|
|
46
|
+
"@sentry/core": "8.10.0",
|
|
47
|
+
"@sentry/types": "8.10.0",
|
|
48
|
+
"@sentry/utils": "8.10.0",
|
|
49
49
|
"hoist-non-react-statics": "^3.3.2"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactrouterv6.d.ts","sourceRoot":"","sources":["../../src/reactrouterv6.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEL,yBAAyB,EAG1B,MAAM,iBAAiB,CAAC;AAWzB,OAAO,KAAK,EAAU,WAAW,EAA2B,MAAM,eAAe,CAAC;AAGlF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAGV,oBAAoB,EACpB,wBAAwB,EAExB,WAAW,EAGX,MAAM,EACN,WAAW,EACX,SAAS,EACT,WAAW,EACX,iBAAiB,EACjB,SAAS,EACV,MAAM,SAAS,CAAC;AAWjB,UAAU,kBAAkB;IAC1B,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,WAAW,CAAC;IACzB,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,wBAAwB,EAAE,wBAAwB,CAAC;IACnD,W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MAAM,SAAS,WAAW,GAAG,WAAW,EACxC,OAAO,SAAS,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,EAC/C,oBAAoB,EAAE,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC,CAmCpG"}
|
package/types/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAMtD;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAQlD"}
|