@sentry/react 7.0.0-beta.0 → 7.0.0-beta.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.
Files changed (90) hide show
  1. package/README.md +2 -3
  2. package/cjs/constants.js +12 -5
  3. package/cjs/constants.js.map +1 -1
  4. package/cjs/errorboundary.js +134 -102
  5. package/cjs/errorboundary.js.map +1 -1
  6. package/cjs/flags.js +7 -3
  7. package/cjs/flags.js.map +1 -1
  8. package/cjs/index.js +30 -21
  9. package/cjs/index.js.map +1 -1
  10. package/cjs/profiler.js +172 -134
  11. package/cjs/profiler.js.map +1 -1
  12. package/cjs/reactrouter.js +147 -93
  13. package/cjs/reactrouter.js.map +1 -1
  14. package/cjs/reactrouterv3.js +107 -75
  15. package/cjs/reactrouterv3.js.map +1 -1
  16. package/cjs/reactrouterv6.js +163 -0
  17. package/cjs/reactrouterv6.js.map +1 -0
  18. package/cjs/redux.js +54 -42
  19. package/cjs/redux.js.map +1 -1
  20. package/cjs/sdk.js +18 -15
  21. package/cjs/sdk.js.map +1 -1
  22. package/esm/constants.js +8 -4
  23. package/esm/constants.js.map +1 -1
  24. package/esm/errorboundary.js +120 -97
  25. package/esm/errorboundary.js.map +1 -1
  26. package/esm/flags.js +5 -2
  27. package/esm/flags.js.map +1 -1
  28. package/esm/index.js +8 -7
  29. package/esm/index.js.map +1 -1
  30. package/esm/profiler.js +154 -125
  31. package/esm/profiler.js.map +1 -1
  32. package/esm/reactrouter.js +133 -86
  33. package/esm/reactrouter.js.map +1 -1
  34. package/esm/reactrouterv3.js +104 -72
  35. package/esm/reactrouterv3.js.map +1 -1
  36. package/esm/reactrouterv6.js +153 -0
  37. package/esm/reactrouterv6.js.map +1 -0
  38. package/esm/redux.js +51 -40
  39. package/esm/redux.js.map +1 -1
  40. package/esm/sdk.js +17 -14
  41. package/esm/sdk.js.map +1 -1
  42. package/package.json +5 -4
  43. package/types/index.d.ts +1 -0
  44. package/types/index.d.ts.map +1 -1
  45. package/types/reactrouterv6.d.ts +27 -0
  46. package/types/reactrouterv6.d.ts.map +1 -0
  47. package/cjs/constants.d.ts +0 -4
  48. package/cjs/constants.d.ts.map +0 -1
  49. package/cjs/errorboundary.d.ts +0 -63
  50. package/cjs/errorboundary.d.ts.map +0 -1
  51. package/cjs/flags.d.ts +0 -3
  52. package/cjs/flags.d.ts.map +0 -1
  53. package/cjs/index.d.ts +0 -8
  54. package/cjs/index.d.ts.map +0 -1
  55. package/cjs/profiler.d.ts +0 -54
  56. package/cjs/profiler.d.ts.map +0 -1
  57. package/cjs/reactrouter.d.ts +0 -25
  58. package/cjs/reactrouter.d.ts.map +0 -1
  59. package/cjs/reactrouterv3.d.ts +0 -26
  60. package/cjs/reactrouterv3.d.ts.map +0 -1
  61. package/cjs/redux.d.ts +0 -33
  62. package/cjs/redux.d.ts.map +0 -1
  63. package/cjs/sdk.d.ts +0 -6
  64. package/cjs/sdk.d.ts.map +0 -1
  65. package/cjs/types.d.ts +0 -8
  66. package/cjs/types.d.ts.map +0 -1
  67. package/cjs/types.js +0 -2
  68. package/cjs/types.js.map +0 -1
  69. package/esm/constants.d.ts +0 -4
  70. package/esm/constants.d.ts.map +0 -1
  71. package/esm/errorboundary.d.ts +0 -63
  72. package/esm/errorboundary.d.ts.map +0 -1
  73. package/esm/flags.d.ts +0 -3
  74. package/esm/flags.d.ts.map +0 -1
  75. package/esm/index.d.ts +0 -8
  76. package/esm/index.d.ts.map +0 -1
  77. package/esm/profiler.d.ts +0 -54
  78. package/esm/profiler.d.ts.map +0 -1
  79. package/esm/reactrouter.d.ts +0 -25
  80. package/esm/reactrouter.d.ts.map +0 -1
  81. package/esm/reactrouterv3.d.ts +0 -26
  82. package/esm/reactrouterv3.d.ts.map +0 -1
  83. package/esm/redux.d.ts +0 -33
  84. package/esm/redux.d.ts.map +0 -1
  85. package/esm/sdk.d.ts +0 -6
  86. package/esm/sdk.d.ts.map +0 -1
  87. package/esm/types.d.ts +0 -8
  88. package/esm/types.d.ts.map +0 -1
  89. package/esm/types.js +0 -1
  90. package/esm/types.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"reactrouter.js","sourceRoot":"","sources":["../../src/reactrouter.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAuB/B,sDAAsD;AAEtD,MAAM,MAAM,GAAG,eAAe,EAAU,CAAC;AAEzC,IAAI,iBAA0C,CAAC;AAE/C,MAAM,UAAU,4BAA4B,CAC1C,OAAsB,EACtB,MAAsB,EACtB,SAAqB;IAErB,OAAO,gCAAgC,CAAC,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;AACzF,CAAC;AAED,MAAM,UAAU,4BAA4B,CAC1C,OAAsB,EACtB,MAAsB,EACtB,SAAqB;IAErB,OAAO,gCAAgC,CAAC,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;AACzF,CAAC;AAED,SAAS,gCAAgC,CACvC,OAAsB,EACtB,IAAY,EACZ,YAA2B,EAAE,EAC7B,SAAqB;IAErB,SAAS,eAAe;QACtB,IAAI,OAAO,IAAI,OAAO,CAAC,QAAQ,EAAE;YAC/B,OAAO,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;SAClC;QAED,IAAI,MAAM,IAAI,MAAM,CAAC,QAAQ,EAAE;YAC7B,OAAO,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC;SACjC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,SAAS,kBAAkB,CAAC,QAAgB;QAC1C,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE;YACxC,OAAO,QAAQ,CAAC;SACjB;QAED,MAAM,QAAQ,GAAG,WAAW,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,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OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;SACrD;QAED,gFAAgF;QAChF,kEAAkE;QAClE,2IAA2I;QAC3I,OAAO,oBAAC,KAAK,oBAAK,KAAK,EAAI,CAAC;IAC9B,CAAC,CAAC;IAEF,YAAY,CAAC,WAAW,GAAG,eAAe,oBAAoB,GAAG,CAAC;IAClE,oBAAoB,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;IAC1C,gFAAgF;IAChF,kEAAkE;IAClE,2IAA2I;IAC3I,OAAO,YAAY,CAAC;AACtB,CAAC;AACD,kGAAkG","sourcesContent":["import { Transaction } from '@sentry/types';\nimport { getGlobalObject } from '@sentry/utils';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\n\nimport { 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.\n/* eslint-disable @typescript-eslint/no-explicit-any */\ntype Match = { path: string; url: string; params: Record<string, any>; isExact: boolean };\n\nexport type RouterHistory = {\n location?: Location;\n listen?(cb: (location: Location, action: Action) => void): void;\n} & Record<string, any>;\n\nexport type RouteConfig = {\n [propName: string]: any;\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;\n/* eslint-enable @typescript-eslint/no-explicit-any */\n\nconst global = getGlobalObject<Window>();\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 (global && global.location) {\n return global.location.pathname;\n }\n\n return undefined;\n }\n\n function getTransactionName(pathname: string): string {\n if (allRoutes.length === 0 || !matchPath) {\n return pathname;\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;\n }\n }\n\n return pathname;\n }\n\n return (customStartTransaction, startTransactionOnPageLoad = true, startTransactionOnLocationChange = true): void => {\n const initPathName = getInitPathName();\n if (startTransactionOnPageLoad && initPathName) {\n activeTransaction = customStartTransaction({\n name: getTransactionName(initPathName),\n op: 'pageload',\n tags: {\n 'routing.instrumentation': name,\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.finish();\n }\n const tags = {\n 'routing.instrumentation': name,\n };\n\n activeTransaction = customStartTransaction({\n name: getTransactionName(location.pathname),\n op: 'navigation',\n tags,\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.setName(props.computedMatch.path);\n }\n\n // @ts-ignore Setting more specific React Component typing for `R` generic above\n // will break advanced type inference done by react router params:\n // 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-ignore 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"]}
1
+ {"version":3,"file":"reactrouter.js","sources":["../../src/reactrouter.tsx"],"sourcesContent":["import { Transaction } from '@sentry/types';\nimport { getGlobalObject } from '@sentry/utils';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\n\nimport { 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.\n/* eslint-disable @typescript-eslint/no-explicit-any */\ntype Match = { path: string; url: string; params: Record<string, any>; isExact: boolean };\n\nexport type RouterHistory = {\n location?: Location;\n listen?(cb: (location: Location, action: Action) => void): void;\n} & Record<string, any>;\n\nexport type RouteConfig = {\n [propName: string]: any;\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;\n/* eslint-enable @typescript-eslint/no-explicit-any */\n\nconst global = getGlobalObject<Window>();\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 (global && global.location) {\n return global.location.pathname;\n }\n\n return undefined;\n }\n\n function getTransactionName(pathname: string): string {\n if (allRoutes.length === 0 || !matchPath) {\n return pathname;\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;\n }\n }\n\n return pathname;\n }\n\n return (customStartTransaction, startTransactionOnPageLoad = true, startTransactionOnLocationChange = true): void => {\n const initPathName = getInitPathName();\n if (startTransactionOnPageLoad && initPathName) {\n activeTransaction = customStartTransaction({\n name: getTransactionName(initPathName),\n op: 'pageload',\n tags: {\n 'routing.instrumentation': name,\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.finish();\n }\n const tags = {\n 'routing.instrumentation': name,\n };\n\n activeTransaction = customStartTransaction({\n name: getTransactionName(location.pathname),\n op: 'navigation',\n tags,\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.setName(props.computedMatch.path);\n }\n\n // @ts-ignore Setting more specific React Component typing for `R` generic above\n // will break advanced type inference done by react router params:\n // 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-ignore 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":[],"mappings":";;;;AAAA;;AAOA;AACA;;AAkBA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;"}
@@ -1,5 +1,10 @@
1
1
  import { getGlobalObject } from '@sentry/utils';
2
- const global = getGlobalObject();
2
+
3
+ // Many of the types below had to be mocked out to prevent typescript issues
4
+ // these types are required for correct functionality.
5
+
6
+ var global = getGlobalObject();
7
+
3
8
  /**
4
9
  * Creates routing instrumentation for React Router v3
5
10
  * Works for React Router >= 3.2.0 and < 4.0.0
@@ -8,88 +13,115 @@ const global = getGlobalObject();
8
13
  * @param routes a list of all routes, should be
9
14
  * @param match `Router.match` utility
10
15
  */
11
- export function reactRouterV3Instrumentation(history, routes, match) {
12
- return (startTransaction, startTransactionOnPageLoad = true, startTransactionOnLocationChange = true) => {
13
- let activeTransaction;
14
- let prevName;
15
- // Have to use global.location because history.location might not be defined.
16
- if (startTransactionOnPageLoad && global && global.location) {
17
- normalizeTransactionName(routes, global.location, match, (localName) => {
18
- prevName = localName;
19
- activeTransaction = startTransaction({
20
- name: prevName,
21
- op: 'pageload',
22
- tags: {
23
- 'routing.instrumentation': 'react-router-v3',
24
- },
25
- });
26
- });
27
- }
28
- if (startTransactionOnLocationChange && history.listen) {
29
- history.listen(location => {
30
- if (location.action === 'PUSH' || location.action === 'POP') {
31
- if (activeTransaction) {
32
- activeTransaction.finish();
33
- }
34
- const tags = {
35
- 'routing.instrumentation': 'react-router-v3',
36
- };
37
- if (prevName) {
38
- tags.from = prevName;
39
- }
40
- normalizeTransactionName(routes, location, match, (localName) => {
41
- prevName = localName;
42
- activeTransaction = startTransaction({
43
- name: prevName,
44
- op: 'navigation',
45
- tags,
46
- });
47
- });
48
- }
16
+ function reactRouterV3Instrumentation(
17
+ history,
18
+ routes,
19
+ match,
20
+ ) {
21
+ return (
22
+ startTransaction,
23
+ startTransactionOnPageLoad = true,
24
+ startTransactionOnLocationChange = true,
25
+ ) => {
26
+ let activeTransaction;
27
+ let prevName;
28
+
29
+ // Have to use global.location because history.location might not be defined.
30
+ if (startTransactionOnPageLoad && global && global.location) {
31
+ normalizeTransactionName(routes, global.location , match, (localName) => {
32
+ prevName = localName;
33
+ activeTransaction = startTransaction({
34
+ name: prevName,
35
+ op: 'pageload',
36
+ tags: {
37
+ 'routing.instrumentation': 'react-router-v3',
38
+ },
39
+ });
40
+ });
41
+ }
42
+
43
+ if (startTransactionOnLocationChange && history.listen) {
44
+ history.listen(location => {
45
+ if (location.action === 'PUSH' || location.action === 'POP') {
46
+ if (activeTransaction) {
47
+ activeTransaction.finish();
48
+ }
49
+ var tags = {
50
+ 'routing.instrumentation': 'react-router-v3',
51
+ };
52
+ if (prevName) {
53
+ tags.from = prevName;
54
+ }
55
+ normalizeTransactionName(routes, location, match, (localName) => {
56
+ prevName = localName;
57
+ activeTransaction = startTransaction({
58
+ name: prevName,
59
+ op: 'navigation',
60
+ tags,
49
61
  });
62
+ });
50
63
  }
51
- };
64
+ });
65
+ }
66
+ };
52
67
  }
68
+
53
69
  /**
54
70
  * Normalize transaction names using `Router.match`
55
71
  */
56
- function normalizeTransactionName(appRoutes, location, match, callback) {
57
- let name = location.pathname;
58
- match({
59
- location,
60
- routes: appRoutes,
61
- }, (error, _redirectLocation, renderProps) => {
62
- if (error || !renderProps) {
63
- return callback(name);
64
- }
65
- const routePath = getRouteStringFromRoutes(renderProps.routes || []);
66
- if (routePath.length === 0 || routePath === '/*') {
67
- return callback(name);
68
- }
69
- name = routePath;
72
+ function normalizeTransactionName(
73
+ appRoutes,
74
+ location,
75
+ match,
76
+ callback,
77
+ ) {
78
+ let name = location.pathname;
79
+ match(
80
+ {
81
+ location,
82
+ routes: appRoutes,
83
+ },
84
+ (error, _redirectLocation, renderProps) => {
85
+ if (error || !renderProps) {
86
+ return callback(name);
87
+ }
88
+
89
+ var routePath = getRouteStringFromRoutes(renderProps.routes || []);
90
+ if (routePath.length === 0 || routePath === '/*') {
70
91
  return callback(name);
71
- });
92
+ }
93
+
94
+ name = routePath;
95
+ return callback(name);
96
+ },
97
+ );
72
98
  }
99
+
73
100
  /**
74
101
  * Generate route name from array of routes
75
102
  */
76
103
  function getRouteStringFromRoutes(routes) {
77
- if (!Array.isArray(routes) || routes.length === 0) {
78
- return '';
79
- }
80
- const routesWithPaths = routes.filter((route) => !!route.path);
81
- let index = -1;
82
- for (let x = routesWithPaths.length - 1; x >= 0; x--) {
83
- const route = routesWithPaths[x];
84
- if (route.path && route.path.startsWith('/')) {
85
- index = x;
86
- break;
87
- }
104
+ if (!Array.isArray(routes) || routes.length === 0) {
105
+ return '';
106
+ }
107
+
108
+ var routesWithPaths = routes.filter((route) => !!route.path);
109
+
110
+ let index = -1;
111
+ for (let x = routesWithPaths.length - 1; x >= 0; x--) {
112
+ var route = routesWithPaths[x];
113
+ if (route.path && route.path.startsWith('/')) {
114
+ index = x;
115
+ break;
88
116
  }
89
- return routesWithPaths
90
- .slice(index)
91
- .filter(({ path }) => !!path)
92
- .map(({ path }) => path)
93
- .join('');
117
+ }
118
+
119
+ return routesWithPaths
120
+ .slice(index)
121
+ .filter(({ path }) => !!path)
122
+ .map(({ path }) => path)
123
+ .join('');
94
124
  }
95
- //# sourceMappingURL=reactrouterv3.js.map
125
+
126
+ export { reactRouterV3Instrumentation };
127
+ //# sourceMappingURL=reactrouterv3.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"reactrouterv3.js","sourceRoot":"","sources":["../../src/reactrouterv3.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAoBhD,MAAM,MAAM,GAAG,eAAe,EAAU,CAAC;AAEzC;;;;;;;GAOG;AACH,MAAM,UAAU,4BAA4B,CAC1C,OAAkB,EAClB,MAAe,EACf,KAAY;IAEZ,OAAO,CACL,gBAA0E,EAC1E,6BAAsC,IAAI,EAC1C,mCAA4C,IAAI,EAChD,EAAE;QACF,IAAI,iBAA0C,CAAC;QAC/C,IAAI,QAA4B,CAAC;QAEjC,6EAA6E;QAC7E,IAAI,0BAA0B,IAAI,MAAM,IAAI,MAAM,CAAC,QAAQ,EAAE;YAC3D,wBAAwB,CAAC,MAAM,EAAE,MAAM,CAAC,QAA+B,EAAE,KAAK,EAAE,CAAC,SAAiB,EAAE,EAAE;gBACpG,QAAQ,GAAG,SAAS,CAAC;gBACrB,iBAAiB,GAAG,gBAAgB,CAAC;oBACnC,IAAI,EAAE,QAAQ;oBACd,EAAE,EAAE,UAAU;oBACd,IAAI,EAAE;wBACJ,yBAAyB,EAAE,iBAAiB;qBAC7C;iBACF,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;SACJ;QAED,IAAI,gCAAgC,IAAI,OAAO,CAAC,MAAM,EAAE;YACtD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE;gBACxB,IAAI,QAAQ,CAAC,MAAM,KAAK,MAAM,IAAI,QAAQ,CAAC,MAAM,KAAK,KAAK,EAAE;oBAC3D,IAAI,iBAAiB,EAAE;wBACrB,iBAAiB,CAAC,MAAM,EAAE,CAAC;qBAC5B;oBACD,MAAM,IAAI,GAA8B;wBACtC,yBAAyB,EAAE,iBA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;KACX;IAED,MAAM,eAAe,GAAY,MAAM,CAAC,MAAM,CAAC,CAAC,KAAY,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAE/E,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC;IACf,KAAK,IAAI,CAAC,GAAG,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;QACpD,MAAM,KAAK,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;QACjC,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YAC5C,KAAK,GAAG,CAAC,CAAC;YACV,MAAM;SACP;KACF;IAED,OAAO,eAAe;SACnB,KAAK,CAAC,KAAK,CAAC;SACZ,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;SAC5B,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC;SACvB,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC","sourcesContent":["import { Primitive, Transaction, TransactionContext } from '@sentry/types';\nimport { getGlobalObject } from '@sentry/utils';\n\nimport { 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\nconst global = getGlobalObject<Window>();\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 global.location because history.location might not be defined.\n if (startTransactionOnPageLoad && global && global.location) {\n normalizeTransactionName(routes, global.location as unknown as Location, match, (localName: string) => {\n prevName = localName;\n activeTransaction = startTransaction({\n name: prevName,\n op: 'pageload',\n tags: {\n 'routing.instrumentation': 'react-router-v3',\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.finish();\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) => {\n prevName = localName;\n activeTransaction = startTransaction({\n name: prevName,\n op: 'navigation',\n tags,\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) => 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);\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"]}
1
+ {"version":3,"file":"reactrouterv3.js","sources":["../../src/reactrouterv3.ts"],"sourcesContent":["import { Primitive, Transaction, TransactionContext } from '@sentry/types';\nimport { getGlobalObject } from '@sentry/utils';\n\nimport { 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\nconst global = getGlobalObject<Window>();\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 global.location because history.location might not be defined.\n if (startTransactionOnPageLoad && global && global.location) {\n normalizeTransactionName(routes, global.location as unknown as Location, match, (localName: string) => {\n prevName = localName;\n activeTransaction = startTransaction({\n name: prevName,\n op: 'pageload',\n tags: {\n 'routing.instrumentation': 'react-router-v3',\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.finish();\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) => {\n prevName = localName;\n activeTransaction = startTransaction({\n name: prevName,\n op: 'navigation',\n tags,\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) => 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);\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":[],"mappings":";;AAKA;AACA;;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;"}
@@ -0,0 +1,153 @@
1
+ import { getGlobalObject, logger } from '@sentry/utils';
2
+ import hoistNonReactStatics from 'hoist-non-react-statics';
3
+ import React__default from 'react';
4
+ import { IS_DEBUG_BUILD } from './flags.js';
5
+
6
+ var _jsxFileName = "/home/runner/work/sentry-javascript/sentry-javascript/packages/react/src/reactrouterv6.tsx";
7
+
8
+ let activeTransaction;
9
+
10
+ let _useEffect;
11
+ let _useLocation;
12
+ let _useNavigationType;
13
+ let _createRoutesFromChildren;
14
+ let _matchRoutes;
15
+ let _customStartTransaction;
16
+ let _startTransactionOnLocationChange;
17
+
18
+ var global = getGlobalObject();
19
+
20
+ var SENTRY_TAGS = {
21
+ 'routing.instrumentation': 'react-router-v6',
22
+ };
23
+
24
+ function getInitPathName() {
25
+ if (global && global.location) {
26
+ return global.location.pathname;
27
+ }
28
+
29
+ return undefined;
30
+ }
31
+
32
+ function reactRouterV6Instrumentation(
33
+ useEffect,
34
+ useLocation,
35
+ useNavigationType,
36
+ createRoutesFromChildren,
37
+ matchRoutes,
38
+ ) {
39
+ return (
40
+ customStartTransaction,
41
+ startTransactionOnPageLoad = true,
42
+ startTransactionOnLocationChange = true,
43
+ ) => {
44
+ var initPathName = getInitPathName();
45
+ if (startTransactionOnPageLoad && initPathName) {
46
+ activeTransaction = customStartTransaction({
47
+ name: initPathName,
48
+ op: 'pageload',
49
+ tags: SENTRY_TAGS,
50
+ });
51
+ }
52
+
53
+ _useEffect = useEffect;
54
+ _useLocation = useLocation;
55
+ _useNavigationType = useNavigationType;
56
+ _matchRoutes = matchRoutes;
57
+ _createRoutesFromChildren = createRoutesFromChildren;
58
+
59
+ _customStartTransaction = customStartTransaction;
60
+ _startTransactionOnLocationChange = startTransactionOnLocationChange;
61
+ };
62
+ }
63
+
64
+ var getTransactionName = (routes, location, matchRoutes) => {
65
+ if (!routes || routes.length === 0 || !matchRoutes) {
66
+ return location.pathname;
67
+ }
68
+
69
+ var branches = matchRoutes(routes, location);
70
+
71
+ if (branches) {
72
+ for (let x = 0; x < branches.length; x++) {
73
+ if (branches[x].route && branches[x].route.path && branches[x].pathname === location.pathname) {
74
+ return branches[x].route.path || location.pathname;
75
+ }
76
+ }
77
+ }
78
+
79
+ return location.pathname;
80
+ };
81
+
82
+ function withSentryReactRouterV6Routing(Routes) {
83
+ if (
84
+ !_useEffect ||
85
+ !_useLocation ||
86
+ !_useNavigationType ||
87
+ !_createRoutesFromChildren ||
88
+ !_matchRoutes ||
89
+ !_customStartTransaction
90
+ ) {
91
+ IS_DEBUG_BUILD &&
92
+ logger.warn('reactRouterV6Instrumentation was unable to wrap Routes because of one or more missing parameters.');
93
+
94
+ return Routes;
95
+ }
96
+
97
+ let isBaseLocation = false;
98
+ let routes;
99
+
100
+ var SentryRoutes = (props) => {
101
+ var location = _useLocation();
102
+ var navigationType = _useNavigationType();
103
+
104
+ _useEffect(() => {
105
+ // Performance concern:
106
+ // This is repeated when <Routes /> is rendered.
107
+ routes = _createRoutesFromChildren(props.children);
108
+ isBaseLocation = true;
109
+
110
+ if (activeTransaction) {
111
+ activeTransaction.setName(getTransactionName(routes, location, _matchRoutes));
112
+ }
113
+
114
+ }, [props.children]);
115
+
116
+ _useEffect(() => {
117
+ if (isBaseLocation) {
118
+ if (activeTransaction) {
119
+ activeTransaction.finish();
120
+ }
121
+
122
+ return;
123
+ }
124
+
125
+ if (_startTransactionOnLocationChange && (navigationType === 'PUSH' || navigationType === 'POP')) {
126
+ if (activeTransaction) {
127
+ activeTransaction.finish();
128
+ }
129
+
130
+ activeTransaction = _customStartTransaction({
131
+ name: getTransactionName(routes, location, _matchRoutes),
132
+ op: 'navigation',
133
+ tags: SENTRY_TAGS,
134
+ });
135
+ }
136
+ }, [props.children, location, navigationType, isBaseLocation]);
137
+
138
+ isBaseLocation = false;
139
+
140
+ // @ts-ignore Setting more specific React Component typing for `R` generic above
141
+ // will break advanced type inference done by react router params
142
+ return React__default.createElement(Routes, { ...props, __self: this, __source: {fileName: _jsxFileName, lineNumber: 172}} );
143
+ };
144
+
145
+ hoistNonReactStatics(SentryRoutes, Routes);
146
+
147
+ // @ts-ignore Setting more specific React Component typing for `R` generic above
148
+ // will break advanced type inference done by react router params
149
+ return SentryRoutes;
150
+ }
151
+
152
+ export { reactRouterV6Instrumentation, withSentryReactRouterV6Routing };
153
+ //# sourceMappingURL=reactrouterv6.js.map
@@ -0,0 +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 { Transaction, TransactionContext } from '@sentry/types';\nimport { getGlobalObject, logger } from '@sentry/utils';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport React from 'react';\n\nimport { IS_DEBUG_BUILD } from './flags';\nimport { Action, Location } from './types';\n\ninterface RouteObject {\n caseSensitive?: boolean;\n children?: RouteObject[];\n element?: React.ReactNode;\n index?: boolean;\n path?: string;\n}\n\ntype Params<Key extends string = string> = {\n readonly [key in Key]: string | undefined;\n};\n\ninterface RouteMatch<ParamKey extends string = string> {\n params: Params<ParamKey>;\n pathname: string;\n route: RouteObject;\n}\n\ntype UseEffect = (cb: () => void, deps: unknown[]) => void;\ntype UseLocation = () => Location;\ntype UseNavigationType = () => Action;\ntype CreateRoutesFromChildren = (children: JSX.Element[]) => RouteObject[];\ntype MatchRoutes = (routes: RouteObject[], location: Location) => RouteMatch[] | null;\n\nlet activeTransaction: Transaction | undefined;\n\nlet _useEffect: UseEffect;\nlet _useLocation: UseLocation;\nlet _useNavigationType: UseNavigationType;\nlet _createRoutesFromChildren: CreateRoutesFromChildren;\nlet _matchRoutes: MatchRoutes;\nlet _customStartTransaction: (context: TransactionContext) => Transaction | undefined;\nlet _startTransactionOnLocationChange: boolean;\n\nconst global = getGlobalObject<Window>();\n\nconst SENTRY_TAGS = {\n 'routing.instrumentation': 'react-router-v6',\n};\n\nfunction getInitPathName(): string | undefined {\n if (global && global.location) {\n return global.location.pathname;\n }\n\n return undefined;\n}\n\nexport function reactRouterV6Instrumentation(\n useEffect: UseEffect,\n useLocation: UseLocation,\n useNavigationType: UseNavigationType,\n createRoutesFromChildren: CreateRoutesFromChildren,\n matchRoutes: MatchRoutes,\n) {\n return (\n customStartTransaction: (context: TransactionContext) => Transaction | undefined,\n startTransactionOnPageLoad = true,\n startTransactionOnLocationChange = true,\n ): void => {\n const initPathName = getInitPathName();\n if (startTransactionOnPageLoad && initPathName) {\n activeTransaction = customStartTransaction({\n name: initPathName,\n op: 'pageload',\n tags: SENTRY_TAGS,\n });\n }\n\n _useEffect = useEffect;\n _useLocation = useLocation;\n _useNavigationType = useNavigationType;\n _matchRoutes = matchRoutes;\n _createRoutesFromChildren = createRoutesFromChildren;\n\n _customStartTransaction = customStartTransaction;\n _startTransactionOnLocationChange = startTransactionOnLocationChange;\n };\n}\n\nconst getTransactionName = (routes: RouteObject[], location: Location, matchRoutes: MatchRoutes): string => {\n if (!routes || routes.length === 0 || !matchRoutes) {\n return location.pathname;\n }\n\n const branches = matchRoutes(routes, location);\n\n if (branches) {\n // eslint-disable-next-line @typescript-eslint/prefer-for-of\n for (let x = 0; x < branches.length; x++) {\n if (branches[x].route && branches[x].route.path && branches[x].pathname === location.pathname) {\n return branches[x].route.path || location.pathname;\n }\n }\n }\n\n return location.pathname;\n};\n\nexport function withSentryReactRouterV6Routing<P extends Record<string, any>, R extends React.FC<P>>(Routes: R): R {\n if (\n !_useEffect ||\n !_useLocation ||\n !_useNavigationType ||\n !_createRoutesFromChildren ||\n !_matchRoutes ||\n !_customStartTransaction\n ) {\n IS_DEBUG_BUILD &&\n logger.warn('reactRouterV6Instrumentation was unable to wrap Routes because of one or more missing parameters.');\n\n return Routes;\n }\n\n let isBaseLocation: boolean = false;\n let routes: RouteObject[];\n\n const SentryRoutes: React.FC<P> = (props: P) => {\n const location = _useLocation();\n const navigationType = _useNavigationType();\n\n _useEffect(() => {\n // Performance concern:\n // This is repeated when <Routes /> is rendered.\n routes = _createRoutesFromChildren(props.children);\n isBaseLocation = true;\n\n if (activeTransaction) {\n activeTransaction.setName(getTransactionName(routes, location, _matchRoutes));\n }\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [props.children]);\n\n _useEffect(() => {\n if (isBaseLocation) {\n if (activeTransaction) {\n activeTransaction.finish();\n }\n\n return;\n }\n\n if (_startTransactionOnLocationChange && (navigationType === 'PUSH' || navigationType === 'POP')) {\n if (activeTransaction) {\n activeTransaction.finish();\n }\n\n activeTransaction = _customStartTransaction({\n name: getTransactionName(routes, location, _matchRoutes),\n op: 'navigation',\n tags: SENTRY_TAGS,\n });\n }\n }, [props.children, location, navigationType, isBaseLocation]);\n\n isBaseLocation = false;\n\n // @ts-ignore Setting more specific React Component typing for `R` generic above\n // will break advanced type inference done by react router params\n return <Routes {...props} />;\n };\n\n hoistNonReactStatics(SentryRoutes, Routes);\n\n // @ts-ignore Setting more specific React Component typing for `R` generic above\n // will break advanced type inference done by react router params\n return SentryRoutes;\n}\n"],"names":[],"mappings":";;;;;AAAA;;AAmCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;"}
package/esm/redux.js CHANGED
@@ -1,52 +1,63 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
1
  import { configureScope } from '@sentry/browser';
3
- const ACTION_BREADCRUMB_CATEGORY = 'redux.action';
4
- const ACTION_BREADCRUMB_TYPE = 'info';
5
- const STATE_CONTEXT_KEY = 'redux.state';
6
- const defaultOptions = {
7
- actionTransformer: action => action,
8
- stateTransformer: state => state || null,
2
+
3
+ var ACTION_BREADCRUMB_CATEGORY = 'redux.action';
4
+ var ACTION_BREADCRUMB_TYPE = 'info';
5
+ var STATE_CONTEXT_KEY = 'redux.state';
6
+
7
+ var defaultOptions = {
8
+ actionTransformer: action => action,
9
+ stateTransformer: state => state || null,
9
10
  };
11
+
10
12
  /**
11
13
  * Creates an enhancer that would be passed to Redux's createStore to log actions and the latest state to Sentry.
12
14
  *
13
15
  * @param enhancerOptions Options to pass to the enhancer
14
16
  */
15
17
  function createReduxEnhancer(enhancerOptions) {
16
- // Note: We return an any type as to not have type conflicts.
17
- const options = Object.assign(Object.assign({}, defaultOptions), enhancerOptions);
18
- return (next) => (reducer, initialState) => {
19
- const sentryReducer = (state, action) => {
20
- const newState = reducer(state, action);
21
- configureScope(scope => {
22
- /* Action breadcrumbs */
23
- const transformedAction = options.actionTransformer(action);
24
- if (typeof transformedAction !== 'undefined' && transformedAction !== null) {
25
- scope.addBreadcrumb({
26
- category: ACTION_BREADCRUMB_CATEGORY,
27
- data: transformedAction,
28
- type: ACTION_BREADCRUMB_TYPE,
29
- });
30
- }
31
- /* Set latest state to scope */
32
- const transformedState = options.stateTransformer(newState);
33
- if (typeof transformedState !== 'undefined' && transformedState !== null) {
34
- scope.setContext(STATE_CONTEXT_KEY, transformedState);
35
- }
36
- else {
37
- scope.setContext(STATE_CONTEXT_KEY, null);
38
- }
39
- /* Allow user to configure scope with latest state */
40
- // eslint-disable-next-line @typescript-eslint/unbound-method
41
- const { configureScopeWithState } = options;
42
- if (typeof configureScopeWithState === 'function') {
43
- configureScopeWithState(scope, newState);
44
- }
18
+ // Note: We return an any type as to not have type conflicts.
19
+ var options = {
20
+ ...defaultOptions,
21
+ ...enhancerOptions,
22
+ };
23
+
24
+ return (next) =>
25
+ (reducer, initialState) => {
26
+ var sentryReducer = (state, action) => {
27
+ var newState = reducer(state, action);
28
+
29
+ configureScope(scope => {
30
+ /* Action breadcrumbs */
31
+ var transformedAction = options.actionTransformer(action);
32
+ if (typeof transformedAction !== 'undefined' && transformedAction !== null) {
33
+ scope.addBreadcrumb({
34
+ category: ACTION_BREADCRUMB_CATEGORY,
35
+ data: transformedAction,
36
+ type: ACTION_BREADCRUMB_TYPE,
45
37
  });
46
- return newState;
47
- };
48
- return next(sentryReducer, initialState);
38
+ }
39
+
40
+ /* Set latest state to scope */
41
+ var transformedState = options.stateTransformer(newState);
42
+ if (typeof transformedState !== 'undefined' && transformedState !== null) {
43
+ scope.setContext(STATE_CONTEXT_KEY, transformedState);
44
+ } else {
45
+ scope.setContext(STATE_CONTEXT_KEY, null);
46
+ }
47
+
48
+ /* Allow user to configure scope with latest state */
49
+ const { configureScopeWithState } = options;
50
+ if (typeof configureScopeWithState === 'function') {
51
+ configureScopeWithState(scope, newState);
52
+ }
53
+ });
54
+
55
+ return newState;
56
+ };
57
+
58
+ return next(sentryReducer, initialState);
49
59
  };
50
60
  }
61
+
51
62
  export { createReduxEnhancer };
52
- //# sourceMappingURL=redux.js.map
63
+ //# sourceMappingURL=redux.js.map
package/esm/redux.js.map C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gB,KAAK,IAAI,EAAE;oBACxE,KAAK,CAAC,UAAU,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,CAAC;iBACvD;qBAAM;oBACL,KAAK,CAAC,UAAU,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;iBAC3C;gBAED,qDAAqD;gBACrD,6DAA6D;gBAC7D,MAAM,EAAE,uBAAuB,EAAE,GAAG,OAAO,CAAC;gBAC5C,IAAI,OAAO,uBAAuB,KAAK,UAAU,EAAE;oBACjD,uBAAuB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;iBAC1C;YACH,CAAC,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC;QAClB,CAAC,CAAC;QAEF,OAAO,IAAI,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;IAC3C,CAAC,CAAC;AACN,CAAC;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { configureScope } from '@sentry/browser';\nimport { Scope } from '@sentry/types';\n\ninterface Action<T = any> {\n type: T;\n}\n\ninterface AnyAction extends Action {\n [extraProps: string]: any;\n}\n\ntype Reducer<S = any, A extends Action = AnyAction> = (state: S | undefined, action: A) => S;\n\ntype Dispatch<A extends Action = AnyAction> = <T extends A>(action: T, ...extraArgs: any[]) => T;\n\ntype ExtendState<State, Extension> = [Extension] extends [never] ? State : State & Extension;\n\ntype Unsubscribe = () => void;\n\ninterface Store<S = any, A extends Action = AnyAction, StateExt = never, Ext = Record<string, unknown>> {\n dispatch: Dispatch<A>;\n getState(): S;\n subscribe(listener: () => void): Unsubscribe;\n replaceReducer<NewState, NewActions extends Action>(\n nextReducer: Reducer<NewState, NewActions>,\n ): Store<ExtendState<NewState, StateExt>, NewActions, StateExt, Ext> & Ext;\n}\n\ndeclare const $CombinedState: unique symbol;\n\ntype CombinedState<S> = { readonly [$CombinedState]?: undefined } & S;\n\ntype PreloadedState<S> = Required<S> extends {\n [$CombinedState]: undefined;\n}\n ? S extends CombinedState<infer S1>\n ? { [K in keyof S1]?: S1[K] extends Record<string, unknown> ? PreloadedState<S1[K]> : S1[K] }\n : never\n : { [K in keyof S]: S[K] extends string | number | boolean | symbol ? S[K] : PreloadedState<S[K]> };\n\ntype StoreEnhancerStoreCreator<Ext = Record<string, unknown>, StateExt = never> = <\n S = any,\n A extends Action = AnyAction,\n>(\n reducer: Reducer<S, A>,\n preloadedState?: PreloadedState<S>,\n) => Store<ExtendState<S, StateExt>, A, StateExt, Ext> & Ext;\n\nexport interface SentryEnhancerOptions<S = any> {\n /**\n * Transforms the state before attaching it to an event.\n * Use this to remove any private data before sending it to Sentry.\n * Return null to not attach the state.\n */\n stateTransformer(state: S | undefined): (S & any) | null;\n /**\n * Transforms the action before sending it as a breadcrumb.\n * Use this to remove any private data before sending it to Sentry.\n * Return null to not send the breadcrumb.\n */\n actionTransformer(action: AnyAction): AnyAction | null;\n /**\n * Called on every state update, configure the Sentry Scope with the redux state.\n */\n configureScopeWithState?(scope: Scope, state: S): void;\n}\n\nconst ACTION_BREADCRUMB_CATEGORY = 'redux.action';\nconst ACTION_BREADCRUMB_TYPE = 'info';\nconst STATE_CONTEXT_KEY = 'redux.state';\n\nconst defaultOptions: SentryEnhancerOptions = {\n actionTransformer: action => action,\n stateTransformer: state => state || null,\n};\n\n/**\n * Creates an enhancer that would be passed to Redux's createStore to log actions and the latest state to Sentry.\n *\n * @param enhancerOptions Options to pass to the enhancer\n */\nfunction createReduxEnhancer(enhancerOptions?: Partial<SentryEnhancerOptions>): any {\n // Note: We return an any type as to not have type conflicts.\n const options = {\n ...defaultOptions,\n ...enhancerOptions,\n };\n\n return (next: StoreEnhancerStoreCreator): StoreEnhancerStoreCreator =>\n <S = any, A extends Action = AnyAction>(reducer: Reducer<S, A>, initialState?: PreloadedState<S>) => {\n const sentryReducer: Reducer<S, A> = (state, action): S => {\n const newState = reducer(state, action);\n\n configureScope(scope => {\n /* Action breadcrumbs */\n const transformedAction = options.actionTransformer(action);\n if (typeof transformedAction !== 'undefined' && transformedAction !== null) {\n scope.addBreadcrumb({\n category: ACTION_BREADCRUMB_CATEGORY,\n data: transformedAction,\n type: ACTION_BREADCRUMB_TYPE,\n });\n }\n\n /* Set latest state to scope */\n const transformedState = options.stateTransformer(newState);\n if (typeof transformedState !== 'undefined' && transformedState !== null) {\n scope.setContext(STATE_CONTEXT_KEY, transformedState);\n } else {\n scope.setContext(STATE_CONTEXT_KEY, null);\n }\n\n /* Allow user to configure scope with latest state */\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const { configureScopeWithState } = options;\n if (typeof configureScopeWithState === 'function') {\n configureScopeWithState(scope, newState);\n }\n });\n\n return newState;\n };\n\n return next(sentryReducer, initialState);\n };\n}\n\nexport { createReduxEnhancer };\n"]}
1
+ {"version":3,"file":"redux.js","sources":["../../src/redux.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { configureScope } from '@sentry/browser';\nimport { Scope } from '@sentry/types';\n\ninterface Action<T = any> {\n type: T;\n}\n\ninterface AnyAction extends Action {\n [extraProps: string]: any;\n}\n\ntype Reducer<S = any, A extends Action = AnyAction> = (state: S | undefined, action: A) => S;\n\ntype Dispatch<A extends Action = AnyAction> = <T extends A>(action: T, ...extraArgs: any[]) => T;\n\ntype ExtendState<State, Extension> = [Extension] extends [never] ? State : State & Extension;\n\ntype Unsubscribe = () => void;\n\ninterface Store<S = any, A extends Action = AnyAction, StateExt = never, Ext = Record<string, unknown>> {\n dispatch: Dispatch<A>;\n getState(): S;\n subscribe(listener: () => void): Unsubscribe;\n replaceReducer<NewState, NewActions extends Action>(\n nextReducer: Reducer<NewState, NewActions>,\n ): Store<ExtendState<NewState, StateExt>, NewActions, StateExt, Ext> & Ext;\n}\n\ndeclare const $CombinedState: unique symbol;\n\ntype CombinedState<S> = { readonly [$CombinedState]?: undefined } & S;\n\ntype PreloadedState<S> = Required<S> extends {\n [$CombinedState]: undefined;\n}\n ? S extends CombinedState<infer S1>\n ? { [K in keyof S1]?: S1[K] extends Record<string, unknown> ? PreloadedState<S1[K]> : S1[K] }\n : never\n : { [K in keyof S]: S[K] extends string | number | boolean | symbol ? S[K] : PreloadedState<S[K]> };\n\ntype StoreEnhancerStoreCreator<Ext = Record<string, unknown>, StateExt = never> = <\n S = any,\n A extends Action = AnyAction,\n>(\n reducer: Reducer<S, A>,\n preloadedState?: PreloadedState<S>,\n) => Store<ExtendState<S, StateExt>, A, StateExt, Ext> & Ext;\n\nexport interface SentryEnhancerOptions<S = any> {\n /**\n * Transforms the state before attaching it to an event.\n * Use this to remove any private data before sending it to Sentry.\n * Return null to not attach the state.\n */\n stateTransformer(state: S | undefined): (S & any) | null;\n /**\n * Transforms the action before sending it as a breadcrumb.\n * Use this to remove any private data before sending it to Sentry.\n * Return null to not send the breadcrumb.\n */\n actionTransformer(action: AnyAction): AnyAction | null;\n /**\n * Called on every state update, configure the Sentry Scope with the redux state.\n */\n configureScopeWithState?(scope: Scope, state: S): void;\n}\n\nconst ACTION_BREADCRUMB_CATEGORY = 'redux.action';\nconst ACTION_BREADCRUMB_TYPE = 'info';\nconst STATE_CONTEXT_KEY = 'redux.state';\n\nconst defaultOptions: SentryEnhancerOptions = {\n actionTransformer: action => action,\n stateTransformer: state => state || null,\n};\n\n/**\n * Creates an enhancer that would be passed to Redux's createStore to log actions and the latest state to Sentry.\n *\n * @param enhancerOptions Options to pass to the enhancer\n */\nfunction createReduxEnhancer(enhancerOptions?: Partial<SentryEnhancerOptions>): any {\n // Note: We return an any type as to not have type conflicts.\n const options = {\n ...defaultOptions,\n ...enhancerOptions,\n };\n\n return (next: StoreEnhancerStoreCreator): StoreEnhancerStoreCreator =>\n <S = any, A extends Action = AnyAction>(reducer: Reducer<S, A>, initialState?: PreloadedState<S>) => {\n const sentryReducer: Reducer<S, A> = (state, action): S => {\n const newState = reducer(state, action);\n\n configureScope(scope => {\n /* Action breadcrumbs */\n const transformedAction = options.actionTransformer(action);\n if (typeof transformedAction !== 'undefined' && transformedAction !== null) {\n scope.addBreadcrumb({\n category: ACTION_BREADCRUMB_CATEGORY,\n data: transformedAction,\n type: ACTION_BREADCRUMB_TYPE,\n });\n }\n\n /* Set latest state to scope */\n const transformedState = options.stateTransformer(newState);\n if (typeof transformedState !== 'undefined' && transformedState !== null) {\n scope.setContext(STATE_CONTEXT_KEY, transformedState);\n } else {\n scope.setContext(STATE_CONTEXT_KEY, null);\n }\n\n /* Allow user to configure scope with latest state */\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const { configureScopeWithState } = options;\n if (typeof configureScopeWithState === 'function') {\n configureScopeWithState(scope, newState);\n }\n });\n\n return newState;\n };\n\n return next(sentryReducer, initialState);\n };\n}\n\nexport { createReduxEnhancer };\n"],"names":[],"mappings":";;AAoEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;"}
package/esm/sdk.js CHANGED
@@ -1,19 +1,22 @@
1
- import { init as browserInit, SDK_VERSION } from '@sentry/browser';
1
+ import { SDK_VERSION, init as init$1 } from '@sentry/browser';
2
+
2
3
  /**
3
4
  * Inits the React SDK
4
5
  */
5
- export function init(options) {
6
- options._metadata = options._metadata || {};
7
- options._metadata.sdk = options._metadata.sdk || {
8
- name: 'sentry.javascript.react',
9
- packages: [
10
- {
11
- name: 'npm:@sentry/react',
12
- version: SDK_VERSION,
13
- },
14
- ],
6
+ function init(options) {
7
+ options._metadata = options._metadata || {};
8
+ options._metadata.sdk = options._metadata.sdk || {
9
+ name: 'sentry.javascript.react',
10
+ packages: [
11
+ {
12
+ name: 'npm:@sentry/react',
15
13
  version: SDK_VERSION,
16
- };
17
- browserInit(options);
14
+ },
15
+ ],
16
+ version: SDK_VERSION,
17
+ };
18
+ init$1(options);
18
19
  }
19
- //# sourceMappingURL=sdk.js.map
20
+
21
+ export { init };
22
+ //# sourceMappingURL=sdk.js.map
package/esm/sdk.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,IAAI,IAAI,WAAW,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnF;;GAEG;AACH,MAAM,UAAU,IAAI,CAAC,OAAuB;IAC1C,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC;IAC5C,OAAO,CAAC,SAAS,CAAC,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,IAAI;QAC/C,IAAI,EAAE,yBAAyB;QAC/B,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,mBAAmB;gBACzB,OAAO,EAAE,WAAW;aACrB;SACF;QACD,OAAO,EAAE,WAAW;KACrB,CAAC;IACF,WAAW,CAAC,OAAO,CAAC,CAAC;AACvB,CAAC","sourcesContent":["import { BrowserOptions, init as browserInit, SDK_VERSION } from '@sentry/browser';\n\n/**\n * Inits the React SDK\n */\nexport function init(options: BrowserOptions): void {\n options._metadata = options._metadata || {};\n options._metadata.sdk = options._metadata.sdk || {\n name: 'sentry.javascript.react',\n packages: [\n {\n name: 'npm:@sentry/react',\n version: SDK_VERSION,\n },\n ],\n version: SDK_VERSION,\n };\n browserInit(options);\n}\n"]}
1
+ {"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import { BrowserOptions, init as browserInit, SDK_VERSION } from '@sentry/browser';\n\n/**\n * Inits the React SDK\n */\nexport function init(options: BrowserOptions): void {\n options._metadata = options._metadata || {};\n options._metadata.sdk = options._metadata.sdk || {\n name: 'sentry.javascript.react',\n packages: [\n {\n name: 'npm:@sentry/react',\n version: SDK_VERSION,\n },\n ],\n version: SDK_VERSION,\n };\n browserInit(options);\n}\n"],"names":[],"mappings":";;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;"}