@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
package/cjs/profiler.js CHANGED
@@ -1,93 +1,110 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- const tslib_1 = require("tslib");
3
- /* eslint-disable @typescript-eslint/no-unsafe-member-access */
4
- /* eslint-disable @typescript-eslint/no-explicit-any */
5
- const browser_1 = require("@sentry/browser");
6
- const utils_1 = require("@sentry/utils");
7
- const hoist_non_react_statics_1 = tslib_1.__importDefault(require("hoist-non-react-statics"));
8
- const React = tslib_1.__importStar(require("react"));
9
- const constants_1 = require("./constants");
10
- exports.UNKNOWN_COMPONENT = 'unknown';
1
+ var {
2
+ _interopDefault,
3
+ _interopNamespace
4
+ } = require('@sentry/utils/cjs/buildPolyfills');
5
+
6
+ Object.defineProperty(exports, '__esModule', { value: true });
7
+
8
+ var browser = require('@sentry/browser');
9
+ var utils = require('@sentry/utils');
10
+ var hoistNonReactStatics = require('hoist-non-react-statics');
11
+ var React = require('react');
12
+ var constants = require('./constants.js');
13
+
14
+ var hoistNonReactStatics__default = /*#__PURE__*/_interopDefault(hoistNonReactStatics);
15
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
16
+
17
+ var _jsxFileName = "/home/runner/work/sentry-javascript/sentry-javascript/packages/react/src/profiler.tsx";
18
+ var UNKNOWN_COMPONENT = 'unknown';
19
+
11
20
  /**
12
21
  * The Profiler component leverages Sentry's Tracing integration to generate
13
22
  * spans based on component lifecycles.
14
23
  */
15
- class Profiler extends React.Component {
16
- constructor(props) {
17
- super(props);
18
- /**
19
- * The span of the mount activity
20
- * Made protected for the React Native SDK to access
21
- */
22
- this._mountSpan = undefined;
23
- const { name, disabled = false } = this.props;
24
- if (disabled) {
25
- return;
26
- }
27
- const activeTransaction = getActiveTransaction();
28
- if (activeTransaction) {
29
- this._mountSpan = activeTransaction.startChild({
30
- description: `<${name}>`,
31
- op: constants_1.REACT_MOUNT_OP,
32
- });
33
- }
24
+ class Profiler extends React__namespace.Component {
25
+ /**
26
+ * The span of the mount activity
27
+ * Made protected for the React Native SDK to access
28
+ */
29
+ __init() {this._mountSpan = undefined;}
30
+
31
+ static __initStatic() {this.defaultProps = {
32
+ disabled: false,
33
+ includeRender: true,
34
+ includeUpdates: true,
35
+ };}
36
+
37
+ constructor(props) {
38
+ super(props);Profiler.prototype.__init.call(this);;
39
+ const { name, disabled = false } = this.props;
40
+
41
+ if (disabled) {
42
+ return;
34
43
  }
35
- // If a component mounted, we can finish the mount activity.
36
- componentDidMount() {
37
- if (this._mountSpan) {
38
- this._mountSpan.finish();
39
- }
44
+
45
+ var activeTransaction = getActiveTransaction();
46
+ if (activeTransaction) {
47
+ this._mountSpan = activeTransaction.startChild({
48
+ description: `<${name}>`,
49
+ op: constants.REACT_MOUNT_OP,
50
+ });
40
51
  }
41
- componentDidUpdate({ updateProps, includeUpdates = true }) {
42
- // Only generate an update span if hasUpdateSpan is true, if there is a valid mountSpan,
43
- // and if the updateProps have changed. It is ok to not do a deep equality check here as it is expensive.
44
- // We are just trying to give baseline clues for further investigation.
45
- if (includeUpdates && this._mountSpan && updateProps !== this.props.updateProps) {
46
- // See what props haved changed between the previous props, and the current props. This is
47
- // set as data on the span. We just store the prop keys as the values could be potenially very large.
48
- const changedProps = Object.keys(updateProps).filter(k => updateProps[k] !== this.props.updateProps[k]);
49
- if (changedProps.length > 0) {
50
- // The update span is a point in time span with 0 duration, just signifying that the component
51
- // has been updated.
52
- const now = utils_1.timestampWithMs();
53
- this._mountSpan.startChild({
54
- data: {
55
- changedProps,
56
- },
57
- description: `<${this.props.name}>`,
58
- endTimestamp: now,
59
- op: constants_1.REACT_UPDATE_OP,
60
- startTimestamp: now,
61
- });
62
- }
63
- }
52
+ }
53
+
54
+ // If a component mounted, we can finish the mount activity.
55
+ componentDidMount() {
56
+ if (this._mountSpan) {
57
+ this._mountSpan.finish();
64
58
  }
65
- // If a component is unmounted, we can say it is no longer on the screen.
66
- // This means we can finish the span representing the component render.
67
- componentWillUnmount() {
68
- const { name, includeRender = true } = this.props;
69
- if (this._mountSpan && includeRender) {
70
- // If we were able to obtain the spanId of the mount activity, we should set the
71
- // next activity as a child to the component mount activity.
72
- this._mountSpan.startChild({
73
- description: `<${name}>`,
74
- endTimestamp: utils_1.timestampWithMs(),
75
- op: constants_1.REACT_RENDER_OP,
76
- startTimestamp: this._mountSpan.endTimestamp,
77
- });
78
- }
59
+ }
60
+
61
+ componentDidUpdate({ updateProps, includeUpdates = true }) {
62
+ // Only generate an update span if hasUpdateSpan is true, if there is a valid mountSpan,
63
+ // and if the updateProps have changed. It is ok to not do a deep equality check here as it is expensive.
64
+ // We are just trying to give baseline clues for further investigation.
65
+ if (includeUpdates && this._mountSpan && updateProps !== this.props.updateProps) {
66
+ // See what props haved changed between the previous props, and the current props. This is
67
+ // set as data on the span. We just store the prop keys as the values could be potenially very large.
68
+ var changedProps = Object.keys(updateProps).filter(k => updateProps[k] !== this.props.updateProps[k]);
69
+ if (changedProps.length > 0) {
70
+ // The update span is a point in time span with 0 duration, just signifying that the component
71
+ // has been updated.
72
+ var now = utils.timestampWithMs();
73
+ this._mountSpan.startChild({
74
+ data: {
75
+ changedProps,
76
+ },
77
+ description: `<${this.props.name}>`,
78
+ endTimestamp: now,
79
+ op: constants.REACT_UPDATE_OP,
80
+ startTimestamp: now,
81
+ });
82
+ }
79
83
  }
80
- render() {
81
- return this.props.children;
84
+ }
85
+
86
+ // If a component is unmounted, we can say it is no longer on the screen.
87
+ // This means we can finish the span representing the component render.
88
+ componentWillUnmount() {
89
+ const { name, includeRender = true } = this.props;
90
+
91
+ if (this._mountSpan && includeRender) {
92
+ // If we were able to obtain the spanId of the mount activity, we should set the
93
+ // next activity as a child to the component mount activity.
94
+ this._mountSpan.startChild({
95
+ description: `<${name}>`,
96
+ endTimestamp: utils.timestampWithMs(),
97
+ op: constants.REACT_RENDER_OP,
98
+ startTimestamp: this._mountSpan.endTimestamp,
99
+ });
82
100
  }
83
- }
84
- exports.Profiler = Profiler;
85
- // eslint-disable-next-line @typescript-eslint/member-ordering
86
- Profiler.defaultProps = {
87
- disabled: false,
88
- includeRender: true,
89
- includeUpdates: true,
90
- };
101
+ }
102
+
103
+ render() {
104
+ return this.props.children;
105
+ }
106
+ }Profiler.__initStatic();
107
+
91
108
  /**
92
109
  * withProfiler is a higher order component that wraps a
93
110
  * component in a {@link Profiler} component. It is recommended that
@@ -96,19 +113,28 @@ Profiler.defaultProps = {
96
113
  * @param WrappedComponent component that is wrapped by Profiler
97
114
  * @param options the {@link ProfilerProps} you can pass into the Profiler
98
115
  */
99
- function withProfiler(WrappedComponent,
100
- // We do not want to have `updateProps` given in options, it is instead filled through the HOC.
101
- options) {
102
- const componentDisplayName = (options && options.name) || WrappedComponent.displayName || WrappedComponent.name || exports.UNKNOWN_COMPONENT;
103
- const Wrapped = (props) => (React.createElement(Profiler, Object.assign({}, options, { name: componentDisplayName, updateProps: props }),
104
- React.createElement(WrappedComponent, Object.assign({}, props))));
105
- Wrapped.displayName = `profiler(${componentDisplayName})`;
106
- // Copy over static methods from Wrapped component to Profiler HOC
107
- // See: https://reactjs.org/docs/higher-order-components.html#static-methods-must-be-copied-over
108
- hoist_non_react_statics_1.default(Wrapped, WrappedComponent);
109
- return Wrapped;
116
+ function withProfiler(
117
+ WrappedComponent,
118
+ // We do not want to have `updateProps` given in options, it is instead filled through the HOC.
119
+ options,
120
+ ) {
121
+ var componentDisplayName =
122
+ (options && options.name) || WrappedComponent.displayName || WrappedComponent.name || UNKNOWN_COMPONENT;
123
+
124
+ var Wrapped = (props) => (
125
+ React__namespace.createElement(Profiler, { ...options, name: componentDisplayName, updateProps: props, __self: this, __source: {fileName: _jsxFileName, lineNumber: 133}}
126
+ , React__namespace.createElement(WrappedComponent, { ...props, __self: this, __source: {fileName: _jsxFileName, lineNumber: 134}} )
127
+ )
128
+ );
129
+
130
+ Wrapped.displayName = `profiler(${componentDisplayName})`;
131
+
132
+ // Copy over static methods from Wrapped component to Profiler HOC
133
+ // See: https://reactjs.org/docs/higher-order-components.html#static-methods-must-be-copied-over
134
+ hoistNonReactStatics__default(Wrapped, WrappedComponent);
135
+ return Wrapped;
110
136
  }
111
- exports.withProfiler = withProfiler;
137
+
112
138
  /**
113
139
  *
114
140
  * `useProfiler` is a React hook that profiles a React component.
@@ -116,51 +142,63 @@ exports.withProfiler = withProfiler;
116
142
  * Requires React 16.8 or above.
117
143
  * @param name displayName of component being profiled
118
144
  */
119
- function useProfiler(name, options = {
145
+ function useProfiler(
146
+ name,
147
+ options = {
120
148
  disabled: false,
121
149
  hasRenderSpan: true,
122
- }) {
123
- const [mountSpan] = React.useState(() => {
124
- if (options && options.disabled) {
125
- return undefined;
126
- }
127
- const activeTransaction = getActiveTransaction();
128
- if (activeTransaction) {
129
- return activeTransaction.startChild({
130
- description: `<${name}>`,
131
- op: constants_1.REACT_MOUNT_OP,
132
- });
133
- }
134
- return undefined;
135
- });
136
- React.useEffect(() => {
137
- if (mountSpan) {
138
- mountSpan.finish();
139
- }
140
- return () => {
141
- if (mountSpan && options.hasRenderSpan) {
142
- mountSpan.startChild({
143
- description: `<${name}>`,
144
- endTimestamp: utils_1.timestampWithMs(),
145
- op: constants_1.REACT_RENDER_OP,
146
- startTimestamp: mountSpan.endTimestamp,
147
- });
148
- }
149
- };
150
- // We only want this to run once.
151
- // eslint-disable-next-line react-hooks/exhaustive-deps
152
- }, []);
150
+ },
151
+ ) {
152
+ const [mountSpan] = React__namespace.useState(() => {
153
+ if (options && options.disabled) {
154
+ return undefined;
155
+ }
156
+
157
+ var activeTransaction = getActiveTransaction();
158
+ if (activeTransaction) {
159
+ return activeTransaction.startChild({
160
+ description: `<${name}>`,
161
+ op: constants.REACT_MOUNT_OP,
162
+ });
163
+ }
164
+
165
+ return undefined;
166
+ });
167
+
168
+ React__namespace.useEffect(() => {
169
+ if (mountSpan) {
170
+ mountSpan.finish();
171
+ }
172
+
173
+ return () => {
174
+ if (mountSpan && options.hasRenderSpan) {
175
+ mountSpan.startChild({
176
+ description: `<${name}>`,
177
+ endTimestamp: utils.timestampWithMs(),
178
+ op: constants.REACT_RENDER_OP,
179
+ startTimestamp: mountSpan.endTimestamp,
180
+ });
181
+ }
182
+ };
183
+ // We only want this to run once.
184
+ }, []);
153
185
  }
154
- exports.useProfiler = useProfiler;
186
+
155
187
  /** Grabs active transaction off scope */
156
- function getActiveTransaction(hub = browser_1.getCurrentHub()) {
157
- if (hub) {
158
- const scope = hub.getScope();
159
- if (scope) {
160
- return scope.getTransaction();
161
- }
188
+ function getActiveTransaction(hub = browser.getCurrentHub()) {
189
+ if (hub) {
190
+ var scope = hub.getScope();
191
+ if (scope) {
192
+ return scope.getTransaction() ;
162
193
  }
163
- return undefined;
194
+ }
195
+
196
+ return undefined;
164
197
  }
198
+
199
+ exports.Profiler = Profiler;
200
+ exports.UNKNOWN_COMPONENT = UNKNOWN_COMPONENT;
165
201
  exports.getActiveTransaction = getActiveTransaction;
166
- //# sourceMappingURL=profiler.js.map
202
+ exports.useProfiler = useProfiler;
203
+ exports.withProfiler = withProfiler;
204
+ //# sourceMappingURL=profiler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"profiler.js","sourceRoot":"","sources":["../../src/profiler.tsx"],"names":[],"mappings":";;AAAA,+DAA+D;AAC/D,uDAAuD;AACvD,6CAAqD;AAErD,yCAAgD;AAChD,8FAA2D;AAC3D,qDAA+B;AAE/B,2CAA+E;AAElE,QAAA,iBAAiB,GAAG,SAAS,CAAC;AAgB3C;;;GAGG;AACH,MAAM,QAAS,SAAQ,KAAK,CAAC,SAAwB;IAcnD,YAAmB,KAAoB;QACrC,KAAK,CAAC,KAAK,CAAC,CAAC;QAdf;;;WAGG;QACO,eAAU,GAAqB,SAAS,CAAC;QAWjD,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAE9C,IAAI,QAAQ,EAAE;YACZ,OAAO;SACR;QAED,MAAM,iBAAiB,GAAG,oBAAoB,EAAE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n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { getCurrentHub, Hub } from '@sentry/browser';\nimport { Span, Transaction } from '@sentry/types';\nimport { timestampWithMs } from '@sentry/utils';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\n\nimport { REACT_MOUNT_OP, REACT_RENDER_OP, REACT_UPDATE_OP } from './constants';\n\nexport const UNKNOWN_COMPONENT = 'unknown';\n\nexport type ProfilerProps = {\n // The name of the component being profiled.\n name: string;\n // If the Profiler is disabled. False by default. This is useful if you want to disable profilers\n // in certain environments.\n disabled?: boolean;\n // If time component is on page should be displayed as spans. True by default.\n includeRender?: boolean;\n // If component updates should be displayed as spans. True by default.\n includeUpdates?: boolean;\n // props given to component being profiled.\n updateProps: { [key: string]: unknown };\n};\n\n/**\n * The Profiler component leverages Sentry's Tracing integration to generate\n * spans based on component lifecycles.\n */\nclass Profiler extends React.Component<ProfilerProps> {\n /**\n * The span of the mount activity\n * Made protected for the React Native SDK to access\n */\n protected _mountSpan: Span | undefined = undefined;\n\n // eslint-disable-next-line @typescript-eslint/member-ordering\n public static defaultProps: Partial<ProfilerProps> = {\n disabled: false,\n includeRender: true,\n includeUpdates: true,\n };\n\n public constructor(props: ProfilerProps) {\n super(props);\n const { name, disabled = false } = this.props;\n\n if (disabled) {\n return;\n }\n\n const activeTransaction = getActiveTransaction();\n if (activeTransaction) {\n this._mountSpan = activeTransaction.startChild({\n description: `<${name}>`,\n op: REACT_MOUNT_OP,\n });\n }\n }\n\n // If a component mounted, we can finish the mount activity.\n public componentDidMount(): void {\n if (this._mountSpan) {\n this._mountSpan.finish();\n }\n }\n\n public componentDidUpdate({ updateProps, includeUpdates = true }: ProfilerProps): void {\n // Only generate an update span if hasUpdateSpan is true, if there is a valid mountSpan,\n // and if the updateProps have changed. It is ok to not do a deep equality check here as it is expensive.\n // We are just trying to give baseline clues for further investigation.\n if (includeUpdates && this._mountSpan && updateProps !== this.props.updateProps) {\n // See what props haved changed between the previous props, and the current props. This is\n // set as data on the span. We just store the prop keys as the values could be potenially very large.\n const changedProps = Object.keys(updateProps).filter(k => updateProps[k] !== this.props.updateProps[k]);\n if (changedProps.length > 0) {\n // The update span is a point in time span with 0 duration, just signifying that the component\n // has been updated.\n const now = timestampWithMs();\n this._mountSpan.startChild({\n data: {\n changedProps,\n },\n description: `<${this.props.name}>`,\n endTimestamp: now,\n op: REACT_UPDATE_OP,\n startTimestamp: now,\n });\n }\n }\n }\n\n // If a component is unmounted, we can say it is no longer on the screen.\n // This means we can finish the span representing the component render.\n public componentWillUnmount(): void {\n const { name, includeRender = true } = this.props;\n\n if (this._mountSpan && includeRender) {\n // If we were able to obtain the spanId of the mount activity, we should set the\n // next activity as a child to the component mount activity.\n this._mountSpan.startChild({\n description: `<${name}>`,\n endTimestamp: timestampWithMs(),\n op: REACT_RENDER_OP,\n startTimestamp: this._mountSpan.endTimestamp,\n });\n }\n }\n\n public render(): React.ReactNode {\n return this.props.children;\n }\n}\n\n/**\n * withProfiler is a higher order component that wraps a\n * component in a {@link Profiler} component. It is recommended that\n * the higher order component be used over the regular {@link Profiler} component.\n *\n * @param WrappedComponent component that is wrapped by Profiler\n * @param options the {@link ProfilerProps} you can pass into the Profiler\n */\nfunction withProfiler<P extends Record<string, any>>(\n WrappedComponent: React.ComponentType<P>,\n // We do not want to have `updateProps` given in options, it is instead filled through the HOC.\n options?: Pick<Partial<ProfilerProps>, Exclude<keyof ProfilerProps, 'updateProps'>>,\n): React.FC<P> {\n const componentDisplayName =\n (options && options.name) || WrappedComponent.displayName || WrappedComponent.name || UNKNOWN_COMPONENT;\n\n const Wrapped: React.FC<P> = (props: P) => (\n <Profiler {...options} name={componentDisplayName} updateProps={props}>\n <WrappedComponent {...props} />\n </Profiler>\n );\n\n Wrapped.displayName = `profiler(${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\n/**\n *\n * `useProfiler` is a React hook that profiles a React component.\n *\n * Requires React 16.8 or above.\n * @param name displayName of component being profiled\n */\nfunction useProfiler(\n name: string,\n options: { disabled?: boolean; hasRenderSpan?: boolean } = {\n disabled: false,\n hasRenderSpan: true,\n },\n): void {\n const [mountSpan] = React.useState(() => {\n if (options && options.disabled) {\n return undefined;\n }\n\n const activeTransaction = getActiveTransaction();\n if (activeTransaction) {\n return activeTransaction.startChild({\n description: `<${name}>`,\n op: REACT_MOUNT_OP,\n });\n }\n\n return undefined;\n });\n\n React.useEffect(() => {\n if (mountSpan) {\n mountSpan.finish();\n }\n\n return (): void => {\n if (mountSpan && options.hasRenderSpan) {\n mountSpan.startChild({\n description: `<${name}>`,\n endTimestamp: timestampWithMs(),\n op: REACT_RENDER_OP,\n startTimestamp: mountSpan.endTimestamp,\n });\n }\n };\n // We only want this to run once.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n}\n\nexport { withProfiler, Profiler, useProfiler };\n\n/** Grabs active transaction off scope */\nexport function getActiveTransaction<T extends Transaction>(hub: Hub = getCurrentHub()): T | undefined {\n if (hub) {\n const scope = hub.getScope();\n if (scope) {\n return scope.getTransaction() as T | undefined;\n }\n }\n\n return undefined;\n}\n"]}
1
+ {"version":3,"file":"profiler.js","sources":["../../src/profiler.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { getCurrentHub, Hub } from '@sentry/browser';\nimport { Span, Transaction } from '@sentry/types';\nimport { timestampWithMs } from '@sentry/utils';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\n\nimport { REACT_MOUNT_OP, REACT_RENDER_OP, REACT_UPDATE_OP } from './constants';\n\nexport const UNKNOWN_COMPONENT = 'unknown';\n\nexport type ProfilerProps = {\n // The name of the component being profiled.\n name: string;\n // If the Profiler is disabled. False by default. This is useful if you want to disable profilers\n // in certain environments.\n disabled?: boolean;\n // If time component is on page should be displayed as spans. True by default.\n includeRender?: boolean;\n // If component updates should be displayed as spans. True by default.\n includeUpdates?: boolean;\n // props given to component being profiled.\n updateProps: { [key: string]: unknown };\n};\n\n/**\n * The Profiler component leverages Sentry's Tracing integration to generate\n * spans based on component lifecycles.\n */\nclass Profiler extends React.Component<ProfilerProps> {\n /**\n * The span of the mount activity\n * Made protected for the React Native SDK to access\n */\n protected _mountSpan: Span | undefined = undefined;\n\n // eslint-disable-next-line @typescript-eslint/member-ordering\n public static defaultProps: Partial<ProfilerProps> = {\n disabled: false,\n includeRender: true,\n includeUpdates: true,\n };\n\n public constructor(props: ProfilerProps) {\n super(props);\n const { name, disabled = false } = this.props;\n\n if (disabled) {\n return;\n }\n\n const activeTransaction = getActiveTransaction();\n if (activeTransaction) {\n this._mountSpan = activeTransaction.startChild({\n description: `<${name}>`,\n op: REACT_MOUNT_OP,\n });\n }\n }\n\n // If a component mounted, we can finish the mount activity.\n public componentDidMount(): void {\n if (this._mountSpan) {\n this._mountSpan.finish();\n }\n }\n\n public componentDidUpdate({ updateProps, includeUpdates = true }: ProfilerProps): void {\n // Only generate an update span if hasUpdateSpan is true, if there is a valid mountSpan,\n // and if the updateProps have changed. It is ok to not do a deep equality check here as it is expensive.\n // We are just trying to give baseline clues for further investigation.\n if (includeUpdates && this._mountSpan && updateProps !== this.props.updateProps) {\n // See what props haved changed between the previous props, and the current props. This is\n // set as data on the span. We just store the prop keys as the values could be potenially very large.\n const changedProps = Object.keys(updateProps).filter(k => updateProps[k] !== this.props.updateProps[k]);\n if (changedProps.length > 0) {\n // The update span is a point in time span with 0 duration, just signifying that the component\n // has been updated.\n const now = timestampWithMs();\n this._mountSpan.startChild({\n data: {\n changedProps,\n },\n description: `<${this.props.name}>`,\n endTimestamp: now,\n op: REACT_UPDATE_OP,\n startTimestamp: now,\n });\n }\n }\n }\n\n // If a component is unmounted, we can say it is no longer on the screen.\n // This means we can finish the span representing the component render.\n public componentWillUnmount(): void {\n const { name, includeRender = true } = this.props;\n\n if (this._mountSpan && includeRender) {\n // If we were able to obtain the spanId of the mount activity, we should set the\n // next activity as a child to the component mount activity.\n this._mountSpan.startChild({\n description: `<${name}>`,\n endTimestamp: timestampWithMs(),\n op: REACT_RENDER_OP,\n startTimestamp: this._mountSpan.endTimestamp,\n });\n }\n }\n\n public render(): React.ReactNode {\n return this.props.children;\n }\n}\n\n/**\n * withProfiler is a higher order component that wraps a\n * component in a {@link Profiler} component. It is recommended that\n * the higher order component be used over the regular {@link Profiler} component.\n *\n * @param WrappedComponent component that is wrapped by Profiler\n * @param options the {@link ProfilerProps} you can pass into the Profiler\n */\nfunction withProfiler<P extends Record<string, any>>(\n WrappedComponent: React.ComponentType<P>,\n // We do not want to have `updateProps` given in options, it is instead filled through the HOC.\n options?: Pick<Partial<ProfilerProps>, Exclude<keyof ProfilerProps, 'updateProps'>>,\n): React.FC<P> {\n const componentDisplayName =\n (options && options.name) || WrappedComponent.displayName || WrappedComponent.name || UNKNOWN_COMPONENT;\n\n const Wrapped: React.FC<P> = (props: P) => (\n <Profiler {...options} name={componentDisplayName} updateProps={props}>\n <WrappedComponent {...props} />\n </Profiler>\n );\n\n Wrapped.displayName = `profiler(${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\n/**\n *\n * `useProfiler` is a React hook that profiles a React component.\n *\n * Requires React 16.8 or above.\n * @param name displayName of component being profiled\n */\nfunction useProfiler(\n name: string,\n options: { disabled?: boolean; hasRenderSpan?: boolean } = {\n disabled: false,\n hasRenderSpan: true,\n },\n): void {\n const [mountSpan] = React.useState(() => {\n if (options && options.disabled) {\n return undefined;\n }\n\n const activeTransaction = getActiveTransaction();\n if (activeTransaction) {\n return activeTransaction.startChild({\n description: `<${name}>`,\n op: REACT_MOUNT_OP,\n });\n }\n\n return undefined;\n });\n\n React.useEffect(() => {\n if (mountSpan) {\n mountSpan.finish();\n }\n\n return (): void => {\n if (mountSpan && options.hasRenderSpan) {\n mountSpan.startChild({\n description: `<${name}>`,\n endTimestamp: timestampWithMs(),\n op: REACT_RENDER_OP,\n startTimestamp: mountSpan.endTimestamp,\n });\n }\n };\n // We only want this to run once.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n}\n\nexport { withProfiler, Profiler, useProfiler };\n\n/** Grabs active transaction off scope */\nexport function getActiveTransaction<T extends Transaction>(hub: Hub = getCurrentHub()): T | undefined {\n if (hub) {\n const scope = hub.getScope();\n if (scope) {\n return scope.getTransaction() as T | undefined;\n }\n }\n\n return undefined;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;AA0BA;;;;AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmFA;;AAEA;;;;;;;;AAQA;;;;AAIA;;;;;;;;;;;;;;;;AAgBA;;AAEA;;;;;;;AAOA;;;;;;AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA;;AAIA;;;;;;;;;;AAUA;;;;;;"}
@@ -1,115 +1,169 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- const tslib_1 = require("tslib");
3
- const utils_1 = require("@sentry/utils");
4
- const hoist_non_react_statics_1 = tslib_1.__importDefault(require("hoist-non-react-statics"));
5
- const React = tslib_1.__importStar(require("react"));
1
+ var {
2
+ _interopDefault,
3
+ _interopNamespace
4
+ } = require('@sentry/utils/cjs/buildPolyfills');
5
+
6
+ Object.defineProperty(exports, '__esModule', { value: true });
7
+
8
+ var utils = require('@sentry/utils');
9
+ var hoistNonReactStatics = require('hoist-non-react-statics');
10
+ var React = require('react');
11
+
12
+ var hoistNonReactStatics__default = /*#__PURE__*/_interopDefault(hoistNonReactStatics);
13
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
14
+
15
+ var _jsxFileName = "/home/runner/work/sentry-javascript/sentry-javascript/packages/react/src/reactrouter.tsx";
16
+
17
+ // We need to disable eslint no-explict-any because any is required for the
18
+ // react-router typings.
19
+
6
20
  /* eslint-enable @typescript-eslint/no-explicit-any */
7
- const global = utils_1.getGlobalObject();
21
+
22
+ var global = utils.getGlobalObject();
23
+
8
24
  let activeTransaction;
9
- function reactRouterV4Instrumentation(history, routes, matchPath) {
10
- return createReactRouterInstrumentation(history, 'react-router-v4', routes, matchPath);
25
+
26
+ function reactRouterV4Instrumentation(
27
+ history,
28
+ routes,
29
+ matchPath,
30
+ ) {
31
+ return createReactRouterInstrumentation(history, 'react-router-v4', routes, matchPath);
11
32
  }
12
- exports.reactRouterV4Instrumentation = reactRouterV4Instrumentation;
13
- function reactRouterV5Instrumentation(history, routes, matchPath) {
14
- return createReactRouterInstrumentation(history, 'react-router-v5', routes, matchPath);
33
+
34
+ function reactRouterV5Instrumentation(
35
+ history,
36
+ routes,
37
+ matchPath,
38
+ ) {
39
+ return createReactRouterInstrumentation(history, 'react-router-v5', routes, matchPath);
15
40
  }
16
- exports.reactRouterV5Instrumentation = reactRouterV5Instrumentation;
17
- function createReactRouterInstrumentation(history, name, allRoutes = [], matchPath) {
18
- function getInitPathName() {
19
- if (history && history.location) {
20
- return history.location.pathname;
21
- }
22
- if (global && global.location) {
23
- return global.location.pathname;
24
- }
25
- return undefined;
41
+
42
+ function createReactRouterInstrumentation(
43
+ history,
44
+ name,
45
+ allRoutes = [],
46
+ matchPath,
47
+ ) {
48
+ function getInitPathName() {
49
+ if (history && history.location) {
50
+ return history.location.pathname;
26
51
  }
27
- function getTransactionName(pathname) {
28
- if (allRoutes.length === 0 || !matchPath) {
29
- return pathname;
30
- }
31
- const branches = matchRoutes(allRoutes, pathname, matchPath);
32
- // eslint-disable-next-line @typescript-eslint/prefer-for-of
52
+
53
+ if (global && global.location) {
54
+ return global.location.pathname;
55
+ }
56
+
57
+ return undefined;
58
+ }
59
+
60
+ function getTransactionName(pathname) {
61
+ if (allRoutes.length === 0 || !matchPath) {
62
+ return pathname;
63
+ }
64
+
65
+ var branches = matchRoutes(allRoutes, pathname, matchPath);
33
66
  for (let x = 0; x < branches.length; x++) {
34
- if (branches[x].match.isExact) {
35
- return branches[x].match.path;
36
- }
37
- }
38
- return pathname;
67
+ if (branches[x].match.isExact) {
68
+ return branches[x].match.path;
69
+ }
39
70
  }
40
- return (customStartTransaction, startTransactionOnPageLoad = true, startTransactionOnLocationChange = true) => {
41
- const initPathName = getInitPathName();
42
- if (startTransactionOnPageLoad && initPathName) {
43
- activeTransaction = customStartTransaction({
44
- name: getTransactionName(initPathName),
45
- op: 'pageload',
46
- tags: {
47
- 'routing.instrumentation': name,
48
- },
49
- });
50
- }
51
- if (startTransactionOnLocationChange && history.listen) {
52
- history.listen((location, action) => {
53
- if (action && (action === 'PUSH' || action === 'POP')) {
54
- if (activeTransaction) {
55
- activeTransaction.finish();
56
- }
57
- const tags = {
58
- 'routing.instrumentation': name,
59
- };
60
- activeTransaction = customStartTransaction({
61
- name: getTransactionName(location.pathname),
62
- op: 'navigation',
63
- tags,
64
- });
65
- }
66
- });
71
+
72
+ return pathname;
73
+ }
74
+
75
+ return (customStartTransaction, startTransactionOnPageLoad = true, startTransactionOnLocationChange = true) => {
76
+ var initPathName = getInitPathName();
77
+ if (startTransactionOnPageLoad && initPathName) {
78
+ activeTransaction = customStartTransaction({
79
+ name: getTransactionName(initPathName),
80
+ op: 'pageload',
81
+ tags: {
82
+ 'routing.instrumentation': name,
83
+ },
84
+ });
85
+ }
86
+
87
+ if (startTransactionOnLocationChange && history.listen) {
88
+ history.listen((location, action) => {
89
+ if (action && (action === 'PUSH' || action === 'POP')) {
90
+ if (activeTransaction) {
91
+ activeTransaction.finish();
92
+ }
93
+ var tags = {
94
+ 'routing.instrumentation': name,
95
+ };
96
+
97
+ activeTransaction = customStartTransaction({
98
+ name: getTransactionName(location.pathname),
99
+ op: 'navigation',
100
+ tags,
101
+ });
67
102
  }
68
- };
103
+ });
104
+ }
105
+ };
69
106
  }
107
+
70
108
  /**
71
109
  * Matches a set of routes to a pathname
72
110
  * Based on implementation from
73
111
  */
74
- function matchRoutes(routes, pathname, matchPath, branch = []) {
75
- routes.some(route => {
76
- const match = route.path
77
- ? matchPath(pathname, route)
78
- : branch.length
79
- ? branch[branch.length - 1].match // use parent match
80
- : computeRootMatch(pathname); // use default "root" match
81
- if (match) {
82
- branch.push({ route, match });
83
- if (route.routes) {
84
- matchRoutes(route.routes, pathname, matchPath, branch);
85
- }
86
- }
87
- return !!match;
88
- });
89
- return branch;
112
+ function matchRoutes(
113
+ routes,
114
+ pathname,
115
+ matchPath,
116
+ branch = [],
117
+ ) {
118
+ routes.some(route => {
119
+ var match = route.path
120
+ ? matchPath(pathname, route)
121
+ : branch.length
122
+ ? branch[branch.length - 1].match // use parent match
123
+ : computeRootMatch(pathname); // use default "root" match
124
+
125
+ if (match) {
126
+ branch.push({ route, match });
127
+
128
+ if (route.routes) {
129
+ matchRoutes(route.routes, pathname, matchPath, branch);
130
+ }
131
+ }
132
+
133
+ return !!match;
134
+ });
135
+
136
+ return branch;
90
137
  }
138
+
91
139
  function computeRootMatch(pathname) {
92
- return { path: '/', url: '/', params: {}, isExact: pathname === '/' };
140
+ return { path: '/', url: '/', params: {}, isExact: pathname === '/' };
93
141
  }
94
- /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */
142
+
95
143
  function withSentryRouting(Route) {
96
- const componentDisplayName = Route.displayName || Route.name;
97
- const WrappedRoute = (props) => {
98
- if (activeTransaction && props && props.computedMatch && props.computedMatch.isExact) {
99
- activeTransaction.setName(props.computedMatch.path);
100
- }
101
- // @ts-ignore Setting more specific React Component typing for `R` generic above
102
- // will break advanced type inference done by react router params:
103
- // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/13dc4235c069e25fe7ee16e11f529d909f9f3ff8/types/react-router/index.d.ts#L154-L164
104
- return React.createElement(Route, Object.assign({}, props));
105
- };
106
- WrappedRoute.displayName = `sentryRoute(${componentDisplayName})`;
107
- hoist_non_react_statics_1.default(WrappedRoute, Route);
144
+ var componentDisplayName = (Route ).displayName || (Route ).name;
145
+
146
+ var WrappedRoute = (props) => {
147
+ if (activeTransaction && props && props.computedMatch && props.computedMatch.isExact) {
148
+ activeTransaction.setName(props.computedMatch.path);
149
+ }
150
+
108
151
  // @ts-ignore Setting more specific React Component typing for `R` generic above
109
152
  // will break advanced type inference done by react router params:
110
153
  // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/13dc4235c069e25fe7ee16e11f529d909f9f3ff8/types/react-router/index.d.ts#L154-L164
111
- return WrappedRoute;
154
+ return React__namespace.createElement(Route, { ...props, __self: this, __source: {fileName: _jsxFileName, lineNumber: 163}} );
155
+ };
156
+
157
+ WrappedRoute.displayName = `sentryRoute(${componentDisplayName})`;
158
+ hoistNonReactStatics__default(WrappedRoute, Route);
159
+ // @ts-ignore Setting more specific React Component typing for `R` generic above
160
+ // will break advanced type inference done by react router params:
161
+ // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/13dc4235c069e25fe7ee16e11f529d909f9f3ff8/types/react-router/index.d.ts#L154-L164
162
+ return WrappedRoute;
112
163
  }
113
- exports.withSentryRouting = withSentryRouting;
114
164
  /* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */
115
- //# sourceMappingURL=reactrouter.js.map
165
+
166
+ exports.reactRouterV4Instrumentation = reactRouterV4Instrumentation;
167
+ exports.reactRouterV5Instrumentation = reactRouterV5Instrumentation;
168
+ exports.withSentryRouting = withSentryRouting;
169
+ //# sourceMappingURL=reactrouter.js.map