@sentry/react 7.99.0 → 7.100.1

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/index.js CHANGED
@@ -18,10 +18,14 @@ exports.withProfiler = profiler.withProfiler;
18
18
  exports.ErrorBoundary = errorboundary.ErrorBoundary;
19
19
  exports.withErrorBoundary = errorboundary.withErrorBoundary;
20
20
  exports.createReduxEnhancer = redux.createReduxEnhancer;
21
+ exports.reactRouterV3BrowserTracingIntegration = reactrouterv3.reactRouterV3BrowserTracingIntegration;
21
22
  exports.reactRouterV3Instrumentation = reactrouterv3.reactRouterV3Instrumentation;
23
+ exports.reactRouterV4BrowserTracingIntegration = reactrouter.reactRouterV4BrowserTracingIntegration;
22
24
  exports.reactRouterV4Instrumentation = reactrouter.reactRouterV4Instrumentation;
25
+ exports.reactRouterV5BrowserTracingIntegration = reactrouter.reactRouterV5BrowserTracingIntegration;
23
26
  exports.reactRouterV5Instrumentation = reactrouter.reactRouterV5Instrumentation;
24
27
  exports.withSentryRouting = reactrouter.withSentryRouting;
28
+ exports.reactRouterV6BrowserTracingIntegration = reactrouterv6.reactRouterV6BrowserTracingIntegration;
25
29
  exports.reactRouterV6Instrumentation = reactrouterv6.reactRouterV6Instrumentation;
26
30
  exports.withSentryReactRouterV6Routing = reactrouterv6.withSentryReactRouterV6Routing;
27
31
  exports.wrapCreateBrowserRouter = reactrouterv6.wrapCreateBrowserRouter;
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -26,29 +26,113 @@ const _jsxFileName = "/home/runner/work/sentry-javascript/sentry-javascript/pack
26
26
  // We need to disable eslint no-explict-any because any is required for the
27
27
  // react-router typings.
28
28
 
29
- // eslint-disable-line @typescript-eslint/no-explicit-any
30
-
31
29
  let activeTransaction;
32
30
 
31
+ /**
32
+ * A browser tracing integration that uses React Router v4 to instrument navigations.
33
+ * Expects `history` (and optionally `routes` and `matchPath`) to be passed as options.
34
+ */
35
+ function reactRouterV4BrowserTracingIntegration(
36
+ options,
37
+ ) {
38
+ const integration = browser.browserTracingIntegration({
39
+ ...options,
40
+ instrumentPageLoad: false,
41
+ instrumentNavigation: false,
42
+ });
43
+
44
+ const { history, routes, matchPath, instrumentPageLoad = true, instrumentNavigation = true } = options;
45
+
46
+ return {
47
+ ...integration,
48
+ afterAllSetup(client) {
49
+ integration.afterAllSetup(client);
50
+
51
+ const startPageloadCallback = (startSpanOptions) => {
52
+ browser.startBrowserTracingPageLoadSpan(client, startSpanOptions);
53
+ return undefined;
54
+ };
55
+
56
+ const startNavigationCallback = (startSpanOptions) => {
57
+ browser.startBrowserTracingNavigationSpan(client, startSpanOptions);
58
+ return undefined;
59
+ };
60
+
61
+ // eslint-disable-next-line deprecation/deprecation
62
+ const instrumentation = reactRouterV4Instrumentation(history, routes, matchPath);
63
+
64
+ // Now instrument page load & navigation with correct settings
65
+ instrumentation(startPageloadCallback, instrumentPageLoad, false);
66
+ instrumentation(startNavigationCallback, false, instrumentNavigation);
67
+ },
68
+ };
69
+ }
70
+
71
+ /**
72
+ * A browser tracing integration that uses React Router v5 to instrument navigations.
73
+ * Expects `history` (and optionally `routes` and `matchPath`) to be passed as options.
74
+ */
75
+ function reactRouterV5BrowserTracingIntegration(
76
+ options,
77
+ ) {
78
+ const integration = browser.browserTracingIntegration({
79
+ ...options,
80
+ instrumentPageLoad: false,
81
+ instrumentNavigation: false,
82
+ });
83
+
84
+ const { history, routes, matchPath } = options;
85
+
86
+ return {
87
+ ...integration,
88
+ afterAllSetup(client) {
89
+ integration.afterAllSetup(client);
90
+
91
+ const startPageloadCallback = (startSpanOptions) => {
92
+ browser.startBrowserTracingPageLoadSpan(client, startSpanOptions);
93
+ return undefined;
94
+ };
95
+
96
+ const startNavigationCallback = (startSpanOptions) => {
97
+ browser.startBrowserTracingNavigationSpan(client, startSpanOptions);
98
+ return undefined;
99
+ };
100
+
101
+ // eslint-disable-next-line deprecation/deprecation
102
+ const instrumentation = reactRouterV5Instrumentation(history, routes, matchPath);
103
+
104
+ // Now instrument page load & navigation with correct settings
105
+ instrumentation(startPageloadCallback, options.instrumentPageLoad, false);
106
+ instrumentation(startNavigationCallback, false, options.instrumentNavigation);
107
+ },
108
+ };
109
+ }
110
+
111
+ /**
112
+ * @deprecated Use `browserTracingReactRouterV4()` instead.
113
+ */
33
114
  function reactRouterV4Instrumentation(
34
115
  history,
35
116
  routes,
36
117
  matchPath,
37
118
  ) {
38
- return createReactRouterInstrumentation(history, 'react-router-v4', routes, matchPath);
119
+ return createReactRouterInstrumentation(history, 'reactrouter_v4', routes, matchPath);
39
120
  }
40
121
 
122
+ /**
123
+ * @deprecated Use `browserTracingReactRouterV5()` instead.
124
+ */
41
125
  function reactRouterV5Instrumentation(
42
126
  history,
43
127
  routes,
44
128
  matchPath,
45
129
  ) {
46
- return createReactRouterInstrumentation(history, 'react-router-v5', routes, matchPath);
130
+ return createReactRouterInstrumentation(history, 'reactrouter_v5', routes, matchPath);
47
131
  }
48
132
 
49
133
  function createReactRouterInstrumentation(
50
134
  history,
51
- name,
135
+ instrumentationName,
52
136
  allRoutes = [],
53
137
  matchPath,
54
138
  ) {
@@ -86,21 +170,17 @@ function createReactRouterInstrumentation(
86
170
  return [pathname, 'url'];
87
171
  }
88
172
 
89
- const tags = {
90
- 'routing.instrumentation': name,
91
- };
92
-
93
173
  return (customStartTransaction, startTransactionOnPageLoad = true, startTransactionOnLocationChange = true) => {
94
174
  const initPathName = getInitPathName();
175
+
95
176
  if (startTransactionOnPageLoad && initPathName) {
96
177
  const [name, source] = normalizeTransactionName(initPathName);
97
178
  activeTransaction = customStartTransaction({
98
179
  name,
99
- op: 'pageload',
100
- origin: 'auto.pageload.react.reactrouter',
101
- tags,
102
- metadata: {
103
- source,
180
+ attributes: {
181
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'pageload',
182
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: `auto.pageload.react.${instrumentationName}`,
183
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,
104
184
  },
105
185
  });
106
186
  }
@@ -115,11 +195,10 @@ function createReactRouterInstrumentation(
115
195
  const [name, source] = normalizeTransactionName(location.pathname);
116
196
  activeTransaction = customStartTransaction({
117
197
  name,
118
- op: 'navigation',
119
- origin: 'auto.navigation.react.reactrouter',
120
- tags,
121
- metadata: {
122
- source,
198
+ attributes: {
199
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',
200
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: `auto.navigation.react.${instrumentationName}`,
201
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,
123
202
  },
124
203
  });
125
204
  }
@@ -167,16 +246,18 @@ function computeRootMatch(pathname) {
167
246
  function withSentryRouting(Route) {
168
247
  const componentDisplayName = (Route ).displayName || (Route ).name;
169
248
 
249
+ const activeRootSpan = getActiveRootSpan();
250
+
170
251
  const WrappedRoute = (props) => {
171
- if (activeTransaction && props && props.computedMatch && props.computedMatch.isExact) {
172
- activeTransaction.updateName(props.computedMatch.path);
173
- activeTransaction.setAttribute(core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'route');
252
+ if (activeRootSpan && props && props.computedMatch && props.computedMatch.isExact) {
253
+ activeRootSpan.updateName(props.computedMatch.path);
254
+ activeRootSpan.setAttribute(core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'route');
174
255
  }
175
256
 
176
257
  // @ts-expect-error Setting more specific React Component typing for `R` generic above
177
258
  // will break advanced type inference done by react router params:
178
259
  // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/13dc4235c069e25fe7ee16e11f529d909f9f3ff8/types/react-router/index.d.ts#L154-L164
179
- return React__namespace.createElement(Route, { ...props, __self: this, __source: {fileName: _jsxFileName, lineNumber: 176}} );
260
+ return React__namespace.createElement(Route, { ...props, __self: this, __source: {fileName: _jsxFileName, lineNumber: 277}} );
180
261
  };
181
262
 
182
263
  WrappedRoute.displayName = `sentryRoute(${componentDisplayName})`;
@@ -188,7 +269,28 @@ function withSentryRouting(Route) {
188
269
  }
189
270
  /* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */
190
271
 
272
+ function getActiveRootSpan() {
273
+ // Legacy behavior for "old" react router instrumentation
274
+ if (activeTransaction) {
275
+ return activeTransaction;
276
+ }
277
+
278
+ const span = core.getActiveSpan();
279
+ const rootSpan = span ? core.getRootSpan(span) : undefined;
280
+
281
+ if (!rootSpan) {
282
+ return undefined;
283
+ }
284
+
285
+ const op = core.spanToJSON(rootSpan).op;
286
+
287
+ // Only use this root span if it is a pageload or navigation span
288
+ return op === 'navigation' || op === 'pageload' ? rootSpan : undefined;
289
+ }
290
+
291
+ exports.reactRouterV4BrowserTracingIntegration = reactRouterV4BrowserTracingIntegration;
191
292
  exports.reactRouterV4Instrumentation = reactRouterV4Instrumentation;
293
+ exports.reactRouterV5BrowserTracingIntegration = reactRouterV5BrowserTracingIntegration;
192
294
  exports.reactRouterV5Instrumentation = reactRouterV5Instrumentation;
193
295
  exports.withSentryRouting = withSentryRouting;
194
296
  //# sourceMappingURL=reactrouter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"reactrouter.js","sources":["../../src/reactrouter.tsx"],"sourcesContent":["import { WINDOW } from '@sentry/browser';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '@sentry/core';\nimport type { Transaction, TransactionSource } from '@sentry/types';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\n\nimport type { Action, Location, ReactRouterInstrumentation } 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\ntype MatchPath = (pathname: string, props: string | string[] | any, parent?: Match | null) => Match | null; // eslint-disable-line @typescript-eslint/no-explicit-any\n\nlet activeTransaction: Transaction | undefined;\n\nexport function reactRouterV4Instrumentation(\n history: RouterHistory,\n routes?: RouteConfig[],\n matchPath?: MatchPath,\n): ReactRouterInstrumentation {\n return createReactRouterInstrumentation(history, 'react-router-v4', routes, matchPath);\n}\n\nexport function reactRouterV5Instrumentation(\n history: RouterHistory,\n routes?: RouteConfig[],\n matchPath?: MatchPath,\n): ReactRouterInstrumentation {\n return createReactRouterInstrumentation(history, 'react-router-v5', routes, matchPath);\n}\n\nfunction createReactRouterInstrumentation(\n history: RouterHistory,\n name: string,\n allRoutes: RouteConfig[] = [],\n matchPath?: MatchPath,\n): ReactRouterInstrumentation {\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 const tags = {\n 'routing.instrumentation': name,\n };\n\n return (customStartTransaction, startTransactionOnPageLoad = true, startTransactionOnLocationChange = true): void => {\n const initPathName = getInitPathName();\n if (startTransactionOnPageLoad && initPathName) {\n const [name, source] = normalizeTransactionName(initPathName);\n activeTransaction = customStartTransaction({\n name,\n op: 'pageload',\n origin: 'auto.pageload.react.reactrouter',\n tags,\n metadata: {\n source,\n },\n });\n }\n\n if (startTransactionOnLocationChange && history.listen) {\n history.listen((location, action) => {\n if (action && (action === 'PUSH' || action === 'POP')) {\n if (activeTransaction) {\n activeTransaction.end();\n }\n\n const [name, source] = normalizeTransactionName(location.pathname);\n activeTransaction = customStartTransaction({\n name,\n op: 'navigation',\n origin: 'auto.navigation.react.reactrouter',\n tags,\n metadata: {\n source,\n },\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 (activeTransaction && props && props.computedMatch && props.computedMatch.isExact) {\n activeTransaction.updateName(props.computedMatch.path);\n activeTransaction.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'route');\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"],"names":["WINDOW","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","React","hoistNonReactStatics"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAA,YAAA,GAAA,0FAAA;AAQA;AACA;;AAgBA;AACA;AACA,IAAI,iBAAiB,CAAA;AACrB;AACO,SAAS,4BAA4B;AAC5C,EAAE,OAAO;AACT,EAAE,MAAM;AACR,EAAE,SAAS;AACX,EAA8B;AAC9B,EAAE,OAAO,gCAAgC,CAAC,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,SAAS,CAAC,CAAA;AACxF,CAAA;AACA;AACO,SAAS,4BAA4B;AAC5C,EAAE,OAAO;AACT,EAAE,MAAM;AACR,EAAE,SAAS;AACX,EAA8B;AAC9B,EAAE,OAAO,gCAAgC,CAAC,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,SAAS,CAAC,CAAA;AACxF,CAAA;AACA;AACA,SAAS,gCAAgC;AACzC,EAAE,OAAO;AACT,EAAE,IAAI;AACN,EAAE,SAAS,GAAkB,EAAE;AAC/B,EAAE,SAAS;AACX,EAA8B;AAC9B,EAAE,SAAS,eAAe,GAAuB;AACjD,IAAI,IAAI,OAAA,IAAW,OAAO,CAAC,QAAQ,EAAE;AACrC,MAAM,OAAO,OAA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;AACA;AACA,IAAI,OAAOC,gBAAC,CAAA,aAAA,CAAA,KAAA,EAAA,EAAM,GAAI,KAAK,sEAAI,CAAA;AAC/B,GAAG,CAAA;AACH;AACA,EAAE,YAAY,CAAC,WAAA,GAAc,CAAC,YAAY,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAA;AACnE,EAAEC,6BAAoB,CAAC,YAAY,EAAE,KAAK,CAAC,CAAA;AAC3C;AACA;AACA;AACA,EAAE,OAAO,YAAY,CAAA;AACrB,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 getRootSpan,\n spanToJSON,\n} from '@sentry/core';\nimport type { Integration, Span, StartSpanOptions, Transaction, TransactionSource } from '@sentry/types';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\n\nimport type { Action, Location, ReactRouterInstrumentation } 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\nlet activeTransaction: Transaction | undefined;\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 const startPageloadCallback = (startSpanOptions: StartSpanOptions): undefined => {\n startBrowserTracingPageLoadSpan(client, startSpanOptions);\n return undefined;\n };\n\n const startNavigationCallback = (startSpanOptions: StartSpanOptions): undefined => {\n startBrowserTracingNavigationSpan(client, startSpanOptions);\n return undefined;\n };\n\n // eslint-disable-next-line deprecation/deprecation\n const instrumentation = reactRouterV4Instrumentation(history, routes, matchPath);\n\n // Now instrument page load & navigation with correct settings\n instrumentation(startPageloadCallback, instrumentPageLoad, false);\n instrumentation(startNavigationCallback, false, instrumentNavigation);\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 } = options;\n\n return {\n ...integration,\n afterAllSetup(client) {\n integration.afterAllSetup(client);\n\n const startPageloadCallback = (startSpanOptions: StartSpanOptions): undefined => {\n startBrowserTracingPageLoadSpan(client, startSpanOptions);\n return undefined;\n };\n\n const startNavigationCallback = (startSpanOptions: StartSpanOptions): undefined => {\n startBrowserTracingNavigationSpan(client, startSpanOptions);\n return undefined;\n };\n\n // eslint-disable-next-line deprecation/deprecation\n const instrumentation = reactRouterV5Instrumentation(history, routes, matchPath);\n\n // Now instrument page load & navigation with correct settings\n instrumentation(startPageloadCallback, options.instrumentPageLoad, false);\n instrumentation(startNavigationCallback, false, options.instrumentNavigation);\n },\n };\n}\n\n/**\n * @deprecated Use `browserTracingReactRouterV4()` instead.\n */\nexport function reactRouterV4Instrumentation(\n history: RouterHistory,\n routes?: RouteConfig[],\n matchPath?: MatchPath,\n): ReactRouterInstrumentation {\n return createReactRouterInstrumentation(history, 'reactrouter_v4', routes, matchPath);\n}\n\n/**\n * @deprecated Use `browserTracingReactRouterV5()` instead.\n */\nexport function reactRouterV5Instrumentation(\n history: RouterHistory,\n routes?: RouteConfig[],\n matchPath?: MatchPath,\n): ReactRouterInstrumentation {\n return createReactRouterInstrumentation(history, 'reactrouter_v5', routes, matchPath);\n}\n\nfunction createReactRouterInstrumentation(\n history: RouterHistory,\n instrumentationName: string,\n allRoutes: RouteConfig[] = [],\n matchPath?: MatchPath,\n): ReactRouterInstrumentation {\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 return (customStartTransaction, startTransactionOnPageLoad = true, startTransactionOnLocationChange = true): void => {\n const initPathName = getInitPathName();\n\n if (startTransactionOnPageLoad && initPathName) {\n const [name, source] = normalizeTransactionName(initPathName);\n activeTransaction = customStartTransaction({\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 if (startTransactionOnLocationChange && history.listen) {\n history.listen((location, action) => {\n if (action && (action === 'PUSH' || action === 'POP')) {\n if (activeTransaction) {\n activeTransaction.end();\n }\n\n const [name, source] = normalizeTransactionName(location.pathname);\n activeTransaction = customStartTransaction({\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/**\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 activeRootSpan = getActiveRootSpan();\n\n const WrappedRoute: React.FC<P> = (props: P) => {\n if (activeRootSpan && props && props.computedMatch && props.computedMatch.isExact) {\n activeRootSpan.updateName(props.computedMatch.path);\n activeRootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'route');\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 // Legacy behavior for \"old\" react router instrumentation\n if (activeTransaction) {\n return activeTransaction;\n }\n\n const span = getActiveSpan();\n const rootSpan = span ? getRootSpan(span) : undefined;\n\n if (!rootSpan) {\n return undefined;\n }\n\n const op = spanToJSON(rootSpan).op;\n\n // Only use this root span if it is a pageload or navigation span\n return op === 'navigation' || op === 'pageload' ? rootSpan : undefined;\n}\n"],"names":["browserTracingIntegration","startBrowserTracingPageLoadSpan","startBrowserTracingNavigationSpan","WINDOW","SEMANTIC_ATTRIBUTE_SENTRY_OP","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","React","hoistNonReactStatics","getActiveSpan","getRootSpan","spanToJSON"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAO,YAAA,GAAA,0FAAA;AAoBP;AACA;;AAwBA,IAAI,iBAAiB,CAAA;AACrB;AACA;AACA;AACA;AACA;AACO,SAAS,sCAAsC;AACtD,EAAE,OAAO;AACT,EAAe;AACf,EAAE,MAAM,WAAA,GAAcA,iCAAyB,C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
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
2
 
3
3
  const browser = require('@sentry/browser');
4
+ const core = require('@sentry/core');
4
5
 
5
6
  // Many of the types below had to be mocked out to prevent typescript issues
6
7
  // these types are required for correct functionality.
7
8
 
9
+ /**
10
+ * A browser tracing integration that uses React Router v3 to instrument navigations.
11
+ * Expects `history` (and optionally `routes` and `matchPath`) to be passed as options.
12
+ */
13
+ function reactRouterV3BrowserTracingIntegration(
14
+ options,
15
+ ) {
16
+ const integration = browser.browserTracingIntegration({
17
+ ...options,
18
+ instrumentPageLoad: false,
19
+ instrumentNavigation: false,
20
+ });
21
+
22
+ const { history, routes, match, instrumentPageLoad = true, instrumentNavigation = true } = options;
23
+
24
+ return {
25
+ ...integration,
26
+ afterAllSetup(client) {
27
+ integration.afterAllSetup(client);
28
+
29
+ const startPageloadCallback = (startSpanOptions) => {
30
+ browser.startBrowserTracingPageLoadSpan(client, startSpanOptions);
31
+ return undefined;
32
+ };
33
+
34
+ const startNavigationCallback = (startSpanOptions) => {
35
+ browser.startBrowserTracingNavigationSpan(client, startSpanOptions);
36
+ return undefined;
37
+ };
38
+
39
+ // eslint-disable-next-line deprecation/deprecation
40
+ const instrumentation = reactRouterV3Instrumentation(history, routes, match);
41
+
42
+ // Now instrument page load & navigation with correct settings
43
+ instrumentation(startPageloadCallback, instrumentPageLoad, false);
44
+ instrumentation(startNavigationCallback, false, instrumentNavigation);
45
+ },
46
+ };
47
+ }
48
+
8
49
  /**
9
50
  * Creates routing instrumentation for React Router v3
10
51
  * Works for React Router >= 3.2.0 and < 4.0.0
@@ -12,6 +53,8 @@ const browser = require('@sentry/browser');
12
53
  * @param history object from the `history` library
13
54
  * @param routes a list of all routes, should be
14
55
  * @param match `Router.match` utility
56
+ *
57
+ * @deprecated Use `reactRouterV3BrowserTracingIntegration()` instead
15
58
  */
16
59
  function reactRouterV3Instrumentation(
17
60
  history,
@@ -36,13 +79,10 @@ function reactRouterV3Instrumentation(
36
79
  prevName = localName;
37
80
  activeTransaction = startTransaction({
38
81
  name: prevName,
39
- op: 'pageload',
40
- origin: 'auto.pageload.react.reactrouterv3',
41
- tags: {
42
- 'routing.instrumentation': 'react-router-v3',
43
- },
44
- metadata: {
45
- source,
82
+ attributes: {
83
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'pageload',
84
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.pageload.react.reactrouter_v3',
85
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,
46
86
  },
47
87
  });
48
88
  },
@@ -55,22 +95,18 @@ function reactRouterV3Instrumentation(
55
95
  if (activeTransaction) {
56
96
  activeTransaction.end();
57
97
  }
58
- const tags = {
59
- 'routing.instrumentation': 'react-router-v3',
60
- };
61
- if (prevName) {
62
- tags.from = prevName;
63
- }
64
98
  normalizeTransactionName(routes, location, match, (localName, source = 'url') => {
65
99
  prevName = localName;
100
+
101
+ const attributes = {
102
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',
103
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.react.reactrouter_v3',
104
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,
105
+ };
106
+
66
107
  activeTransaction = startTransaction({
67
108
  name: prevName,
68
- op: 'navigation',
69
- origin: 'auto.navigation.react.reactrouterv3',
70
- tags,
71
- metadata: {
72
- source,
73
- },
109
+ attributes,
74
110
  });
75
111
  });
76
112
  }
@@ -136,5 +172,6 @@ function getRouteStringFromRoutes(routes) {
136
172
  .join('');
137
173
  }
138
174
 
175
+ exports.reactRouterV3BrowserTracingIntegration = reactRouterV3BrowserTracingIntegration;
139
176
  exports.reactRouterV3Instrumentation = reactRouterV3Instrumentation;
140
177
  //# sourceMappingURL=reactrouterv3.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"reactrouterv3.js","sources":["../../src/reactrouterv3.ts"],"sourcesContent":["import { WINDOW } from '@sentry/browser';\nimport type { Primitive, Transaction, TransactionContext, TransactionSource } from '@sentry/types';\n\nimport type { Location, ReactRouterInstrumentation } 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\n/**\n * Creates routing instrumentation for React Router v3\n * Works for React Router >= 3.2.0 and < 4.0.0\n *\n * @param history object from the `history` library\n * @param routes a list of all routes, should be\n * @param match `Router.match` utility\n */\nexport function reactRouterV3Instrumentation(\n history: HistoryV3,\n routes: Route[],\n match: Match,\n): ReactRouterInstrumentation {\n return (\n startTransaction: (context: TransactionContext) => Transaction | undefined,\n startTransactionOnPageLoad: boolean = true,\n startTransactionOnLocationChange: boolean = true,\n ) => {\n let activeTransaction: Transaction | undefined;\n let prevName: string | undefined;\n\n // Have to use window.location because history.location might not be defined.\n if (startTransactionOnPageLoad && WINDOW && WINDOW.location) {\n normalizeTransactionName(\n routes,\n WINDOW.location as unknown as Location,\n match,\n (localName: string, source: ReactRouterV3TransactionSource = 'url') => {\n prevName = localName;\n activeTransaction = startTransaction({\n name: prevName,\n op: 'pageload',\n origin: 'auto.pageload.react.reactrouterv3',\n tags: {\n 'routing.instrumentation': 'react-router-v3',\n },\n metadata: {\n source,\n },\n });\n },\n );\n }\n\n if (startTransactionOnLocationChange && history.listen) {\n history.listen(location => {\n if (location.action === 'PUSH' || location.action === 'POP') {\n if (activeTransaction) {\n activeTransaction.end();\n }\n const tags: Record<string, Primitive> = {\n 'routing.instrumentation': 'react-router-v3',\n };\n if (prevName) {\n tags.from = prevName;\n }\n normalizeTransactionName(routes, location, match, (localName: string, source: TransactionSource = 'url') => {\n prevName = localName;\n activeTransaction = startTransaction({\n name: prevName,\n op: 'navigation',\n origin: 'auto.navigation.react.reactrouterv3',\n tags,\n metadata: {\n source,\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];\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":["WINDOW"],"mappings":";;;;AAKA;AACA;;AAiBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,4BAA4B;AAC5C,EAAE,OAAO;AACT,EAAE,MAAM;AACR,EAAE,KAAK;AACP,EAA8B;AAC9B,EAAE,OAAO;AACT,IAAI,gBAAgB;AACpB,IAAI,0BAA0B,GAAY,IAAI;AAC9C,IAAI,gCAAgC,GAAY,IAAI;AACpD,OAAO;AACP,IAAI,IAAI,iBAAiB,CAAA;AACzB,IAAI,IAAI,QAAQ,CAAA;AAChB;AACA;AACA,IAAI,IAAI,0BAA2B,IAAGA,kBAAUA,cAAM,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,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,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;;;;"}
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 {\n Integration,\n SpanAttributes,\n StartSpanOptions,\n Transaction,\n TransactionContext,\n TransactionSource,\n} from '@sentry/types';\n\nimport type { Location, ReactRouterInstrumentation } 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 const startPageloadCallback = (startSpanOptions: StartSpanOptions): undefined => {\n startBrowserTracingPageLoadSpan(client, startSpanOptions);\n return undefined;\n };\n\n const startNavigationCallback = (startSpanOptions: StartSpanOptions): undefined => {\n startBrowserTracingNavigationSpan(client, startSpanOptions);\n return undefined;\n };\n\n // eslint-disable-next-line deprecation/deprecation\n const instrumentation = reactRouterV3Instrumentation(history, routes, match);\n\n // Now instrument page load & navigation with correct settings\n instrumentation(startPageloadCallback, instrumentPageLoad, false);\n instrumentation(startNavigationCallback, false, instrumentNavigation);\n },\n };\n}\n\n/**\n * Creates routing instrumentation for React Router v3\n * Works for React Router >= 3.2.0 and < 4.0.0\n *\n * @param history object from the `history` library\n * @param routes a list of all routes, should be\n * @param match `Router.match` utility\n *\n * @deprecated Use `reactRouterV3BrowserTracingIntegration()` instead\n */\nexport function reactRouterV3Instrumentation(\n history: HistoryV3,\n routes: Route[],\n match: Match,\n): ReactRouterInstrumentation {\n return (\n startTransaction: (context: TransactionContext) => Transaction | undefined,\n startTransactionOnPageLoad: boolean = true,\n startTransactionOnLocationChange: boolean = true,\n ) => {\n let activeTransaction: Transaction | undefined;\n let prevName: string | undefined;\n\n // Have to use window.location because history.location might not be defined.\n if (startTransactionOnPageLoad && WINDOW && WINDOW.location) {\n normalizeTransactionName(\n routes,\n WINDOW.location as unknown as Location,\n match,\n (localName: string, source: ReactRouterV3TransactionSource = 'url') => {\n prevName = localName;\n activeTransaction = startTransaction({\n name: prevName,\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 (startTransactionOnLocationChange && history.listen) {\n history.listen(location => {\n if (location.action === 'PUSH' || location.action === 'POP') {\n if (activeTransaction) {\n activeTransaction.end();\n }\n normalizeTransactionName(routes, location, match, (localName: string, source: TransactionSource = 'url') => {\n prevName = localName;\n\n const attributes: SpanAttributes = {\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 activeTransaction = startTransaction({\n name: prevName,\n attributes,\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];\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","startBrowserTracingPageLoadSpan","startBrowserTracingNavigationSpan","WINDOW","SEMANTIC_ATTRIBUTE_SENTRY_OP","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE"],"mappings":";;;;;AAsBA;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,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;AACvC;AACA,MAAM,MAAM,qBAAA,GAAwB,CAAC,gBAAgB,KAAkC;AACvF,QAAQC,uCAA+B,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;AACjE,QAAQ,OAAO,SAAS,CAAA;AACxB,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