@sentry/react 8.5.0 → 8.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -4
- package/cjs/error.js +112 -0
- package/cjs/error.js.map +1 -0
- package/cjs/errorboundary.js +10 -56
- package/cjs/errorboundary.js.map +1 -1
- package/cjs/index.js +4 -0
- package/cjs/index.js.map +1 -1
- package/cjs/reactrouterv6.js +3 -3
- package/cjs/reactrouterv6.js.map +1 -1
- package/cjs/tanstackrouter.js +120 -0
- package/cjs/tanstackrouter.js.map +1 -0
- package/esm/error.js +107 -0
- package/esm/error.js.map +1 -0
- package/esm/errorboundary.js +12 -57
- package/esm/errorboundary.js.map +1 -1
- package/esm/index.js +2 -0
- package/esm/index.js.map +1 -1
- package/esm/reactrouterv6.js +3 -3
- package/esm/reactrouterv6.js.map +1 -1
- package/esm/tanstackrouter.js +118 -0
- package/esm/tanstackrouter.js.map +1 -0
- package/package.json +7 -7
- package/types/error.d.ts +41 -0
- package/types/error.d.ts.map +1 -0
- package/types/errorboundary.d.ts +4 -5
- package/types/errorboundary.d.ts.map +1 -1
- package/types/index.d.ts +2 -0
- package/types/index.d.ts.map +1 -1
- package/types/tanstackrouter.d.ts +13 -0
- package/types/tanstackrouter.d.ts.map +1 -0
- package/types/vendor/tanstackrouter-types.d.ts +33 -0
- package/types/vendor/tanstackrouter-types.d.ts.map +1 -0
- package/types-ts3.8/error.d.ts +41 -0
- package/types-ts3.8/errorboundary.d.ts +4 -5
- package/types-ts3.8/index.d.ts +2 -0
- package/types-ts3.8/tanstackrouter.d.ts +13 -0
- package/types-ts3.8/vendor/tanstackrouter-types.d.ts +33 -0
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ To use this SDK, call `Sentry.init(options)` before you mount your React compone
|
|
|
20
20
|
|
|
21
21
|
```javascript
|
|
22
22
|
import React from 'react';
|
|
23
|
-
import
|
|
23
|
+
import { createRoot } from 'react-dom/client';
|
|
24
24
|
import * as Sentry from '@sentry/react';
|
|
25
25
|
|
|
26
26
|
Sentry.init({
|
|
@@ -30,12 +30,39 @@ Sentry.init({
|
|
|
30
30
|
|
|
31
31
|
// ...
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
const container = document.getElementById(“app”);
|
|
34
|
+
const root = createRoot(container);
|
|
35
|
+
root.render(<App />);
|
|
34
36
|
|
|
35
|
-
//
|
|
36
|
-
//
|
|
37
|
+
// also works with hydrateRoot
|
|
38
|
+
// const domNode = document.getElementById('root');
|
|
39
|
+
// const root = hydrateRoot(domNode, reactNode);
|
|
40
|
+
// root.render(<App />);
|
|
37
41
|
```
|
|
38
42
|
|
|
43
|
+
### React 19
|
|
44
|
+
|
|
45
|
+
Starting with React 19, the `createRoot` and `hydrateRoot` methods expose error hooks that can be used to capture errors
|
|
46
|
+
automatically. Use the `Sentry.reactErrorHandler` function to capture errors in the error hooks you are interested in.
|
|
47
|
+
|
|
48
|
+
```js
|
|
49
|
+
const container = document.getElementById(“app”);
|
|
50
|
+
const root = createRoot(container, {
|
|
51
|
+
// Callback called when an error is thrown and not caught by an Error Boundary.
|
|
52
|
+
onUncaughtError: Sentry.reactErrorHandler((error, errorInfo) => {
|
|
53
|
+
console.warn('Uncaught error', error, errorInfo.componentStack);
|
|
54
|
+
}),
|
|
55
|
+
// Callback called when React catches an error in an Error Boundary.
|
|
56
|
+
onCaughtError: Sentry.reactErrorHandler(),
|
|
57
|
+
// Callback called when React automatically recovers from errors.
|
|
58
|
+
onRecoverableError: Sentry.reactErrorHandler(),
|
|
59
|
+
});
|
|
60
|
+
root.render(<App />);
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
If you want more finely grained control over error handling, we recommend only adding the `onUncaughtError` and
|
|
64
|
+
`onRecoverableError` hooks and using an `ErrorBoundary` component instead of the `onCaughtError` hook.
|
|
65
|
+
|
|
39
66
|
### ErrorBoundary
|
|
40
67
|
|
|
41
68
|
`@sentry/react` exports an ErrorBoundary component that will automatically send Javascript errors from inside a
|
package/cjs/error.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
|
|
3
|
+
const browser = require('@sentry/browser');
|
|
4
|
+
const utils = require('@sentry/utils');
|
|
5
|
+
const React = require('react');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* See if React major version is 17+ by parsing version string.
|
|
9
|
+
*/
|
|
10
|
+
function isAtLeastReact17(reactVersion) {
|
|
11
|
+
const reactMajor = reactVersion.match(/^([^.]+)/);
|
|
12
|
+
return reactMajor !== null && parseInt(reactMajor[0]) >= 17;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Recurse through `error.cause` chain to set cause on an error.
|
|
17
|
+
*/
|
|
18
|
+
function setCause(error, cause) {
|
|
19
|
+
const seenErrors = new WeakSet();
|
|
20
|
+
|
|
21
|
+
function recurse(error, cause) {
|
|
22
|
+
// If we've already seen the error, there is a recursive loop somewhere in the error's
|
|
23
|
+
// cause chain. Let's just bail out then to prevent a stack overflow.
|
|
24
|
+
if (seenErrors.has(error)) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (error.cause) {
|
|
28
|
+
seenErrors.add(error);
|
|
29
|
+
return recurse(error.cause, cause);
|
|
30
|
+
}
|
|
31
|
+
error.cause = cause;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
recurse(error, cause);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Captures an error that was thrown by a React ErrorBoundary or React root.
|
|
39
|
+
*
|
|
40
|
+
* @param error The error to capture.
|
|
41
|
+
* @param errorInfo The errorInfo provided by React.
|
|
42
|
+
* @param hint Optional additional data to attach to the Sentry event.
|
|
43
|
+
* @returns the id of the captured Sentry event.
|
|
44
|
+
*/
|
|
45
|
+
function captureReactException(
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
+
error,
|
|
48
|
+
{ componentStack },
|
|
49
|
+
hint,
|
|
50
|
+
) {
|
|
51
|
+
// If on React version >= 17, create stack trace from componentStack param and links
|
|
52
|
+
// to to the original error using `error.cause` otherwise relies on error param for stacktrace.
|
|
53
|
+
// Linking errors requires the `LinkedErrors` integration be enabled.
|
|
54
|
+
// See: https://reactjs.org/blog/2020/08/10/react-v17-rc.html#native-component-stacks
|
|
55
|
+
//
|
|
56
|
+
// Although `componentDidCatch` is typed to accept an `Error` object, it can also be invoked
|
|
57
|
+
// with non-error objects. This is why we need to check if the error is an error-like object.
|
|
58
|
+
// See: https://github.com/getsentry/sentry-javascript/issues/6167
|
|
59
|
+
if (isAtLeastReact17(React.version) && utils.isError(error) && componentStack) {
|
|
60
|
+
const errorBoundaryError = new Error(error.message);
|
|
61
|
+
errorBoundaryError.name = `React ErrorBoundary ${error.name}`;
|
|
62
|
+
errorBoundaryError.stack = componentStack;
|
|
63
|
+
|
|
64
|
+
// Using the `LinkedErrors` integration to link the errors together.
|
|
65
|
+
setCause(error, errorBoundaryError);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return browser.captureException(error, {
|
|
69
|
+
...hint,
|
|
70
|
+
captureContext: {
|
|
71
|
+
contexts: { react: { componentStack } },
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Creates an error handler that can be used with the `onCaughtError`, `onUncaughtError`,
|
|
78
|
+
* and `onRecoverableError` options in `createRoot` and `hydrateRoot` React DOM methods.
|
|
79
|
+
*
|
|
80
|
+
* @param callback An optional callback that will be called after the error is captured.
|
|
81
|
+
* Use this to add custom handling for errors.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
*
|
|
85
|
+
* ```JavaScript
|
|
86
|
+
* const root = createRoot(container, {
|
|
87
|
+
* onCaughtError: Sentry.reactErrorHandler(),
|
|
88
|
+
* onUncaughtError: Sentry.reactErrorHandler((error, errorInfo) => {
|
|
89
|
+
* console.warn('Caught error', error, errorInfo.componentStack);
|
|
90
|
+
* });
|
|
91
|
+
* });
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
function reactErrorHandler(
|
|
95
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
96
|
+
callback,
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
98
|
+
) {
|
|
99
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
100
|
+
return (error, errorInfo) => {
|
|
101
|
+
const eventId = captureReactException(error, errorInfo);
|
|
102
|
+
if (callback) {
|
|
103
|
+
callback(error, errorInfo, eventId);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
exports.captureReactException = captureReactException;
|
|
109
|
+
exports.isAtLeastReact17 = isAtLeastReact17;
|
|
110
|
+
exports.reactErrorHandler = reactErrorHandler;
|
|
111
|
+
exports.setCause = setCause;
|
|
112
|
+
//# sourceMappingURL=error.js.map
|
package/cjs/error.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sources":["../../src/error.ts"],"sourcesContent":["import { captureException } from '@sentry/browser';\nimport type { EventHint } from '@sentry/types';\nimport { isError } from '@sentry/utils';\nimport { version } from 'react';\nimport type { ErrorInfo } from 'react';\n\n/**\n * See if React major version is 17+ by parsing version string.\n */\nexport function isAtLeastReact17(reactVersion: string): boolean {\n const reactMajor = reactVersion.match(/^([^.]+)/);\n return reactMajor !== null && parseInt(reactMajor[0]) >= 17;\n}\n\n/**\n * Recurse through `error.cause` chain to set cause on an error.\n */\nexport function setCause(error: Error & { cause?: Error }, cause: Error): void {\n const seenErrors = new WeakSet();\n\n function recurse(error: Error & { cause?: Error }, cause: Error): void {\n // If we've already seen the error, there is a recursive loop somewhere in the error's\n // cause chain. Let's just bail out then to prevent a stack overflow.\n if (seenErrors.has(error)) {\n return;\n }\n if (error.cause) {\n seenErrors.add(error);\n return recurse(error.cause, cause);\n }\n error.cause = cause;\n }\n\n recurse(error, cause);\n}\n\n/**\n * Captures an error that was thrown by a React ErrorBoundary or React root.\n *\n * @param error The error to capture.\n * @param errorInfo The errorInfo provided by React.\n * @param hint Optional additional data to attach to the Sentry event.\n * @returns the id of the captured Sentry event.\n */\nexport function captureReactException(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n error: any,\n { componentStack }: ErrorInfo,\n hint?: EventHint,\n): string {\n // If on React version >= 17, create stack trace from componentStack param and links\n // to to the original error using `error.cause` otherwise relies on error param for stacktrace.\n // Linking errors requires the `LinkedErrors` integration be enabled.\n // See: https://reactjs.org/blog/2020/08/10/react-v17-rc.html#native-component-stacks\n //\n // Although `componentDidCatch` is typed to accept an `Error` object, it can also be invoked\n // with non-error objects. This is why we need to check if the error is an error-like object.\n // See: https://github.com/getsentry/sentry-javascript/issues/6167\n if (isAtLeastReact17(version) && isError(error) && componentStack) {\n const errorBoundaryError = new Error(error.message);\n errorBoundaryError.name = `React ErrorBoundary ${error.name}`;\n errorBoundaryError.stack = componentStack;\n\n // Using the `LinkedErrors` integration to link the errors together.\n setCause(error, errorBoundaryError);\n }\n\n return captureException(error, {\n ...hint,\n captureContext: {\n contexts: { react: { componentStack } },\n },\n });\n}\n\n/**\n * Creates an error handler that can be used with the `onCaughtError`, `onUncaughtError`,\n * and `onRecoverableError` options in `createRoot` and `hydrateRoot` React DOM methods.\n *\n * @param callback An optional callback that will be called after the error is captured.\n * Use this to add custom handling for errors.\n *\n * @example\n *\n * ```JavaScript\n * const root = createRoot(container, {\n * onCaughtError: Sentry.reactErrorHandler(),\n * onUncaughtError: Sentry.reactErrorHandler((error, errorInfo) => {\n * console.warn('Caught error', error, errorInfo.componentStack);\n * });\n * });\n * ```\n */\nexport function reactErrorHandler(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n callback?: (error: any, errorInfo: ErrorInfo, eventId: string) => void,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): (error: any, errorInfo: ErrorInfo) => void {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (error: any, errorInfo: ErrorInfo) => {\n const eventId = captureReactException(error, errorInfo);\n if (callback) {\n callback(error, errorInfo, eventId);\n }\n };\n}\n"],"names":["version","isError","captureException"],"mappings":";;;;;;AAMA;AACA;AACA;AACO,SAAS,gBAAgB,CAAC,YAAY,EAAmB;AAChE,EAAE,MAAM,aAAa,YAAY,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;AACnD,EAAE,OAAO,UAAA,KAAe,IAAA,IAAQ,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA,IAAK,EAAE,CAAA;AAC7D,CAAA;AACA;AACA;AACA;AACA;AACO,SAAS,QAAQ,CAAC,KAAK,EAA6B,KAAK,EAAe;AAC/E,EAAE,MAAM,UAAW,GAAE,IAAI,OAAO,EAAE,CAAA;AAClC;AACA,EAAE,SAAS,OAAO,CAAC,KAAK,EAA6B,KAAK,EAAe;AACzE;AACA;AACA,IAAI,IAAI,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;AAC/B,MAAM,OAAM;AACZ,KAAI;AACJ,IAAI,IAAI,KAAK,CAAC,KAAK,EAAE;AACrB,MAAM,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;AAC3B,MAAM,OAAO,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AACxC,KAAI;AACJ,IAAI,KAAK,CAAC,KAAM,GAAE,KAAK,CAAA;AACvB,GAAE;AACF;AACA,EAAE,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AACvB,CAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,qBAAqB;AACrC;AACA,EAAE,KAAK;AACP,EAAE,EAAE,gBAAgB;AACpB,EAAE,IAAI;AACN,EAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,IAAI,gBAAgB,CAACA,aAAO,CAAA,IAAKC,aAAO,CAAC,KAAK,CAAE,IAAG,cAAc,EAAE;AACrE,IAAI,MAAM,qBAAqB,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;AACvD,IAAI,kBAAkB,CAAC,IAAA,GAAO,CAAC,oBAAoB,EAAE,KAAK,CAAC,IAAI,CAAC,CAAA,CAAA;AACA,IAAA,kBAAA,CAAA,KAAA,GAAA,cAAA,CAAA;AACA;AACA;AACA,IAAA,QAAA,CAAA,KAAA,EAAA,kBAAA,CAAA,CAAA;AACA,GAAA;AACA;AACA,EAAA,OAAAC,wBAAA,CAAA,KAAA,EAAA;AACA,IAAA,GAAA,IAAA;AACA,IAAA,cAAA,EAAA;AACA,MAAA,QAAA,EAAA,EAAA,KAAA,EAAA,EAAA,cAAA,EAAA,EAAA;AACA,KAAA;AACA,GAAA,CAAA,CAAA;AACA,CAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAA,iBAAA;AACA;AACA,EAAA,QAAA;AACA;AACA,EAAA;AACA;AACA,EAAA,OAAA,CAAA,KAAA,EAAA,SAAA,KAAA;AACA,IAAA,MAAA,OAAA,GAAA,qBAAA,CAAA,KAAA,EAAA,SAAA,CAAA,CAAA;AACA,IAAA,IAAA,QAAA,EAAA;AACA,MAAA,QAAA,CAAA,KAAA,EAAA,SAAA,EAAA,OAAA,CAAA,CAAA;AACA,KAAA;AACA,GAAA,CAAA;AACA;;;;;;;"}
|
package/cjs/errorboundary.js
CHANGED
|
@@ -6,6 +6,7 @@ const utils = require('@sentry/utils');
|
|
|
6
6
|
const hoistNonReactStatics = require('hoist-non-react-statics');
|
|
7
7
|
const React = require('react');
|
|
8
8
|
const debugBuild = require('./debug-build.js');
|
|
9
|
+
const error = require('./error.js');
|
|
9
10
|
|
|
10
11
|
const _interopDefault = e => e && e.__esModule ? e.default : e;
|
|
11
12
|
|
|
@@ -24,11 +25,6 @@ function _interopNamespace(e) {
|
|
|
24
25
|
const hoistNonReactStatics__default = /*#__PURE__*/_interopDefault(hoistNonReactStatics);
|
|
25
26
|
const React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
26
27
|
|
|
27
|
-
function isAtLeastReact17(version) {
|
|
28
|
-
const major = version.match(/^([^.]+)/);
|
|
29
|
-
return major !== null && parseInt(major[0]) >= 17;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
28
|
const UNKNOWN_COMPONENT = 'unknown';
|
|
33
29
|
|
|
34
30
|
const INITIAL_STATE = {
|
|
@@ -37,25 +33,6 @@ const INITIAL_STATE = {
|
|
|
37
33
|
eventId: null,
|
|
38
34
|
};
|
|
39
35
|
|
|
40
|
-
function setCause(error, cause) {
|
|
41
|
-
const seenErrors = new WeakMap();
|
|
42
|
-
|
|
43
|
-
function recurse(error, cause) {
|
|
44
|
-
// If we've already seen the error, there is a recursive loop somewhere in the error's
|
|
45
|
-
// cause chain. Let's just bail out then to prevent a stack overflow.
|
|
46
|
-
if (seenErrors.has(error)) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
if (error.cause) {
|
|
50
|
-
seenErrors.set(error, true);
|
|
51
|
-
return recurse(error.cause, cause);
|
|
52
|
-
}
|
|
53
|
-
error.cause = cause;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
recurse(error, cause);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
36
|
/**
|
|
60
37
|
* A ErrorBoundary component that logs errors to Sentry.
|
|
61
38
|
* NOTE: If you are a Sentry user, and you are seeing this stack frame, it means the
|
|
@@ -80,41 +57,21 @@ class ErrorBoundary extends React__namespace.Component {
|
|
|
80
57
|
}
|
|
81
58
|
}
|
|
82
59
|
|
|
83
|
-
componentDidCatch(error,
|
|
60
|
+
componentDidCatch(error$1, errorInfo) {
|
|
61
|
+
const { componentStack } = errorInfo;
|
|
62
|
+
// TODO(v9): Remove this check and type `componentStack` to be React.ErrorInfo['componentStack'].
|
|
63
|
+
const passedInComponentStack = componentStack == null ? undefined : componentStack;
|
|
64
|
+
|
|
84
65
|
const { beforeCapture, onError, showDialog, dialogOptions } = this.props;
|
|
85
66
|
browser.withScope(scope => {
|
|
86
|
-
// If on React version >= 17, create stack trace from componentStack param and links
|
|
87
|
-
// to to the original error using `error.cause` otherwise relies on error param for stacktrace.
|
|
88
|
-
// Linking errors requires the `LinkedErrors` integration be enabled.
|
|
89
|
-
// See: https://reactjs.org/blog/2020/08/10/react-v17-rc.html#native-component-stacks
|
|
90
|
-
//
|
|
91
|
-
// Although `componentDidCatch` is typed to accept an `Error` object, it can also be invoked
|
|
92
|
-
// with non-error objects. This is why we need to check if the error is an error-like object.
|
|
93
|
-
// See: https://github.com/getsentry/sentry-javascript/issues/6167
|
|
94
|
-
if (isAtLeastReact17(React__namespace.version) && utils.isError(error)) {
|
|
95
|
-
const errorBoundaryError = new Error(error.message);
|
|
96
|
-
errorBoundaryError.name = `React ErrorBoundary ${error.name}`;
|
|
97
|
-
errorBoundaryError.stack = componentStack;
|
|
98
|
-
|
|
99
|
-
// Using the `LinkedErrors` integration to link the errors together.
|
|
100
|
-
setCause(error, errorBoundaryError);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
67
|
if (beforeCapture) {
|
|
104
|
-
beforeCapture(scope, error,
|
|
68
|
+
beforeCapture(scope, error$1, passedInComponentStack);
|
|
105
69
|
}
|
|
106
70
|
|
|
107
|
-
const eventId =
|
|
108
|
-
captureContext: {
|
|
109
|
-
contexts: { react: { componentStack } },
|
|
110
|
-
},
|
|
111
|
-
// If users provide a fallback component we can assume they are handling the error.
|
|
112
|
-
// Therefore, we set the mechanism depending on the presence of the fallback prop.
|
|
113
|
-
mechanism: { handled: !!this.props.fallback },
|
|
114
|
-
});
|
|
71
|
+
const eventId = error.captureReactException(error$1, errorInfo, { mechanism: { handled: !!this.props.fallback } });
|
|
115
72
|
|
|
116
73
|
if (onError) {
|
|
117
|
-
onError(error,
|
|
74
|
+
onError(error$1, passedInComponentStack, eventId);
|
|
118
75
|
}
|
|
119
76
|
if (showDialog) {
|
|
120
77
|
this._lastEventId = eventId;
|
|
@@ -125,7 +82,7 @@ class ErrorBoundary extends React__namespace.Component {
|
|
|
125
82
|
|
|
126
83
|
// componentDidCatch is used over getDerivedStateFromError
|
|
127
84
|
// so that componentStack is accessible through state.
|
|
128
|
-
this.setState({ error, componentStack, eventId });
|
|
85
|
+
this.setState({ error: error$1, componentStack, eventId });
|
|
129
86
|
});
|
|
130
87
|
}
|
|
131
88
|
|
|
@@ -194,7 +151,6 @@ function withErrorBoundary(
|
|
|
194
151
|
WrappedComponent,
|
|
195
152
|
errorBoundaryOptions,
|
|
196
153
|
) {
|
|
197
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
198
154
|
const componentDisplayName = WrappedComponent.displayName || WrappedComponent.name || UNKNOWN_COMPONENT;
|
|
199
155
|
|
|
200
156
|
const Wrapped = (props) => (
|
|
@@ -203,7 +159,6 @@ function withErrorBoundary(
|
|
|
203
159
|
})
|
|
204
160
|
);
|
|
205
161
|
|
|
206
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
207
162
|
Wrapped.displayName = `errorBoundary(${componentDisplayName})`;
|
|
208
163
|
|
|
209
164
|
// Copy over static methods from Wrapped component to Profiler HOC
|
|
@@ -214,6 +169,5 @@ function withErrorBoundary(
|
|
|
214
169
|
|
|
215
170
|
exports.ErrorBoundary = ErrorBoundary;
|
|
216
171
|
exports.UNKNOWN_COMPONENT = UNKNOWN_COMPONENT;
|
|
217
|
-
exports.isAtLeastReact17 = isAtLeastReact17;
|
|
218
172
|
exports.withErrorBoundary = withErrorBoundary;
|
|
219
173
|
//# sourceMappingURL=errorboundary.js.map
|
package/cjs/errorboundary.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorboundary.js","sources":["../../src/errorboundary.tsx"],"sourcesContent":["import type { ReportDialogOptions } from '@sentry/browser';\nimport { captureException, getClient, showReportDialog, withScope } from '@sentry/browser';\nimport type { Scope } from '@sentry/types';\nimport { isError, logger } from '@sentry/utils';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\n\nimport { DEBUG_BUILD } from './debug-build';\n\nexport function isAtLeastReact17(version: string): boolean {\n const major = version.match(/^([^.]+)/);\n return major !== null && parseInt(major[0]) >= 17;\n}\n\nexport const UNKNOWN_COMPONENT = 'unknown';\n\nexport type FallbackRender = (errorData: {\n error: unknown;\n componentStack: string;\n eventId: string;\n resetError(): void;\n}) => React.ReactElement;\n\nexport type ErrorBoundaryProps = {\n children?: React.ReactNode | (() => React.ReactNode);\n /** If a Sentry report dialog should be rendered on error */\n showDialog?: boolean | undefined;\n /**\n * Options to be passed into the Sentry report dialog.\n * No-op if {@link showDialog} is false.\n */\n dialogOptions?: ReportDialogOptions | undefined;\n /**\n * A fallback component that gets rendered when the error boundary encounters an error.\n *\n * Can either provide a React Component, or a function that returns React Component as\n * a valid fallback prop. If a function is provided, the function will be called with\n * the error, the component stack, and an function that resets the error boundary on error.\n *\n */\n fallback?: React.ReactElement | FallbackRender | undefined;\n /** Called when the error boundary encounters an error */\n onError?: ((error: unknown, componentStack: string, eventId: string) => void) | undefined;\n /** Called on componentDidMount() */\n onMount?: (() => void) | undefined;\n /** Called if resetError() is called from the fallback render props function */\n onReset?: ((error: unknown, componentStack: string | null, eventId: string | null) => void) | undefined;\n /** Called on componentWillUnmount() */\n onUnmount?: ((error: unknown, componentStack: string | null, eventId: string | null) => void) | undefined;\n /** Called before the error is captured by Sentry, allows for you to add tags or context using the scope */\n beforeCapture?: ((scope: Scope, error: unknown, componentStack: string | undefined) => void) | undefined;\n};\n\ntype ErrorBoundaryState =\n | {\n componentStack: null;\n error: null;\n eventId: null;\n }\n | {\n componentStack: React.ErrorInfo['componentStack'];\n error: unknown;\n eventId: string;\n };\n\nconst INITIAL_STATE = {\n componentStack: null,\n error: null,\n eventId: null,\n};\n\nfunction setCause(error: Error & { cause?: Error }, cause: Error): void {\n const seenErrors = new WeakMap<Error, boolean>();\n\n function recurse(error: Error & { cause?: Error }, cause: Error): void {\n // If we've already seen the error, there is a recursive loop somewhere in the error's\n // cause chain. Let's just bail out then to prevent a stack overflow.\n if (seenErrors.has(error)) {\n return;\n }\n if (error.cause) {\n seenErrors.set(error, true);\n return recurse(error.cause, cause);\n }\n error.cause = cause;\n }\n\n recurse(error, cause);\n}\n\n/**\n * A ErrorBoundary component that logs errors to Sentry.\n * NOTE: If you are a Sentry user, and you are seeing this stack frame, it means the\n * Sentry React SDK ErrorBoundary caught an error invoking your application code. This\n * is expected behavior and NOT indicative of a bug with the Sentry React SDK.\n */\nclass ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {\n public state: ErrorBoundaryState;\n\n private readonly _openFallbackReportDialog: boolean;\n\n private _lastEventId?: string;\n\n public constructor(props: ErrorBoundaryProps) {\n super(props);\n\n this.state = INITIAL_STATE;\n this._openFallbackReportDialog = true;\n\n const client = getClient();\n if (client && props.showDialog) {\n this._openFallbackReportDialog = false;\n client.on('afterSendEvent', event => {\n if (!event.type && this._lastEventId && event.event_id === this._lastEventId) {\n showReportDialog({ ...props.dialogOptions, eventId: this._lastEventId });\n }\n });\n }\n }\n\n public componentDidCatch(error: unknown, { componentStack }: React.ErrorInfo): void {\n const { beforeCapture, onError, showDialog, dialogOptions } = this.props;\n withScope(scope => {\n // If on React version >= 17, create stack trace from componentStack param and links\n // to to the original error using `error.cause` otherwise relies on error param for stacktrace.\n // Linking errors requires the `LinkedErrors` integration be enabled.\n // See: https://reactjs.org/blog/2020/08/10/react-v17-rc.html#native-component-stacks\n //\n // Although `componentDidCatch` is typed to accept an `Error` object, it can also be invoked\n // with non-error objects. This is why we need to check if the error is an error-like object.\n // See: https://github.com/getsentry/sentry-javascript/issues/6167\n if (isAtLeastReact17(React.version) && isError(error)) {\n const errorBoundaryError = new Error(error.message);\n errorBoundaryError.name = `React ErrorBoundary ${error.name}`;\n errorBoundaryError.stack = componentStack;\n\n // Using the `LinkedErrors` integration to link the errors together.\n setCause(error, errorBoundaryError);\n }\n\n if (beforeCapture) {\n beforeCapture(scope, error, componentStack);\n }\n\n const eventId = captureException(error, {\n captureContext: {\n contexts: { react: { componentStack } },\n },\n // If users provide a fallback component we can assume they are handling the error.\n // Therefore, we set the mechanism depending on the presence of the fallback prop.\n mechanism: { handled: !!this.props.fallback },\n });\n\n if (onError) {\n onError(error, componentStack, eventId);\n }\n if (showDialog) {\n this._lastEventId = eventId;\n if (this._openFallbackReportDialog) {\n showReportDialog({ ...dialogOptions, eventId });\n }\n }\n\n // componentDidCatch is used over getDerivedStateFromError\n // so that componentStack is accessible through state.\n this.setState({ error, componentStack, eventId });\n });\n }\n\n public componentDidMount(): void {\n const { onMount } = this.props;\n if (onMount) {\n onMount();\n }\n }\n\n public componentWillUnmount(): void {\n const { error, componentStack, eventId } = this.state;\n const { onUnmount } = this.props;\n if (onUnmount) {\n onUnmount(error, componentStack, eventId);\n }\n }\n\n public resetErrorBoundary: () => void = () => {\n const { onReset } = this.props;\n const { error, componentStack, eventId } = this.state;\n if (onReset) {\n onReset(error, componentStack, eventId);\n }\n this.setState(INITIAL_STATE);\n };\n\n public render(): React.ReactNode {\n const { fallback, children } = this.props;\n const state = this.state;\n\n if (state.error) {\n let element: React.ReactElement | undefined = undefined;\n if (typeof fallback === 'function') {\n element = React.createElement(fallback, {\n error: state.error,\n componentStack: state.componentStack as string,\n resetError: this.resetErrorBoundary,\n eventId: state.eventId as string,\n });\n } else {\n element = fallback;\n }\n\n if (React.isValidElement(element)) {\n return element;\n }\n\n if (fallback) {\n DEBUG_BUILD && logger.warn('fallback did not produce a valid ReactElement');\n }\n\n // Fail gracefully if no fallback provided or is not valid\n return null;\n }\n\n if (typeof children === 'function') {\n return (children as () => React.ReactNode)();\n }\n return children;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction withErrorBoundary<P extends Record<string, any>>(\n WrappedComponent: React.ComponentType<P>,\n errorBoundaryOptions: ErrorBoundaryProps,\n): React.FC<P> {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const componentDisplayName = WrappedComponent.displayName || WrappedComponent.name || UNKNOWN_COMPONENT;\n\n const Wrapped: React.FC<P> = (props: P) => (\n <ErrorBoundary {...errorBoundaryOptions}>\n <WrappedComponent {...props} />\n </ErrorBoundary>\n );\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n Wrapped.displayName = `errorBoundary(${componentDisplayName})`;\n\n // Copy over static methods from Wrapped component to Profiler HOC\n // See: https://reactjs.org/docs/higher-order-components.html#static-methods-must-be-copied-over\n hoistNonReactStatics(Wrapped, WrappedComponent);\n return Wrapped;\n}\n\nexport { ErrorBoundary, withErrorBoundary };\n"],"names":["React","getClient","showReportDialog","withScope","isError","captureException","DEBUG_BUILD","logger","_jsx","hoistNonReactStatics"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AASO,SAAS,gBAAgB,CAAC,OAAO,EAAmB;AAC3D,EAAE,MAAM,QAAQ,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;AACzC,EAAE,OAAO,KAAA,KAAU,IAAA,IAAQ,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA,IAAK,EAAE,CAAA;AACnD,CAAA;AACA;AACO,MAAM,iBAAkB,GAAE,UAAS;;AAmD1C,MAAM,gBAAgB;AACtB,EAAE,cAAc,EAAE,IAAI;AACtB,EAAE,KAAK,EAAE,IAAI;AACb,EAAE,OAAO,EAAE,IAAI;AACf,CAAC,CAAA;AACD;AACA,SAAS,QAAQ,CAAC,KAAK,EAA6B,KAAK,EAAe;AACxE,EAAE,MAAM,UAAW,GAAE,IAAI,OAAO,EAAkB,CAAA;AAClD;AACA,EAAE,SAAS,OAAO,CAAC,KAAK,EAA6B,KAAK,EAAe;AACzE;AACA;AACA,IAAI,IAAI,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,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AAA,EAAA;AACA,KAAA,CAAA;AACA,GAAA,CAAA;AACA;AACA;AACA,EAAA,OAAA,CAAA,WAAA,GAAA,CAAA,cAAA,EAAA,oBAAA,CAAA,CAAA,CAAA,CAAA;AACA;AACA;AACA;AACA,EAAAC,6BAAA,CAAA,OAAA,EAAA,gBAAA,CAAA,CAAA;AACA,EAAA,OAAA,OAAA,CAAA;AACA;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"errorboundary.js","sources":["../../src/errorboundary.tsx"],"sourcesContent":["import type { ReportDialogOptions } from '@sentry/browser';\nimport { getClient, showReportDialog, withScope } from '@sentry/browser';\nimport type { Scope } from '@sentry/types';\nimport { logger } from '@sentry/utils';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\n\nimport { DEBUG_BUILD } from './debug-build';\nimport { captureReactException } from './error';\n\nexport const UNKNOWN_COMPONENT = 'unknown';\n\nexport type FallbackRender = (errorData: {\n error: unknown;\n componentStack: string;\n eventId: string;\n resetError(): void;\n}) => React.ReactElement;\n\nexport type ErrorBoundaryProps = {\n children?: React.ReactNode | (() => React.ReactNode);\n /** If a Sentry report dialog should be rendered on error */\n showDialog?: boolean | undefined;\n /**\n * Options to be passed into the Sentry report dialog.\n * No-op if {@link showDialog} is false.\n */\n dialogOptions?: ReportDialogOptions | undefined;\n /**\n * A fallback component that gets rendered when the error boundary encounters an error.\n *\n * Can either provide a React Component, or a function that returns React Component as\n * a valid fallback prop. If a function is provided, the function will be called with\n * the error, the component stack, and an function that resets the error boundary on error.\n *\n */\n fallback?: React.ReactElement | FallbackRender | undefined;\n /** Called when the error boundary encounters an error */\n onError?: ((error: unknown, componentStack: string | undefined, eventId: string) => void) | undefined;\n /** Called on componentDidMount() */\n onMount?: (() => void) | undefined;\n /** Called if resetError() is called from the fallback render props function */\n onReset?: ((error: unknown, componentStack: string | null | undefined, eventId: string | null) => void) | undefined;\n /** Called on componentWillUnmount() */\n onUnmount?: ((error: unknown, componentStack: string | null | undefined, eventId: string | null) => void) | undefined;\n /** Called before the error is captured by Sentry, allows for you to add tags or context using the scope */\n beforeCapture?: ((scope: Scope, error: unknown, componentStack: string | undefined) => void) | undefined;\n};\n\ntype ErrorBoundaryState =\n | {\n componentStack: null;\n error: null;\n eventId: null;\n }\n | {\n componentStack: React.ErrorInfo['componentStack'];\n error: unknown;\n eventId: string;\n };\n\nconst INITIAL_STATE = {\n componentStack: null,\n error: null,\n eventId: null,\n};\n\n/**\n * A ErrorBoundary component that logs errors to Sentry.\n * NOTE: If you are a Sentry user, and you are seeing this stack frame, it means the\n * Sentry React SDK ErrorBoundary caught an error invoking your application code. This\n * is expected behavior and NOT indicative of a bug with the Sentry React SDK.\n */\nclass ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {\n public state: ErrorBoundaryState;\n\n private readonly _openFallbackReportDialog: boolean;\n\n private _lastEventId?: string;\n\n public constructor(props: ErrorBoundaryProps) {\n super(props);\n\n this.state = INITIAL_STATE;\n this._openFallbackReportDialog = true;\n\n const client = getClient();\n if (client && props.showDialog) {\n this._openFallbackReportDialog = false;\n client.on('afterSendEvent', event => {\n if (!event.type && this._lastEventId && event.event_id === this._lastEventId) {\n showReportDialog({ ...props.dialogOptions, eventId: this._lastEventId });\n }\n });\n }\n }\n\n public componentDidCatch(error: unknown, errorInfo: React.ErrorInfo): void {\n const { componentStack } = errorInfo;\n // TODO(v9): Remove this check and type `componentStack` to be React.ErrorInfo['componentStack'].\n const passedInComponentStack: string | undefined = componentStack == null ? undefined : componentStack;\n\n const { beforeCapture, onError, showDialog, dialogOptions } = this.props;\n withScope(scope => {\n if (beforeCapture) {\n beforeCapture(scope, error, passedInComponentStack);\n }\n\n const eventId = captureReactException(error, errorInfo, { mechanism: { handled: !!this.props.fallback } });\n\n if (onError) {\n onError(error, passedInComponentStack, eventId);\n }\n if (showDialog) {\n this._lastEventId = eventId;\n if (this._openFallbackReportDialog) {\n showReportDialog({ ...dialogOptions, eventId });\n }\n }\n\n // componentDidCatch is used over getDerivedStateFromError\n // so that componentStack is accessible through state.\n this.setState({ error, componentStack, eventId });\n });\n }\n\n public componentDidMount(): void {\n const { onMount } = this.props;\n if (onMount) {\n onMount();\n }\n }\n\n public componentWillUnmount(): void {\n const { error, componentStack, eventId } = this.state;\n const { onUnmount } = this.props;\n if (onUnmount) {\n onUnmount(error, componentStack, eventId);\n }\n }\n\n public resetErrorBoundary: () => void = () => {\n const { onReset } = this.props;\n const { error, componentStack, eventId } = this.state;\n if (onReset) {\n onReset(error, componentStack, eventId);\n }\n this.setState(INITIAL_STATE);\n };\n\n public render(): React.ReactNode {\n const { fallback, children } = this.props;\n const state = this.state;\n\n if (state.error) {\n let element: React.ReactElement | undefined = undefined;\n if (typeof fallback === 'function') {\n element = React.createElement(fallback, {\n error: state.error,\n componentStack: state.componentStack as string,\n resetError: this.resetErrorBoundary,\n eventId: state.eventId as string,\n });\n } else {\n element = fallback;\n }\n\n if (React.isValidElement(element)) {\n return element;\n }\n\n if (fallback) {\n DEBUG_BUILD && logger.warn('fallback did not produce a valid ReactElement');\n }\n\n // Fail gracefully if no fallback provided or is not valid\n return null;\n }\n\n if (typeof children === 'function') {\n return (children as () => React.ReactNode)();\n }\n return children;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction withErrorBoundary<P extends Record<string, any>>(\n WrappedComponent: React.ComponentType<P>,\n errorBoundaryOptions: ErrorBoundaryProps,\n): React.FC<P> {\n const componentDisplayName = WrappedComponent.displayName || WrappedComponent.name || UNKNOWN_COMPONENT;\n\n const Wrapped: React.FC<P> = (props: P) => (\n <ErrorBoundary {...errorBoundaryOptions}>\n <WrappedComponent {...props} />\n </ErrorBoundary>\n );\n\n Wrapped.displayName = `errorBoundary(${componentDisplayName})`;\n\n // Copy over static methods from Wrapped component to Profiler HOC\n // See: https://reactjs.org/docs/higher-order-components.html#static-methods-must-be-copied-over\n hoistNonReactStatics(Wrapped, WrappedComponent);\n return Wrapped;\n}\n\nexport { ErrorBoundary, withErrorBoundary };\n"],"names":["React","getClient","showReportDialog","error","withScope","captureReactException","DEBUG_BUILD","logger","_jsx","hoistNonReactStatics"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAUO,MAAM,iBAAkB,GAAE,UAAS;;AAmD1C,MAAM,gBAAgB;AACtB,EAAE,cAAc,EAAE,IAAI;AACtB,EAAE,KAAK,EAAE,IAAI;AACb,EAAE,OAAO,EAAE,IAAI;AACf,CAAC,CAAA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,aAAc,SAAQA,gBAAK,CAAC,SAAS,CAAyC;;AAOpF,GAAS,WAAW,CAAC,KAAK,EAAsB;AAChD,IAAI,KAAK,CAAC,KAAK,CAAC,CAAA,aAAA,CAAA,SAAA,CAAA,MAAA,CAAA,IAAA,CAAA,IAAA,CAAA,CAChB;AACA,IAAI,IAAI,CAAC,KAAM,GAAE,aAAa,CAAA;AAC9B,IAAI,IAAI,CAAC,yBAA0B,GAAE,IAAI,CAAA;AACzC;AACA,IAAI,MAAM,MAAA,GAASC,iBAAS,EAAE,CAAA;AAC9B,IAAI,IAAI,MAAA,IAAU,KAAK,CAAC,UAAU,EAAE;AACpC,MAAM,IAAI,CAAC,yBAA0B,GAAE,KAAK,CAAA;AAC5C,MAAM,MAAM,CAAC,EAAE,CAAC,gBAAgB,EAAE,SAAS;AAC3C,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAA,IAAQ,IAAI,CAAC,YAAa,IAAG,KAAK,CAAC,QAAA,KAAa,IAAI,CAAC,YAAY,EAAE;AACtF,UAAUC,wBAAgB,CAAC,EAAE,GAAG,KAAK,CAAC,aAAa,EAAE,OAAO,EAAE,IAAI,CAAC,YAAA,EAAc,CAAC,CAAA;AAClF,SAAQ;AACR,OAAO,CAAC,CAAA;AACR,KAAI;AACJ,GAAE;AACF;AACA,GAAS,iBAAiB,CAACC,OAAK,EAAW,SAAS,EAAyB;AAC7E,IAAI,MAAM,EAAE,cAAe,EAAA,GA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,QAAQ,CAAA;AAC1B,OAAM;AACN;AACA,MAAM,IAAIA,gBAAK,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE;AACzC,QAAQ,OAAO,OAAO,CAAA;AACtB,OAAM;AACN;AACA,MAAM,IAAI,QAAQ,EAAE;AACpB,QAAQM,0BAAeC,YAAM,CAAC,IAAI,CAAC,+CAA+C,CAAC,CAAA;AACnF,OAAM;AACN;AACA;AACA,MAAM,OAAO,IAAI,CAAA;AACjB,KAAI;AACJ;AACA,IAAI,IAAI,OAAO,QAAS,KAAI,UAAU,EAAE;AACxC,MAAM,OAAO,CAAC,QAAS,IAA2B,CAAA;AAClD,KAAI;AACJ,IAAI,OAAO,QAAQ,CAAA;AACnB,GAAE;AACF,CAAA;AACA;AACA;AACA,SAAS,iBAAiB;AAC1B,EAAE,gBAAgB;AAClB,EAAE,oBAAoB;AACtB,EAAe;AACf,EAAE,MAAM,oBAAqB,GAAE,gBAAgB,CAAC,WAAY,IAAG,gBAAgB,CAAC,IAAK,IAAG,iBAAiB,CAAA;AACzG;AACA,EAAE,MAAM,OAAO,GAAgB,CAAC,KAAK;AACrC,IAAIC,cAAC,CAAA,aAAA,EAAA,EAAc,GAAI,oBAAoB,EAAE,QAAA;AAC7C,MAAMA,cAAC,CAAA,gBAAA,EAAA,EAAiB,GAAI,KAAK,IAAI;AACrC,KAAI,CAAA;AACJ,GAAG,CAAA;AACH;AACA,EAAE,OAAO,CAAC,WAAA,GAAc,CAAC,cAAc,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAA;AAChE;AACA;AACA;AACA,EAAEC,6BAAoB,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAA;AACjD,EAAE,OAAO,OAAO,CAAA;AAChB;;;;;;"}
|
package/cjs/index.js
CHANGED
|
@@ -2,16 +2,19 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
2
2
|
|
|
3
3
|
const browser = require('@sentry/browser');
|
|
4
4
|
const sdk = require('./sdk.js');
|
|
5
|
+
const error = require('./error.js');
|
|
5
6
|
const profiler = require('./profiler.js');
|
|
6
7
|
const errorboundary = require('./errorboundary.js');
|
|
7
8
|
const redux = require('./redux.js');
|
|
8
9
|
const reactrouterv3 = require('./reactrouterv3.js');
|
|
10
|
+
const tanstackrouter = require('./tanstackrouter.js');
|
|
9
11
|
const reactrouter = require('./reactrouter.js');
|
|
10
12
|
const reactrouterv6 = require('./reactrouterv6.js');
|
|
11
13
|
|
|
12
14
|
|
|
13
15
|
|
|
14
16
|
exports.init = sdk.init;
|
|
17
|
+
exports.reactErrorHandler = error.reactErrorHandler;
|
|
15
18
|
exports.Profiler = profiler.Profiler;
|
|
16
19
|
exports.useProfiler = profiler.useProfiler;
|
|
17
20
|
exports.withProfiler = profiler.withProfiler;
|
|
@@ -19,6 +22,7 @@ exports.ErrorBoundary = errorboundary.ErrorBoundary;
|
|
|
19
22
|
exports.withErrorBoundary = errorboundary.withErrorBoundary;
|
|
20
23
|
exports.createReduxEnhancer = redux.createReduxEnhancer;
|
|
21
24
|
exports.reactRouterV3BrowserTracingIntegration = reactrouterv3.reactRouterV3BrowserTracingIntegration;
|
|
25
|
+
exports.tanstackRouterBrowserTracingIntegration = tanstackrouter.tanstackRouterBrowserTracingIntegration;
|
|
22
26
|
exports.reactRouterV4BrowserTracingIntegration = reactrouter.reactRouterV4BrowserTracingIntegration;
|
|
23
27
|
exports.reactRouterV5BrowserTracingIntegration = reactrouter.reactRouterV5BrowserTracingIntegration;
|
|
24
28
|
exports.withSentryRouting = reactrouter.withSentryRouting;
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/cjs/reactrouterv6.js
CHANGED
|
@@ -19,7 +19,7 @@ let _createRoutesFromChildren;
|
|
|
19
19
|
let _matchRoutes;
|
|
20
20
|
let _stripBasename = false;
|
|
21
21
|
|
|
22
|
-
const CLIENTS_WITH_INSTRUMENT_NAVIGATION =
|
|
22
|
+
const CLIENTS_WITH_INSTRUMENT_NAVIGATION = new WeakSet();
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* A browser tracing integration that uses React Router v6 to instrument navigations.
|
|
@@ -71,7 +71,7 @@ function reactRouterV6BrowserTracingIntegration(
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
if (instrumentNavigation) {
|
|
74
|
-
CLIENTS_WITH_INSTRUMENT_NAVIGATION.
|
|
74
|
+
CLIENTS_WITH_INSTRUMENT_NAVIGATION.add(client);
|
|
75
75
|
}
|
|
76
76
|
},
|
|
77
77
|
};
|
|
@@ -185,7 +185,7 @@ function handleNavigation(
|
|
|
185
185
|
const branches = Array.isArray(matches) ? matches : _matchRoutes(routes, location, basename);
|
|
186
186
|
|
|
187
187
|
const client = core.getClient();
|
|
188
|
-
if (!client || !CLIENTS_WITH_INSTRUMENT_NAVIGATION.
|
|
188
|
+
if (!client || !CLIENTS_WITH_INSTRUMENT_NAVIGATION.has(client)) {
|
|
189
189
|
return;
|
|
190
190
|
}
|
|
191
191
|
|
package/cjs/reactrouterv6.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactrouterv6.js","sources":["../../src/reactrouterv6.tsx"],"sourcesContent":["// Inspired from Donnie McNeal's solution:\n// https://gist.github.com/wontondon/e8c4bdf2888875e4c755712e99279536\n\nimport {\n WINDOW,\n browserTracingIntegration,\n startBrowserTracingNavigationSpan,\n startBrowserTracingPageLoadSpan,\n} from '@sentry/browser';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n getActiveSpan,\n getClient,\n getCurrentScope,\n getRootSpan,\n spanToJSON,\n} from '@sentry/core';\nimport type { Client, Integration, Span, TransactionSource } from '@sentry/types';\nimport { getNumberOfUrlSegments, logger } from '@sentry/utils';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\n\nimport { DEBUG_BUILD } from './debug-build';\nimport type {\n Action,\n AgnosticDataRouteMatch,\n CreateRouterFunction,\n CreateRoutesFromChildren,\n Location,\n MatchRoutes,\n RouteMatch,\n RouteObject,\n Router,\n RouterState,\n UseEffect,\n UseLocation,\n UseNavigationType,\n UseRoutes,\n} from './types';\n\nlet _useEffect: UseEffect;\nlet _useLocation: UseLocation;\nlet _useNavigationType: UseNavigationType;\nlet _createRoutesFromChildren: CreateRoutesFromChildren;\nlet _matchRoutes: MatchRoutes;\nlet _stripBasename: boolean = false;\n\nconst CLIENTS_WITH_INSTRUMENT_NAVIGATION: Client[] = [];\n\ninterface ReactRouterOptions {\n useEffect: UseEffect;\n useLocation: UseLocation;\n useNavigationType: UseNavigationType;\n createRoutesFromChildren: CreateRoutesFromChildren;\n matchRoutes: MatchRoutes;\n stripBasename?: boolean;\n}\n\n/**\n * A browser tracing integration that uses React Router v6 to instrument navigations.\n * Expects `useEffect`, `useLocation`, `useNavigationType`, `createRoutesFromChildren` and `matchRoutes` to be passed as options.\n */\nexport function reactRouterV6BrowserTracingIntegration(\n options: Parameters<typeof browserTracingIntegration>[0] & ReactRouterOptions,\n): Integration {\n const integration = browserTracingIntegration({\n ...options,\n instrumentPageLoad: false,\n instrumentNavigation: false,\n });\n\n const {\n useEffect,\n useLocation,\n useNavigationType,\n createRoutesFromChildren,\n matchRoutes,\n stripBasename,\n instrumentPageLoad = true,\n instrumentNavigation = true,\n } = options;\n\n return {\n ...integration,\n setup() {\n _useEffect = useEffect;\n _useLocation = useLocation;\n _useNavigationType = useNavigationType;\n _matchRoutes = matchRoutes;\n _createRoutesFromChildren = createRoutesFromChildren;\n _stripBasename = stripBasename || false;\n },\n afterAllSetup(client) {\n integration.afterAllSetup(client);\n\n const initPathName = WINDOW && WINDOW.location && WINDOW.location.pathname;\n if (instrumentPageLoad && initPathName) {\n startBrowserTracingPageLoadSpan(client, {\n name: initPathName,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'pageload',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.pageload.react.reactrouter_v6',\n },\n });\n }\n\n if (instrumentNavigation) {\n CLIENTS_WITH_INSTRUMENT_NAVIGATION.push(client);\n }\n },\n };\n}\n\n/**\n * Strip the basename from a pathname if exists.\n *\n * Vendored and modified from `react-router`\n * https://github.com/remix-run/react-router/blob/462bb712156a3f739d6139a0f14810b76b002df6/packages/router/utils.ts#L1038\n */\nfunction stripBasenameFromPathname(pathname: string, basename: string): string {\n if (!basename || basename === '/') {\n return pathname;\n }\n\n if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) {\n return pathname;\n }\n\n // We want to leave trailing slash behavior in the user's control, so if they\n // specify a basename with a trailing slash, we should support it\n const startIndex = basename.endsWith('/') ? basename.length - 1 : basename.length;\n const nextChar = pathname.charAt(startIndex);\n if (nextChar && nextChar !== '/') {\n // pathname does not start with basename/\n return pathname;\n }\n\n return pathname.slice(startIndex) || '/';\n}\n\nfunction getNormalizedName(\n routes: RouteObject[],\n location: Location,\n branches: RouteMatch[],\n basename: string = '',\n): [string, TransactionSource] {\n if (!routes || routes.length === 0) {\n return [_stripBasename ? stripBasenameFromPathname(location.pathname, basename) : location.pathname, 'url'];\n }\n\n let pathBuilder = '';\n if (branches) {\n // eslint-disable-next-line @typescript-eslint/prefer-for-of\n for (let x = 0; x < branches.length; x++) {\n const branch = branches[x];\n const route = branch.route;\n if (route) {\n // Early return if index route\n if (route.index) {\n return [_stripBasename ? stripBasenameFromPathname(branch.pathname, basename) : branch.pathname, 'route'];\n }\n\n const path = route.path;\n if (path) {\n const newPath = path[0] === '/' || pathBuilder[pathBuilder.length - 1] === '/' ? path : `/${path}`;\n pathBuilder += newPath;\n\n if (basename + branch.pathname === location.pathname) {\n if (\n // If the route defined on the element is something like\n // <Route path=\"/stores/:storeId/products/:productId\" element={<div>Product</div>} />\n // We should check against the branch.pathname for the number of / seperators\n getNumberOfUrlSegments(pathBuilder) !== getNumberOfUrlSegments(branch.pathname) &&\n // We should not count wildcard operators in the url segments calculation\n pathBuilder.slice(-2) !== '/*'\n ) {\n return [(_stripBasename ? '' : basename) + newPath, 'route'];\n }\n return [(_stripBasename ? '' : basename) + pathBuilder, 'route'];\n }\n }\n }\n }\n }\n\n return [_stripBasename ? stripBasenameFromPathname(location.pathname, basename) : location.pathname, 'url'];\n}\n\nfunction updatePageloadTransaction(\n activeRootSpan: Span | undefined,\n location: Location,\n routes: RouteObject[],\n matches?: AgnosticDataRouteMatch,\n basename?: string,\n): void {\n const branches = Array.isArray(matches)\n ? matches\n : (_matchRoutes(routes, location, basename) as unknown as RouteMatch[]);\n\n if (branches) {\n const [name, source] = getNormalizedName(routes, location, branches, basename);\n\n getCurrentScope().setTransactionName(name);\n\n if (activeRootSpan) {\n activeRootSpan.updateName(name);\n activeRootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, source);\n }\n }\n}\n\nfunction handleNavigation(\n location: Location,\n routes: RouteObject[],\n navigationType: Action,\n matches?: AgnosticDataRouteMatch,\n basename?: string,\n): void {\n const branches = Array.isArray(matches) ? matches : _matchRoutes(routes, location, basename);\n\n const client = getClient();\n if (!client || !CLIENTS_WITH_INSTRUMENT_NAVIGATION.includes(client)) {\n return;\n }\n\n if ((navigationType === 'PUSH' || navigationType === 'POP') && branches) {\n const [name, source] = getNormalizedName(routes, location, branches, basename);\n\n startBrowserTracingNavigationSpan(client, {\n name,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.react.reactrouter_v6',\n },\n });\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function withSentryReactRouterV6Routing<P extends Record<string, any>, R extends React.FC<P>>(Routes: R): R {\n if (!_useEffect || !_useLocation || !_useNavigationType || !_createRoutesFromChildren || !_matchRoutes) {\n DEBUG_BUILD &&\n logger.warn(`reactRouterV6Instrumentation was unable to wrap Routes because of one or more missing parameters.\n useEffect: ${_useEffect}. useLocation: ${_useLocation}. useNavigationType: ${_useNavigationType}.\n createRoutesFromChildren: ${_createRoutesFromChildren}. matchRoutes: ${_matchRoutes}.`);\n\n return Routes;\n }\n\n let isMountRenderPass: boolean = true;\n\n const SentryRoutes: React.FC<P> = (props: P) => {\n const location = _useLocation();\n const navigationType = _useNavigationType();\n\n _useEffect(\n () => {\n const routes = _createRoutesFromChildren(props.children) as RouteObject[];\n\n if (isMountRenderPass) {\n updatePageloadTransaction(getActiveRootSpan(), location, routes);\n isMountRenderPass = false;\n } else {\n handleNavigation(location, routes, navigationType);\n }\n },\n // `props.children` is purpusely not included in the dependency array, because we do not want to re-run this effect\n // when the children change. We only want to start transactions when the location or navigation type change.\n [location, navigationType],\n );\n\n // @ts-expect-error Setting more specific React Component typing for `R` generic above\n // will break advanced type inference done by react router params\n return <Routes {...props} />;\n };\n\n hoistNonReactStatics(SentryRoutes, Routes);\n\n // @ts-expect-error Setting more specific React Component typing for `R` generic above\n // will break advanced type inference done by react router params\n return SentryRoutes;\n}\n\nexport function wrapUseRoutes(origUseRoutes: UseRoutes): UseRoutes {\n if (!_useEffect || !_useLocation || !_useNavigationType || !_matchRoutes) {\n DEBUG_BUILD &&\n logger.warn(\n 'reactRouterV6Instrumentation was unable to wrap `useRoutes` because of one or more missing parameters.',\n );\n\n return origUseRoutes;\n }\n\n let isMountRenderPass: boolean = true;\n\n const SentryRoutes: React.FC<{\n children?: React.ReactNode;\n routes: RouteObject[];\n locationArg?: Partial<Location> | string;\n }> = (props: { children?: React.ReactNode; routes: RouteObject[]; locationArg?: Partial<Location> | string }) => {\n const { routes, locationArg } = props;\n\n const Routes = origUseRoutes(routes, locationArg);\n\n const location = _useLocation();\n const navigationType = _useNavigationType();\n\n // A value with stable identity to either pick `locationArg` if available or `location` if not\n const stableLocationParam =\n typeof locationArg === 'string' || (locationArg && locationArg.pathname)\n ? (locationArg as { pathname: string })\n : location;\n\n _useEffect(() => {\n const normalizedLocation =\n typeof stableLocationParam === 'string' ? { pathname: stableLocationParam } : stableLocationParam;\n\n if (isMountRenderPass) {\n updatePageloadTransaction(getActiveRootSpan(), normalizedLocation, routes);\n isMountRenderPass = false;\n } else {\n handleNavigation(normalizedLocation, routes, navigationType);\n }\n }, [navigationType, stableLocationParam]);\n\n return Routes;\n };\n\n // eslint-disable-next-line react/display-name\n return (routes: RouteObject[], locationArg?: Partial<Location> | string): React.ReactElement | null => {\n return <SentryRoutes routes={routes} locationArg={locationArg} />;\n };\n}\n\nexport function wrapCreateBrowserRouter<\n TState extends RouterState = RouterState,\n TRouter extends Router<TState> = Router<TState>,\n>(createRouterFunction: CreateRouterFunction<TState, TRouter>): CreateRouterFunction<TState, TRouter> {\n if (!_useEffect || !_useLocation || !_useNavigationType || !_matchRoutes) {\n DEBUG_BUILD &&\n logger.warn(\n 'reactRouterV6Instrumentation was unable to wrap the `createRouter` function because of one or more missing parameters.',\n );\n\n return createRouterFunction;\n }\n\n // `opts` for createBrowserHistory and createMemoryHistory are different, but also not relevant for us at the moment.\n // `basename` is the only option that is relevant for us, and it is the same for all.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return function (routes: RouteObject[], opts?: Record<string, any> & { basename?: string }): TRouter {\n const router = createRouterFunction(routes, opts);\n const basename = opts && opts.basename;\n\n const activeRootSpan = getActiveRootSpan();\n\n // The initial load ends when `createBrowserRouter` is called.\n // This is the earliest convenient time to update the transaction name.\n // Callbacks to `router.subscribe` are not called for the initial load.\n if (router.state.historyAction === 'POP' && activeRootSpan) {\n updatePageloadTransaction(activeRootSpan, router.state.location, routes, undefined, basename);\n }\n\n router.subscribe((state: RouterState) => {\n const location = state.location;\n if (state.historyAction === 'PUSH' || state.historyAction === 'POP') {\n handleNavigation(location, routes, state.historyAction, undefined, basename);\n }\n });\n\n return router;\n };\n}\n\nfunction getActiveRootSpan(): Span | undefined {\n const span = getActiveSpan();\n const rootSpan = span ? getRootSpan(span) : undefined;\n\n if (!rootSpan) {\n return undefined;\n }\n\n const op = spanToJSON(rootSpan).op;\n\n // Only use this root span if it is a pageload or navigation span\n return op === 'navigation' || op === 'pageload' ? rootSpan : undefined;\n}\n"],"names":["browserTracingIntegration","WINDOW","startBrowserTracingPageLoadSpan","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","SEMANTIC_ATTRIBUTE_SENTRY_OP","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","getNumberOfUrlSegments","getCurrentScope","getClient","startBrowserTracingNavigationSpan","DEBUG_BUILD","logger","_jsx","hoistNonReactStatics","getActiveSpan","getRootSpan","spanToJSON"],"mappings":";;;;;;;;;;;;;;AA0CA,IAAI,UAAU,CAAA;AACd,IAAI,YAAY,CAAA;AAChB,IAAI,kBAAkB,CAAA;AACtB,IAAI,yBAAyB,CAAA;AAC7B,IAAI,YAAY,CAAA;AAChB,IAAI,cAAc,GAAY,KAAK,CAAA;AACnC;AACA,MAAM,kCAAkC,GAAa,EAAE,CAAA;;AAWvD;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;AACR,IAAI,SAAS;AACb,IAAI,WAAW;AACf,IAAI,iBAAiB;AACrB,IAAI,wBAAwB;AAC5B,IAAI,WAAW;AACf,IAAI,aAAa;AACjB,IAAI,kBAAA,GAAqB,IA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,MAAA,EAAA,SAAA,EAAA,QAAA,CAAA,CAAA;AACA,KAAA;AACA;AACA,IAAA,MAAA,CAAA,SAAA,CAAA,CAAA,KAAA,KAAA;AACA,MAAA,MAAA,QAAA,GAAA,KAAA,CAAA,QAAA,CAAA;AACA,MAAA,IAAA,KAAA,CAAA,aAAA,KAAA,MAAA,IAAA,KAAA,CAAA,aAAA,KAAA,KAAA,EAAA;AACA,QAAA,gBAAA,CAAA,QAAA,EAAA,MAAA,EAAA,KAAA,CAAA,aAAA,EAAA,SAAA,EAAA,QAAA,CAAA,CAAA;AACA,OAAA;AACA,KAAA,CAAA,CAAA;AACA;AACA,IAAA,OAAA,MAAA,CAAA;AACA,GAAA,CAAA;AACA,CAAA;AACA;AACA,SAAA,iBAAA,GAAA;AACA,EAAA,MAAA,IAAA,GAAAG,kBAAA,EAAA,CAAA;AACA,EAAA,MAAA,QAAA,GAAA,IAAA,GAAAC,gBAAA,CAAA,IAAA,CAAA,GAAA,SAAA,CAAA;AACA;AACA,EAAA,IAAA,CAAA,QAAA,EAAA;AACA,IAAA,OAAA,SAAA,CAAA;AACA,GAAA;AACA;AACA,EAAA,MAAA,EAAA,GAAAC,eAAA,CAAA,QAAA,CAAA,CAAA,EAAA,CAAA;AACA;AACA;AACA,EAAA,OAAA,EAAA,KAAA,YAAA,IAAA,EAAA,KAAA,UAAA,GAAA,QAAA,GAAA,SAAA,CAAA;AACA;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"reactrouterv6.js","sources":["../../src/reactrouterv6.tsx"],"sourcesContent":["// Inspired from Donnie McNeal's solution:\n// https://gist.github.com/wontondon/e8c4bdf2888875e4c755712e99279536\n\nimport {\n WINDOW,\n browserTracingIntegration,\n startBrowserTracingNavigationSpan,\n startBrowserTracingPageLoadSpan,\n} from '@sentry/browser';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n getActiveSpan,\n getClient,\n getCurrentScope,\n getRootSpan,\n spanToJSON,\n} from '@sentry/core';\nimport type { Client, Integration, Span, TransactionSource } from '@sentry/types';\nimport { getNumberOfUrlSegments, logger } from '@sentry/utils';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\n\nimport { DEBUG_BUILD } from './debug-build';\nimport type {\n Action,\n AgnosticDataRouteMatch,\n CreateRouterFunction,\n CreateRoutesFromChildren,\n Location,\n MatchRoutes,\n RouteMatch,\n RouteObject,\n Router,\n RouterState,\n UseEffect,\n UseLocation,\n UseNavigationType,\n UseRoutes,\n} from './types';\n\nlet _useEffect: UseEffect;\nlet _useLocation: UseLocation;\nlet _useNavigationType: UseNavigationType;\nlet _createRoutesFromChildren: CreateRoutesFromChildren;\nlet _matchRoutes: MatchRoutes;\nlet _stripBasename: boolean = false;\n\nconst CLIENTS_WITH_INSTRUMENT_NAVIGATION = new WeakSet<Client>();\n\ninterface ReactRouterOptions {\n useEffect: UseEffect;\n useLocation: UseLocation;\n useNavigationType: UseNavigationType;\n createRoutesFromChildren: CreateRoutesFromChildren;\n matchRoutes: MatchRoutes;\n stripBasename?: boolean;\n}\n\n/**\n * A browser tracing integration that uses React Router v6 to instrument navigations.\n * Expects `useEffect`, `useLocation`, `useNavigationType`, `createRoutesFromChildren` and `matchRoutes` to be passed as options.\n */\nexport function reactRouterV6BrowserTracingIntegration(\n options: Parameters<typeof browserTracingIntegration>[0] & ReactRouterOptions,\n): Integration {\n const integration = browserTracingIntegration({\n ...options,\n instrumentPageLoad: false,\n instrumentNavigation: false,\n });\n\n const {\n useEffect,\n useLocation,\n useNavigationType,\n createRoutesFromChildren,\n matchRoutes,\n stripBasename,\n instrumentPageLoad = true,\n instrumentNavigation = true,\n } = options;\n\n return {\n ...integration,\n setup() {\n _useEffect = useEffect;\n _useLocation = useLocation;\n _useNavigationType = useNavigationType;\n _matchRoutes = matchRoutes;\n _createRoutesFromChildren = createRoutesFromChildren;\n _stripBasename = stripBasename || false;\n },\n afterAllSetup(client) {\n integration.afterAllSetup(client);\n\n const initPathName = WINDOW && WINDOW.location && WINDOW.location.pathname;\n if (instrumentPageLoad && initPathName) {\n startBrowserTracingPageLoadSpan(client, {\n name: initPathName,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'pageload',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.pageload.react.reactrouter_v6',\n },\n });\n }\n\n if (instrumentNavigation) {\n CLIENTS_WITH_INSTRUMENT_NAVIGATION.add(client);\n }\n },\n };\n}\n\n/**\n * Strip the basename from a pathname if exists.\n *\n * Vendored and modified from `react-router`\n * https://github.com/remix-run/react-router/blob/462bb712156a3f739d6139a0f14810b76b002df6/packages/router/utils.ts#L1038\n */\nfunction stripBasenameFromPathname(pathname: string, basename: string): string {\n if (!basename || basename === '/') {\n return pathname;\n }\n\n if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) {\n return pathname;\n }\n\n // We want to leave trailing slash behavior in the user's control, so if they\n // specify a basename with a trailing slash, we should support it\n const startIndex = basename.endsWith('/') ? basename.length - 1 : basename.length;\n const nextChar = pathname.charAt(startIndex);\n if (nextChar && nextChar !== '/') {\n // pathname does not start with basename/\n return pathname;\n }\n\n return pathname.slice(startIndex) || '/';\n}\n\nfunction getNormalizedName(\n routes: RouteObject[],\n location: Location,\n branches: RouteMatch[],\n basename: string = '',\n): [string, TransactionSource] {\n if (!routes || routes.length === 0) {\n return [_stripBasename ? stripBasenameFromPathname(location.pathname, basename) : location.pathname, 'url'];\n }\n\n let pathBuilder = '';\n if (branches) {\n // eslint-disable-next-line @typescript-eslint/prefer-for-of\n for (let x = 0; x < branches.length; x++) {\n const branch = branches[x];\n const route = branch.route;\n if (route) {\n // Early return if index route\n if (route.index) {\n return [_stripBasename ? stripBasenameFromPathname(branch.pathname, basename) : branch.pathname, 'route'];\n }\n\n const path = route.path;\n if (path) {\n const newPath = path[0] === '/' || pathBuilder[pathBuilder.length - 1] === '/' ? path : `/${path}`;\n pathBuilder += newPath;\n\n if (basename + branch.pathname === location.pathname) {\n if (\n // If the route defined on the element is something like\n // <Route path=\"/stores/:storeId/products/:productId\" element={<div>Product</div>} />\n // We should check against the branch.pathname for the number of / seperators\n getNumberOfUrlSegments(pathBuilder) !== getNumberOfUrlSegments(branch.pathname) &&\n // We should not count wildcard operators in the url segments calculation\n pathBuilder.slice(-2) !== '/*'\n ) {\n return [(_stripBasename ? '' : basename) + newPath, 'route'];\n }\n return [(_stripBasename ? '' : basename) + pathBuilder, 'route'];\n }\n }\n }\n }\n }\n\n return [_stripBasename ? stripBasenameFromPathname(location.pathname, basename) : location.pathname, 'url'];\n}\n\nfunction updatePageloadTransaction(\n activeRootSpan: Span | undefined,\n location: Location,\n routes: RouteObject[],\n matches?: AgnosticDataRouteMatch,\n basename?: string,\n): void {\n const branches = Array.isArray(matches)\n ? matches\n : (_matchRoutes(routes, location, basename) as unknown as RouteMatch[]);\n\n if (branches) {\n const [name, source] = getNormalizedName(routes, location, branches, basename);\n\n getCurrentScope().setTransactionName(name);\n\n if (activeRootSpan) {\n activeRootSpan.updateName(name);\n activeRootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, source);\n }\n }\n}\n\nfunction handleNavigation(\n location: Location,\n routes: RouteObject[],\n navigationType: Action,\n matches?: AgnosticDataRouteMatch,\n basename?: string,\n): void {\n const branches = Array.isArray(matches) ? matches : _matchRoutes(routes, location, basename);\n\n const client = getClient();\n if (!client || !CLIENTS_WITH_INSTRUMENT_NAVIGATION.has(client)) {\n return;\n }\n\n if ((navigationType === 'PUSH' || navigationType === 'POP') && branches) {\n const [name, source] = getNormalizedName(routes, location, branches, basename);\n\n startBrowserTracingNavigationSpan(client, {\n name,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.react.reactrouter_v6',\n },\n });\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function withSentryReactRouterV6Routing<P extends Record<string, any>, R extends React.FC<P>>(Routes: R): R {\n if (!_useEffect || !_useLocation || !_useNavigationType || !_createRoutesFromChildren || !_matchRoutes) {\n DEBUG_BUILD &&\n logger.warn(`reactRouterV6Instrumentation was unable to wrap Routes because of one or more missing parameters.\n useEffect: ${_useEffect}. useLocation: ${_useLocation}. useNavigationType: ${_useNavigationType}.\n createRoutesFromChildren: ${_createRoutesFromChildren}. matchRoutes: ${_matchRoutes}.`);\n\n return Routes;\n }\n\n let isMountRenderPass: boolean = true;\n\n const SentryRoutes: React.FC<P> = (props: P) => {\n const location = _useLocation();\n const navigationType = _useNavigationType();\n\n _useEffect(\n () => {\n const routes = _createRoutesFromChildren(props.children) as RouteObject[];\n\n if (isMountRenderPass) {\n updatePageloadTransaction(getActiveRootSpan(), location, routes);\n isMountRenderPass = false;\n } else {\n handleNavigation(location, routes, navigationType);\n }\n },\n // `props.children` is purpusely not included in the dependency array, because we do not want to re-run this effect\n // when the children change. We only want to start transactions when the location or navigation type change.\n [location, navigationType],\n );\n\n // @ts-expect-error Setting more specific React Component typing for `R` generic above\n // will break advanced type inference done by react router params\n return <Routes {...props} />;\n };\n\n hoistNonReactStatics(SentryRoutes, Routes);\n\n // @ts-expect-error Setting more specific React Component typing for `R` generic above\n // will break advanced type inference done by react router params\n return SentryRoutes;\n}\n\nexport function wrapUseRoutes(origUseRoutes: UseRoutes): UseRoutes {\n if (!_useEffect || !_useLocation || !_useNavigationType || !_matchRoutes) {\n DEBUG_BUILD &&\n logger.warn(\n 'reactRouterV6Instrumentation was unable to wrap `useRoutes` because of one or more missing parameters.',\n );\n\n return origUseRoutes;\n }\n\n let isMountRenderPass: boolean = true;\n\n const SentryRoutes: React.FC<{\n children?: React.ReactNode;\n routes: RouteObject[];\n locationArg?: Partial<Location> | string;\n }> = (props: { children?: React.ReactNode; routes: RouteObject[]; locationArg?: Partial<Location> | string }) => {\n const { routes, locationArg } = props;\n\n const Routes = origUseRoutes(routes, locationArg);\n\n const location = _useLocation();\n const navigationType = _useNavigationType();\n\n // A value with stable identity to either pick `locationArg` if available or `location` if not\n const stableLocationParam =\n typeof locationArg === 'string' || (locationArg && locationArg.pathname)\n ? (locationArg as { pathname: string })\n : location;\n\n _useEffect(() => {\n const normalizedLocation =\n typeof stableLocationParam === 'string' ? { pathname: stableLocationParam } : stableLocationParam;\n\n if (isMountRenderPass) {\n updatePageloadTransaction(getActiveRootSpan(), normalizedLocation, routes);\n isMountRenderPass = false;\n } else {\n handleNavigation(normalizedLocation, routes, navigationType);\n }\n }, [navigationType, stableLocationParam]);\n\n return Routes;\n };\n\n // eslint-disable-next-line react/display-name\n return (routes: RouteObject[], locationArg?: Partial<Location> | string): React.ReactElement | null => {\n return <SentryRoutes routes={routes} locationArg={locationArg} />;\n };\n}\n\nexport function wrapCreateBrowserRouter<\n TState extends RouterState = RouterState,\n TRouter extends Router<TState> = Router<TState>,\n>(createRouterFunction: CreateRouterFunction<TState, TRouter>): CreateRouterFunction<TState, TRouter> {\n if (!_useEffect || !_useLocation || !_useNavigationType || !_matchRoutes) {\n DEBUG_BUILD &&\n logger.warn(\n 'reactRouterV6Instrumentation was unable to wrap the `createRouter` function because of one or more missing parameters.',\n );\n\n return createRouterFunction;\n }\n\n // `opts` for createBrowserHistory and createMemoryHistory are different, but also not relevant for us at the moment.\n // `basename` is the only option that is relevant for us, and it is the same for all.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return function (routes: RouteObject[], opts?: Record<string, any> & { basename?: string }): TRouter {\n const router = createRouterFunction(routes, opts);\n const basename = opts && opts.basename;\n\n const activeRootSpan = getActiveRootSpan();\n\n // The initial load ends when `createBrowserRouter` is called.\n // This is the earliest convenient time to update the transaction name.\n // Callbacks to `router.subscribe` are not called for the initial load.\n if (router.state.historyAction === 'POP' && activeRootSpan) {\n updatePageloadTransaction(activeRootSpan, router.state.location, routes, undefined, basename);\n }\n\n router.subscribe((state: RouterState) => {\n const location = state.location;\n if (state.historyAction === 'PUSH' || state.historyAction === 'POP') {\n handleNavigation(location, routes, state.historyAction, undefined, basename);\n }\n });\n\n return router;\n };\n}\n\nfunction getActiveRootSpan(): Span | undefined {\n const span = getActiveSpan();\n const rootSpan = span ? getRootSpan(span) : undefined;\n\n if (!rootSpan) {\n return undefined;\n }\n\n const op = spanToJSON(rootSpan).op;\n\n // Only use this root span if it is a pageload or navigation span\n return op === 'navigation' || op === 'pageload' ? rootSpan : undefined;\n}\n"],"names":["browserTracingIntegration","WINDOW","startBrowserTracingPageLoadSpan","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","SEMANTIC_ATTRIBUTE_SENTRY_OP","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","getNumberOfUrlSegments","getCurrentScope","getClient","startBrowserTracingNavigationSpan","DEBUG_BUILD","logger","_jsx","hoistNonReactStatics","getActiveSpan","getRootSpan","spanToJSON"],"mappings":";;;;;;;;;;;;;;AA0CA,IAAI,UAAU,CAAA;AACd,IAAI,YAAY,CAAA;AAChB,IAAI,kBAAkB,CAAA;AACtB,IAAI,yBAAyB,CAAA;AAC7B,IAAI,YAAY,CAAA;AAChB,IAAI,cAAc,GAAY,KAAK,CAAA;AACnC;AACA,MAAM,kCAAmC,GAAE,IAAI,OAAO,EAAU,CAAA;;AAWhE;AACA;AACA;AACA;AACO,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;AACR,IAAI,SAAS;AACb,IAAI,WAAW;AACf,IAAI,iBAAiB;AACrB,IAAI,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