@sentry/react 7.93.0 → 7.94.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cjs/profiler.js CHANGED
@@ -1,6 +1,7 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
2
 
3
3
  const browser = require('@sentry/browser');
4
+ const core = require('@sentry/core');
4
5
  const utils = require('@sentry/utils');
5
6
  const hoistNonReactStatics = require('hoist-non-react-statics');
6
7
  const React = require('react');
@@ -24,7 +25,6 @@ const hoistNonReactStatics__default = /*#__PURE__*/_interopDefault(hoistNonReact
24
25
  const React__namespace = /*#__PURE__*/_interopNamespace(React);
25
26
 
26
27
  const _jsxFileName = "/home/runner/work/sentry-javascript/sentry-javascript/packages/react/src/profiler.tsx";
27
-
28
28
  const UNKNOWN_COMPONENT = 'unknown';
29
29
 
30
30
  /**
@@ -56,16 +56,12 @@ class Profiler extends React__namespace.Component {
56
56
  return;
57
57
  }
58
58
 
59
- const activeTransaction = getActiveTransaction();
60
- if (activeTransaction) {
61
- // eslint-disable-next-line deprecation/deprecation
62
- this._mountSpan = activeTransaction.startChild({
63
- description: `<${name}>`,
64
- op: constants.REACT_MOUNT_OP,
65
- origin: 'auto.ui.react.profiler',
66
- data: { 'ui.component_name': name },
67
- });
68
- }
59
+ this._mountSpan = browser.startInactiveSpan({
60
+ name: `<${name}>`,
61
+ op: constants.REACT_MOUNT_OP,
62
+ origin: 'auto.ui.react.profiler',
63
+ attributes: { 'ui.component_name': name },
64
+ });
69
65
  }
70
66
 
71
67
  // If a component mounted, we can finish the mount activity.
@@ -85,16 +81,17 @@ class Profiler extends React__namespace.Component {
85
81
  const changedProps = Object.keys(updateProps).filter(k => updateProps[k] !== this.props.updateProps[k]);
86
82
  if (changedProps.length > 0) {
87
83
  const now = utils.timestampInSeconds();
88
- // eslint-disable-next-line deprecation/deprecation
89
- this._updateSpan = this._mountSpan.startChild({
90
- data: {
91
- changedProps,
92
- 'ui.component_name': this.props.name,
93
- },
94
- description: `<${this.props.name}>`,
95
- op: constants.REACT_UPDATE_OP,
96
- origin: 'auto.ui.react.profiler',
97
- startTimestamp: now,
84
+ this._updateSpan = core.withActiveSpan(this._mountSpan, () => {
85
+ return browser.startInactiveSpan({
86
+ name: `<${this.props.name}>`,
87
+ op: constants.REACT_UPDATE_OP,
88
+ origin: 'auto.ui.react.profiler',
89
+ startTimestamp: now,
90
+ attributes: {
91
+ 'ui.component_name': this.props.name,
92
+ 'ui.react.changed_props': changedProps,
93
+ },
94
+ });
98
95
  });
99
96
  }
100
97
  }
@@ -112,19 +109,24 @@ class Profiler extends React__namespace.Component {
112
109
  // If a component is unmounted, we can say it is no longer on the screen.
113
110
  // This means we can finish the span representing the component render.
114
111
  componentWillUnmount() {
112
+ const endTimestamp = utils.timestampInSeconds();
115
113
  const { name, includeRender = true } = this.props;
116
114
 
117
115
  if (this._mountSpan && includeRender) {
118
- // If we were able to obtain the spanId of the mount activity, we should set the
119
- // next activity as a child to the component mount activity.
120
- // eslint-disable-next-line deprecation/deprecation
121
- this._mountSpan.startChild({
122
- description: `<${name}>`,
123
- endTimestamp: utils.timestampInSeconds(),
124
- op: constants.REACT_RENDER_OP,
125
- origin: 'auto.ui.react.profiler',
126
- startTimestamp: this._mountSpan.endTimestamp,
127
- data: { 'ui.component_name': name },
116
+ const startTimestamp = core.spanToJSON(this._mountSpan).timestamp;
117
+ core.withActiveSpan(this._mountSpan, () => {
118
+ const renderSpan = browser.startInactiveSpan({
119
+ name: `<${name}>`,
120
+ op: constants.REACT_RENDER_OP,
121
+ origin: 'auto.ui.react.profiler',
122
+ startTimestamp,
123
+ attributes: { 'ui.component_name': name },
124
+ });
125
+ if (renderSpan) {
126
+ // Have to cast to Span because the type of _mountSpan is Span | undefined
127
+ // and not getting narrowed properly
128
+ renderSpan.end(endTimestamp);
129
+ }
128
130
  });
129
131
  }
130
132
  }
@@ -142,6 +144,7 @@ class Profiler extends React__namespace.Component {
142
144
  * @param WrappedComponent component that is wrapped by Profiler
143
145
  * @param options the {@link ProfilerProps} you can pass into the Profiler
144
146
  */
147
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
145
148
  function withProfiler(
146
149
  WrappedComponent,
147
150
  // We do not want to have `updateProps` given in options, it is instead filled through the HOC.
@@ -151,8 +154,8 @@ function withProfiler(
151
154
  (options && options.name) || WrappedComponent.displayName || WrappedComponent.name || UNKNOWN_COMPONENT;
152
155
 
153
156
  const Wrapped = (props) => (
154
- React__namespace.createElement(Profiler, { ...options, name: componentDisplayName, updateProps: props, __self: this, __source: {fileName: _jsxFileName, lineNumber: 155}}
155
- , React__namespace.createElement(WrappedComponent, { ...props, __self: this, __source: {fileName: _jsxFileName, lineNumber: 156}} )
157
+ React__namespace.createElement(Profiler, { ...options, name: componentDisplayName, updateProps: props, __self: this, __source: {fileName: _jsxFileName, lineNumber: 156}}
158
+ , React__namespace.createElement(WrappedComponent, { ...props, __self: this, __source: {fileName: _jsxFileName, lineNumber: 157}} )
156
159
  )
157
160
  );
158
161
 
@@ -183,18 +186,12 @@ function useProfiler(
183
186
  return undefined;
184
187
  }
185
188
 
186
- const activeTransaction = getActiveTransaction();
187
- if (activeTransaction) {
188
- // eslint-disable-next-line deprecation/deprecation
189
- return activeTransaction.startChild({
190
- description: `<${name}>`,
191
- op: constants.REACT_MOUNT_OP,
192
- origin: 'auto.ui.react.profiler',
193
- data: { 'ui.component_name': name },
194
- });
195
- }
196
-
197
- return undefined;
189
+ return browser.startInactiveSpan({
190
+ name: `<${name}>`,
191
+ op: constants.REACT_MOUNT_OP,
192
+ origin: 'auto.ui.react.profiler',
193
+ attributes: { 'ui.component_name': name },
194
+ });
198
195
  });
199
196
 
200
197
  React__namespace.useEffect(() => {
@@ -204,15 +201,21 @@ function useProfiler(
204
201
 
205
202
  return () => {
206
203
  if (mountSpan && options.hasRenderSpan) {
207
- // eslint-disable-next-line deprecation/deprecation
208
- mountSpan.startChild({
209
- description: `<${name}>`,
210
- endTimestamp: utils.timestampInSeconds(),
204
+ const startTimestamp = core.spanToJSON(mountSpan).timestamp;
205
+ const endTimestamp = utils.timestampInSeconds();
206
+
207
+ const renderSpan = browser.startInactiveSpan({
208
+ name: `<${name}>`,
211
209
  op: constants.REACT_RENDER_OP,
212
210
  origin: 'auto.ui.react.profiler',
213
- startTimestamp: mountSpan.endTimestamp,
214
- data: { 'ui.component_name': name },
211
+ startTimestamp,
212
+ attributes: { 'ui.component_name': name },
215
213
  });
214
+ if (renderSpan) {
215
+ // Have to cast to Span because the type of _mountSpan is Span | undefined
216
+ // and not getting narrowed properly
217
+ renderSpan.end(endTimestamp);
218
+ }
216
219
  }
217
220
  };
218
221
  // We only want this to run once.
@@ -220,20 +223,8 @@ function useProfiler(
220
223
  }, []);
221
224
  }
222
225
 
223
- /** Grabs active transaction off scope */
224
- function getActiveTransaction(hub = browser.getCurrentHub()) {
225
- if (hub) {
226
- const scope = hub.getScope();
227
- // eslint-disable-next-line deprecation/deprecation
228
- return scope.getTransaction() ;
229
- }
230
-
231
- return undefined;
232
- }
233
-
234
226
  exports.Profiler = Profiler;
235
227
  exports.UNKNOWN_COMPONENT = UNKNOWN_COMPONENT;
236
- exports.getActiveTransaction = getActiveTransaction;
237
228
  exports.useProfiler = useProfiler;
238
229
  exports.withProfiler = withProfiler;
239
230
  //# sourceMappingURL=profiler.js.map
@@ -1 +1 @@
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 type { Hub } from '@sentry/browser';\nimport { getCurrentHub } from '@sentry/browser';\nimport type { Span, Transaction } from '@sentry/types';\nimport { timestampInSeconds } 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 // Component that is being profiled.\n children?: React.ReactNode;\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;\n /**\n * The span that represents the duration of time between shouldComponentUpdate and componentDidUpdate\n */\n protected _updateSpan: Span | 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 // eslint-disable-next-line deprecation/deprecation\n this._mountSpan = activeTransaction.startChild({\n description: `<${name}>`,\n op: REACT_MOUNT_OP,\n origin: 'auto.ui.react.profiler',\n data: { 'ui.component_name': name },\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.end();\n }\n }\n\n public shouldComponentUpdate({ updateProps, includeUpdates = true }: ProfilerProps): boolean {\n // Only generate an update span if includeUpdates 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 const now = timestampInSeconds();\n // eslint-disable-next-line deprecation/deprecation\n this._updateSpan = this._mountSpan.startChild({\n data: {\n changedProps,\n 'ui.component_name': this.props.name,\n },\n description: `<${this.props.name}>`,\n op: REACT_UPDATE_OP,\n origin: 'auto.ui.react.profiler',\n startTimestamp: now,\n });\n }\n }\n\n return true;\n }\n\n public componentDidUpdate(): void {\n if (this._updateSpan) {\n this._updateSpan.end();\n this._updateSpan = undefined;\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 // eslint-disable-next-line deprecation/deprecation\n this._mountSpan.startChild({\n description: `<${name}>`,\n endTimestamp: timestampInSeconds(),\n op: REACT_RENDER_OP,\n origin: 'auto.ui.react.profiler',\n startTimestamp: this._mountSpan.endTimestamp,\n data: { 'ui.component_name': name },\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' | 'children'>>,\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 // eslint-disable-next-line deprecation/deprecation\n return activeTransaction.startChild({\n description: `<${name}>`,\n op: REACT_MOUNT_OP,\n origin: 'auto.ui.react.profiler',\n data: { 'ui.component_name': name },\n });\n }\n\n return undefined;\n });\n\n React.useEffect(() => {\n if (mountSpan) {\n mountSpan.end();\n }\n\n return (): void => {\n if (mountSpan && options.hasRenderSpan) {\n // eslint-disable-next-line deprecation/deprecation\n mountSpan.startChild({\n description: `<${name}>`,\n endTimestamp: timestampInSeconds(),\n op: REACT_RENDER_OP,\n origin: 'auto.ui.react.profiler',\n startTimestamp: mountSpan.endTimestamp,\n data: { 'ui.component_name': name },\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 // eslint-disable-next-line deprecation/deprecation\n return scope.getTransaction() as T | undefined;\n }\n\n return undefined;\n}\n"],"names":["React","REACT_MOUNT_OP","timestampInSeconds","REACT_UPDATE_OP","REACT_RENDER_OP","hoistNonReactStatics","getCurrentHub"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAA,YAAA,GAAA,uFAAA,CAAA;AAUA;AACO,MAAM,iBAAkB,GAAE,UAAS;;AAkB1C;AACA;AACA;AACA;A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,YAAY,EAAEE,wBAAkB,EAAE;AAC5C,UAAU,EAAE,EAAEE,yBAAe;AAC7B,UAAU,MAAM,EAAE,wBAAwB;AAC1C,UAAU,cAAc,EAAE,SAAS,CAAC,YAAY;AAChD,UAAU,IAAI,EAAE,EAAE,mBAAmB,EAAE,MAAM;AAC7C,SAAS,CAAC,CAAA;AACV,OAAM;AACN,KAAK,CAAA;AACL;AACA;AACA,GAAG,EAAE,EAAE,CAAC,CAAA;AACR,CAAA;AAGA;AACA;AACO,SAAS,oBAAoB,CAAwB,GAAG,GAAQE,qBAAa,EAAE,EAAiB;AACvG,EAAE,IAAI,GAAG,EAAE;AACX,IAAI,MAAM,KAAM,GAAE,GAAG,CAAC,QAAQ,EAAE,CAAA;AAChC;AACA,IAAI,OAAO,KAAK,CAAC,cAAc,EAAG,EAAA;AAClC,GAAE;AACF;AACA,EAAE,OAAO,SAAS,CAAA;AAClB;;;;;;;;"}
1
+ {"version":3,"file":"profiler.js","sources":["../../src/profiler.tsx"],"sourcesContent":["import { startInactiveSpan } from '@sentry/browser';\nimport { spanToJSON, withActiveSpan } from '@sentry/core';\nimport type { Span } from '@sentry/types';\nimport { timestampInSeconds } 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 // Component that is being profiled.\n children?: React.ReactNode;\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;\n /**\n * The span that represents the duration of time between shouldComponentUpdate and componentDidUpdate\n */\n protected _updateSpan: Span | 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 this._mountSpan = startInactiveSpan({\n name: `<${name}>`,\n op: REACT_MOUNT_OP,\n origin: 'auto.ui.react.profiler',\n attributes: { 'ui.component_name': name },\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.end();\n }\n }\n\n public shouldComponentUpdate({ updateProps, includeUpdates = true }: ProfilerProps): boolean {\n // Only generate an update span if includeUpdates 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 const now = timestampInSeconds();\n this._updateSpan = withActiveSpan(this._mountSpan, () => {\n return startInactiveSpan({\n name: `<${this.props.name}>`,\n op: REACT_UPDATE_OP,\n origin: 'auto.ui.react.profiler',\n startTimestamp: now,\n attributes: {\n 'ui.component_name': this.props.name,\n 'ui.react.changed_props': changedProps,\n },\n });\n });\n }\n }\n\n return true;\n }\n\n public componentDidUpdate(): void {\n if (this._updateSpan) {\n this._updateSpan.end();\n this._updateSpan = undefined;\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 endTimestamp = timestampInSeconds();\n const { name, includeRender = true } = this.props;\n\n if (this._mountSpan && includeRender) {\n const startTimestamp = spanToJSON(this._mountSpan).timestamp;\n withActiveSpan(this._mountSpan, () => {\n const renderSpan = startInactiveSpan({\n name: `<${name}>`,\n op: REACT_RENDER_OP,\n origin: 'auto.ui.react.profiler',\n startTimestamp,\n attributes: { 'ui.component_name': name },\n });\n if (renderSpan) {\n // Have to cast to Span because the type of _mountSpan is Span | undefined\n // and not getting narrowed properly\n renderSpan.end(endTimestamp);\n }\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 */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\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' | 'children'>>,\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 return startInactiveSpan({\n name: `<${name}>`,\n op: REACT_MOUNT_OP,\n origin: 'auto.ui.react.profiler',\n attributes: { 'ui.component_name': name },\n });\n });\n\n React.useEffect(() => {\n if (mountSpan) {\n mountSpan.end();\n }\n\n return (): void => {\n if (mountSpan && options.hasRenderSpan) {\n const startTimestamp = spanToJSON(mountSpan).timestamp;\n const endTimestamp = timestampInSeconds();\n\n const renderSpan = startInactiveSpan({\n name: `<${name}>`,\n op: REACT_RENDER_OP,\n origin: 'auto.ui.react.profiler',\n startTimestamp,\n attributes: { 'ui.component_name': name },\n });\n if (renderSpan) {\n // Have to cast to Span because the type of _mountSpan is Span | undefined\n // and not getting narrowed properly\n renderSpan.end(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"],"names":["React","startInactiveSpan","REACT_MOUNT_OP","timestampInSeconds","withActiveSpan","REACT_UPDATE_OP","spanToJSON","REACT_RENDER_OP","hoistNonReactStatics"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAA,YAAA,GAAA,uFAAA,CAQA;AACO,MAAM,iBAAkB,GAAE,UAAS;;AAkB1C;AACA;AACA;AACA;AACA,MAAM,QAAS,SAAQA,gBAAK,CAAC,SAAS,CAAgB;AACtD;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAGA;AACA,GAAS,OAAA,YAAA,GAAA,CAAA,IAAA,CAAO,YAAY,GAA2B;AACvD,IAAI,QAAQ,EAAE,KAAK;AACnB,IAAI,aAAa,EAAE,IAAI;AACvB,IAAI,cAAc,EAAE,IAAI;AACxB,IAAG,CAAA;AACH;AACA,GAAS,WAAW,CAAC,KAAK,EAAiB;AAC3C,IAAI,KAAK,CAAC,KAAK,CAAC,CAAA;AAChB,IAAI,MAAM,EAAE,IAAI,EAAE,QAAA,GAAW,KAAA,EAAQ,GAAE,IAAI,CA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;AACR,OAAM;AACN,KAAK,CAAA;AACL;AACA;AACA,GAAG,EAAE,EAAE,CAAC,CAAA;AACR;;;;;;;"}
package/esm/profiler.js CHANGED
@@ -1,11 +1,11 @@
1
- import { getCurrentHub } from '@sentry/browser';
1
+ import { startInactiveSpan } from '@sentry/browser';
2
+ import { withActiveSpan, spanToJSON } from '@sentry/core';
2
3
  import { timestampInSeconds } from '@sentry/utils';
3
4
  import hoistNonReactStatics from 'hoist-non-react-statics';
4
5
  import * as React from 'react';
5
6
  import { REACT_MOUNT_OP, REACT_UPDATE_OP, REACT_RENDER_OP } from './constants.js';
6
7
 
7
8
  const _jsxFileName = "/home/runner/work/sentry-javascript/sentry-javascript/packages/react/src/profiler.tsx";
8
-
9
9
  const UNKNOWN_COMPONENT = 'unknown';
10
10
 
11
11
  /**
@@ -37,16 +37,12 @@ class Profiler extends React.Component {
37
37
  return;
38
38
  }
39
39
 
40
- const activeTransaction = getActiveTransaction();
41
- if (activeTransaction) {
42
- // eslint-disable-next-line deprecation/deprecation
43
- this._mountSpan = activeTransaction.startChild({
44
- description: `<${name}>`,
45
- op: REACT_MOUNT_OP,
46
- origin: 'auto.ui.react.profiler',
47
- data: { 'ui.component_name': name },
48
- });
49
- }
40
+ this._mountSpan = startInactiveSpan({
41
+ name: `<${name}>`,
42
+ op: REACT_MOUNT_OP,
43
+ origin: 'auto.ui.react.profiler',
44
+ attributes: { 'ui.component_name': name },
45
+ });
50
46
  }
51
47
 
52
48
  // If a component mounted, we can finish the mount activity.
@@ -66,16 +62,17 @@ class Profiler extends React.Component {
66
62
  const changedProps = Object.keys(updateProps).filter(k => updateProps[k] !== this.props.updateProps[k]);
67
63
  if (changedProps.length > 0) {
68
64
  const now = timestampInSeconds();
69
- // eslint-disable-next-line deprecation/deprecation
70
- this._updateSpan = this._mountSpan.startChild({
71
- data: {
72
- changedProps,
73
- 'ui.component_name': this.props.name,
74
- },
75
- description: `<${this.props.name}>`,
76
- op: REACT_UPDATE_OP,
77
- origin: 'auto.ui.react.profiler',
78
- startTimestamp: now,
65
+ this._updateSpan = withActiveSpan(this._mountSpan, () => {
66
+ return startInactiveSpan({
67
+ name: `<${this.props.name}>`,
68
+ op: REACT_UPDATE_OP,
69
+ origin: 'auto.ui.react.profiler',
70
+ startTimestamp: now,
71
+ attributes: {
72
+ 'ui.component_name': this.props.name,
73
+ 'ui.react.changed_props': changedProps,
74
+ },
75
+ });
79
76
  });
80
77
  }
81
78
  }
@@ -93,19 +90,24 @@ class Profiler extends React.Component {
93
90
  // If a component is unmounted, we can say it is no longer on the screen.
94
91
  // This means we can finish the span representing the component render.
95
92
  componentWillUnmount() {
93
+ const endTimestamp = timestampInSeconds();
96
94
  const { name, includeRender = true } = this.props;
97
95
 
98
96
  if (this._mountSpan && includeRender) {
99
- // If we were able to obtain the spanId of the mount activity, we should set the
100
- // next activity as a child to the component mount activity.
101
- // eslint-disable-next-line deprecation/deprecation
102
- this._mountSpan.startChild({
103
- description: `<${name}>`,
104
- endTimestamp: timestampInSeconds(),
105
- op: REACT_RENDER_OP,
106
- origin: 'auto.ui.react.profiler',
107
- startTimestamp: this._mountSpan.endTimestamp,
108
- data: { 'ui.component_name': name },
97
+ const startTimestamp = spanToJSON(this._mountSpan).timestamp;
98
+ withActiveSpan(this._mountSpan, () => {
99
+ const renderSpan = startInactiveSpan({
100
+ name: `<${name}>`,
101
+ op: REACT_RENDER_OP,
102
+ origin: 'auto.ui.react.profiler',
103
+ startTimestamp,
104
+ attributes: { 'ui.component_name': name },
105
+ });
106
+ if (renderSpan) {
107
+ // Have to cast to Span because the type of _mountSpan is Span | undefined
108
+ // and not getting narrowed properly
109
+ renderSpan.end(endTimestamp);
110
+ }
109
111
  });
110
112
  }
111
113
  }
@@ -123,6 +125,7 @@ class Profiler extends React.Component {
123
125
  * @param WrappedComponent component that is wrapped by Profiler
124
126
  * @param options the {@link ProfilerProps} you can pass into the Profiler
125
127
  */
128
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
126
129
  function withProfiler(
127
130
  WrappedComponent,
128
131
  // We do not want to have `updateProps` given in options, it is instead filled through the HOC.
@@ -132,8 +135,8 @@ function withProfiler(
132
135
  (options && options.name) || WrappedComponent.displayName || WrappedComponent.name || UNKNOWN_COMPONENT;
133
136
 
134
137
  const Wrapped = (props) => (
135
- React.createElement(Profiler, { ...options, name: componentDisplayName, updateProps: props, __self: this, __source: {fileName: _jsxFileName, lineNumber: 155}}
136
- , React.createElement(WrappedComponent, { ...props, __self: this, __source: {fileName: _jsxFileName, lineNumber: 156}} )
138
+ React.createElement(Profiler, { ...options, name: componentDisplayName, updateProps: props, __self: this, __source: {fileName: _jsxFileName, lineNumber: 156}}
139
+ , React.createElement(WrappedComponent, { ...props, __self: this, __source: {fileName: _jsxFileName, lineNumber: 157}} )
137
140
  )
138
141
  );
139
142
 
@@ -164,18 +167,12 @@ function useProfiler(
164
167
  return undefined;
165
168
  }
166
169
 
167
- const activeTransaction = getActiveTransaction();
168
- if (activeTransaction) {
169
- // eslint-disable-next-line deprecation/deprecation
170
- return activeTransaction.startChild({
171
- description: `<${name}>`,
172
- op: REACT_MOUNT_OP,
173
- origin: 'auto.ui.react.profiler',
174
- data: { 'ui.component_name': name },
175
- });
176
- }
177
-
178
- return undefined;
170
+ return startInactiveSpan({
171
+ name: `<${name}>`,
172
+ op: REACT_MOUNT_OP,
173
+ origin: 'auto.ui.react.profiler',
174
+ attributes: { 'ui.component_name': name },
175
+ });
179
176
  });
180
177
 
181
178
  React.useEffect(() => {
@@ -185,15 +182,21 @@ function useProfiler(
185
182
 
186
183
  return () => {
187
184
  if (mountSpan && options.hasRenderSpan) {
188
- // eslint-disable-next-line deprecation/deprecation
189
- mountSpan.startChild({
190
- description: `<${name}>`,
191
- endTimestamp: timestampInSeconds(),
185
+ const startTimestamp = spanToJSON(mountSpan).timestamp;
186
+ const endTimestamp = timestampInSeconds();
187
+
188
+ const renderSpan = startInactiveSpan({
189
+ name: `<${name}>`,
192
190
  op: REACT_RENDER_OP,
193
191
  origin: 'auto.ui.react.profiler',
194
- startTimestamp: mountSpan.endTimestamp,
195
- data: { 'ui.component_name': name },
192
+ startTimestamp,
193
+ attributes: { 'ui.component_name': name },
196
194
  });
195
+ if (renderSpan) {
196
+ // Have to cast to Span because the type of _mountSpan is Span | undefined
197
+ // and not getting narrowed properly
198
+ renderSpan.end(endTimestamp);
199
+ }
197
200
  }
198
201
  };
199
202
  // We only want this to run once.
@@ -201,16 +204,5 @@ function useProfiler(
201
204
  }, []);
202
205
  }
203
206
 
204
- /** Grabs active transaction off scope */
205
- function getActiveTransaction(hub = getCurrentHub()) {
206
- if (hub) {
207
- const scope = hub.getScope();
208
- // eslint-disable-next-line deprecation/deprecation
209
- return scope.getTransaction() ;
210
- }
211
-
212
- return undefined;
213
- }
214
-
215
- export { Profiler, UNKNOWN_COMPONENT, getActiveTransaction, useProfiler, withProfiler };
207
+ export { Profiler, UNKNOWN_COMPONENT, useProfiler, withProfiler };
216
208
  //# sourceMappingURL=profiler.js.map
@@ -1 +1 @@
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 type { Hub } from '@sentry/browser';\nimport { getCurrentHub } from '@sentry/browser';\nimport type { Span, Transaction } from '@sentry/types';\nimport { timestampInSeconds } 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 // Component that is being profiled.\n children?: React.ReactNode;\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;\n /**\n * The span that represents the duration of time between shouldComponentUpdate and componentDidUpdate\n */\n protected _updateSpan: Span | 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 // eslint-disable-next-line deprecation/deprecation\n this._mountSpan = activeTransaction.startChild({\n description: `<${name}>`,\n op: REACT_MOUNT_OP,\n origin: 'auto.ui.react.profiler',\n data: { 'ui.component_name': name },\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.end();\n }\n }\n\n public shouldComponentUpdate({ updateProps, includeUpdates = true }: ProfilerProps): boolean {\n // Only generate an update span if includeUpdates 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 const now = timestampInSeconds();\n // eslint-disable-next-line deprecation/deprecation\n this._updateSpan = this._mountSpan.startChild({\n data: {\n changedProps,\n 'ui.component_name': this.props.name,\n },\n description: `<${this.props.name}>`,\n op: REACT_UPDATE_OP,\n origin: 'auto.ui.react.profiler',\n startTimestamp: now,\n });\n }\n }\n\n return true;\n }\n\n public componentDidUpdate(): void {\n if (this._updateSpan) {\n this._updateSpan.end();\n this._updateSpan = undefined;\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 // eslint-disable-next-line deprecation/deprecation\n this._mountSpan.startChild({\n description: `<${name}>`,\n endTimestamp: timestampInSeconds(),\n op: REACT_RENDER_OP,\n origin: 'auto.ui.react.profiler',\n startTimestamp: this._mountSpan.endTimestamp,\n data: { 'ui.component_name': name },\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' | 'children'>>,\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 // eslint-disable-next-line deprecation/deprecation\n return activeTransaction.startChild({\n description: `<${name}>`,\n op: REACT_MOUNT_OP,\n origin: 'auto.ui.react.profiler',\n data: { 'ui.component_name': name },\n });\n }\n\n return undefined;\n });\n\n React.useEffect(() => {\n if (mountSpan) {\n mountSpan.end();\n }\n\n return (): void => {\n if (mountSpan && options.hasRenderSpan) {\n // eslint-disable-next-line deprecation/deprecation\n mountSpan.startChild({\n description: `<${name}>`,\n endTimestamp: timestampInSeconds(),\n op: REACT_RENDER_OP,\n origin: 'auto.ui.react.profiler',\n startTimestamp: mountSpan.endTimestamp,\n data: { 'ui.component_name': name },\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 // eslint-disable-next-line deprecation/deprecation\n return scope.getTransaction() as T | undefined;\n }\n\n return undefined;\n}\n"],"names":[],"mappings":";;;;;;AAAA,MAAA,YAAA,GAAA,uFAAA,CAAA;AAUA;AACO,MAAM,iBAAkB,GAAE,UAAS;;AAkB1C;AACA;AACA;AACA;AACA,MAAM,QAAS,SAAQ,KAAK,CAAC,SAAS,CAAgB;AACtD;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAGA;AACA,GAAS,OAAA,YAAA,GAAA,CAAA,IAAA,CAAO,YAAY,GAA2B;AACvD,IAAI,QAAQ,EAAE,KAAK;AACnB,IAAI,aAAa,EAAE,IAAI;AACvB,IAAI,cAAc,EAAE,IAAI;AACxB,IAAG,CAAA;AACH;AACA,GAAS,WAAW,CAAC,KAAK,EAAiB;AAC3C,IAAI,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AAQ,aAAa,EAAE,EAAiB;AACvG,EAAE,IAAI,GAAG,EAAE;AACX,IAAI,MAAM,KAAM,GAAE,GAAG,CAAC,QAAQ,EAAE,CAAA;AAChC;AACA,IAAI,OAAO,KAAK,CAAC,cAAc,EAAG,EAAA;AAClC,GAAE;AACF;AACA,EAAE,OAAO,SAAS,CAAA;AAClB;;;;"}
1
+ {"version":3,"file":"profiler.js","sources":["../../src/profiler.tsx"],"sourcesContent":["import { startInactiveSpan } from '@sentry/browser';\nimport { spanToJSON, withActiveSpan } from '@sentry/core';\nimport type { Span } from '@sentry/types';\nimport { timestampInSeconds } 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 // Component that is being profiled.\n children?: React.ReactNode;\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;\n /**\n * The span that represents the duration of time between shouldComponentUpdate and componentDidUpdate\n */\n protected _updateSpan: Span | 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 this._mountSpan = startInactiveSpan({\n name: `<${name}>`,\n op: REACT_MOUNT_OP,\n origin: 'auto.ui.react.profiler',\n attributes: { 'ui.component_name': name },\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.end();\n }\n }\n\n public shouldComponentUpdate({ updateProps, includeUpdates = true }: ProfilerProps): boolean {\n // Only generate an update span if includeUpdates 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 const now = timestampInSeconds();\n this._updateSpan = withActiveSpan(this._mountSpan, () => {\n return startInactiveSpan({\n name: `<${this.props.name}>`,\n op: REACT_UPDATE_OP,\n origin: 'auto.ui.react.profiler',\n startTimestamp: now,\n attributes: {\n 'ui.component_name': this.props.name,\n 'ui.react.changed_props': changedProps,\n },\n });\n });\n }\n }\n\n return true;\n }\n\n public componentDidUpdate(): void {\n if (this._updateSpan) {\n this._updateSpan.end();\n this._updateSpan = undefined;\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 endTimestamp = timestampInSeconds();\n const { name, includeRender = true } = this.props;\n\n if (this._mountSpan && includeRender) {\n const startTimestamp = spanToJSON(this._mountSpan).timestamp;\n withActiveSpan(this._mountSpan, () => {\n const renderSpan = startInactiveSpan({\n name: `<${name}>`,\n op: REACT_RENDER_OP,\n origin: 'auto.ui.react.profiler',\n startTimestamp,\n attributes: { 'ui.component_name': name },\n });\n if (renderSpan) {\n // Have to cast to Span because the type of _mountSpan is Span | undefined\n // and not getting narrowed properly\n renderSpan.end(endTimestamp);\n }\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 */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\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' | 'children'>>,\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 return startInactiveSpan({\n name: `<${name}>`,\n op: REACT_MOUNT_OP,\n origin: 'auto.ui.react.profiler',\n attributes: { 'ui.component_name': name },\n });\n });\n\n React.useEffect(() => {\n if (mountSpan) {\n mountSpan.end();\n }\n\n return (): void => {\n if (mountSpan && options.hasRenderSpan) {\n const startTimestamp = spanToJSON(mountSpan).timestamp;\n const endTimestamp = timestampInSeconds();\n\n const renderSpan = startInactiveSpan({\n name: `<${name}>`,\n op: REACT_RENDER_OP,\n origin: 'auto.ui.react.profiler',\n startTimestamp,\n attributes: { 'ui.component_name': name },\n });\n if (renderSpan) {\n // Have to cast to Span because the type of _mountSpan is Span | undefined\n // and not getting narrowed properly\n renderSpan.end(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"],"names":[],"mappings":";;;;;;;AAAA,MAAA,YAAA,GAAA,uFAAA,CAQA;AACO,MAAM,iBAAkB,GAAE,UAAS;;AAkB1C;AACA;AACA;AACA;AACA,MAAM,QAAS,SAAQ,KAAK,CAAC,SAAS,CAAgB;AACtD;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAGA;AACA,GAAS,OAAA,YAAA,GAAA,CAAA,IAAA,CAAO,YAAY,GAA2B;AACvD,IAAI,QAAQ,EAAE,KAAK;AACnB,IAAI,aAAa,EAAE,IAAI;AACvB,IAAI,cAAc,EAAE,IAAI;AACxB,IAAG,CAAA;AACH;AACA,GAAS,WAAW,CAAC,KAAK,EAAiB;AAC3C,IAAI,KAAK,CAAC,KAAK,CAAC,CAAA;AAChB,IAAI,MAAM,EAAE,IAAI,EAAE,QAAA,GAAW,KAAA,EAAQ,GAAE,IAAI,CAAC,KAAK,CAAA;AACjD;AACA,IAAI,IAAI,QAAQ,EAAE;AAClB,MAAM,OAAM;AACZ,KAAI;AACJ;AACA,IAAI,IAAI,CAAC,UAAW,GAAE,iBAAiB,CAAC;AACxC,MAAM,IAAI,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;AACvB,MAAM,EAAE,EAAE,cAAc;AACxB,MAAM,MAAM,EAAE,wBAAwB;AACtC,MAAM,UAAU,EAAE,EAAE,mBAAmB,EAAE,MAAM;AAC/C,KAAK,CAAC,CAAA;AACN,GAAE;AACF;AACA;AACA,GAAS,iBAAiB,GAAS;AACnC,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE;AACzB,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,EA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ACJ;AACA,EAAE,KAAK,CAAC,SAAS,CAAC,MAAM;AACxB,IAAI,IAAI,SAAS,EAAE;AACnB,MAAM,SAAS,CAAC,GAAG,EAAE,CAAA;AACrB,KAAI;AACJ;AACA,IAAI,OAAO,MAAY;AACvB,MAAM,IAAI,SAAA,IAAa,OAAO,CAAC,aAAa,EAAE;AAC9C,QAAQ,MAAM,iBAAiB,UAAU,CAAC,SAAS,CAAC,CAAC,SAAS,CAAA;AAC9D,QAAQ,MAAM,YAAA,GAAe,kBAAkB,EAAE,CAAA;AACjD;AACA,QAAQ,MAAM,UAAA,GAAa,iBAAiB,CAAC;AAC7C,UAAU,IAAI,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;AAC3B,UAAU,EAAE,EAAE,eAAe;AAC7B,UAAU,MAAM,EAAE,wBAAwB;AAC1C,UAAU,cAAc;AACxB,UAAU,UAAU,EAAE,EAAE,mBAAmB,EAAE,MAAM;AACnD,SAAS,CAAC,CAAA;AACV,QAAQ,IAAI,UAAU,EAAE;AACxB;AACA;AACA,UAAU,UAAU,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;AACtC,SAAQ;AACR,OAAM;AACN,KAAK,CAAA;AACL;AACA;AACA,GAAG,EAAE,EAAE,CAAC,CAAA;AACR;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/react",
3
- "version": "7.93.0",
3
+ "version": "7.94.1",
4
4
  "description": "Official Sentry SDK for React.js",
5
5
  "repository": "git://github.com/getsentry/sentry-javascript.git",
6
6
  "homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/react",
@@ -29,10 +29,10 @@
29
29
  "access": "public"
30
30
  },
31
31
  "dependencies": {
32
- "@sentry/browser": "7.93.0",
33
- "@sentry/core": "7.93.0",
34
- "@sentry/types": "7.93.0",
35
- "@sentry/utils": "7.93.0",
32
+ "@sentry/browser": "7.94.1",
33
+ "@sentry/core": "7.94.1",
34
+ "@sentry/types": "7.94.1",
35
+ "@sentry/utils": "7.94.1",
36
36
  "hoist-non-react-statics": "^3.3.2"
37
37
  },
38
38
  "peerDependencies": {
@@ -1,5 +1,4 @@
1
- import type { Hub } from '@sentry/browser';
2
- import type { Span, Transaction } from '@sentry/types';
1
+ import type { Span } from '@sentry/types';
3
2
  import * as React from 'react';
4
3
  export declare const UNKNOWN_COMPONENT = "unknown";
5
4
  export type ProfilerProps = {
@@ -55,6 +54,4 @@ declare function useProfiler(name: string, options?: {
55
54
  hasRenderSpan?: boolean;
56
55
  }): void;
57
56
  export { withProfiler, Profiler, useProfiler };
58
- /** Grabs active transaction off scope */
59
- export declare function getActiveTransaction<T extends Transaction>(hub?: Hub): T | undefined;
60
57
  //# sourceMappingURL=profiler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"profiler.d.ts","sourceRoot":"","sources":["../../src/profiler.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGvD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAE3C,MAAM,MAAM,aAAa,GAAG;IAE1B,IAAI,EAAE,MAAM,CAAC;IAGb,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAE3B,WAAW,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;CACzC,CAAC;AAEF;;;GAGG;AACH,cAAM,QAAS,SAAQ,KAAK,CAAC,SAAS,CAAC,aAAa,CAAC;IACnD;;;OAGG;IACH,SAAS,CAAC,UAAU,EAAE,IAAI,GAAG,SAAS,CAAC;IACvC;;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AAQ,CAAC,EAAE,OAAO,CAAC;IAAC,aAAa,CAAC,EAAE,OAAO,CAAA;CAGrD,GACA,IAAI,CAyCN;AAED,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC"}
@@ -1,5 +1,4 @@
1
- import { Hub } from '@sentry/browser';
2
- import { Span, Transaction } from '@sentry/types';
1
+ import { Span } from '@sentry/types';
3
2
  import * as React from 'react';
4
3
  export declare const UNKNOWN_COMPONENT = "unknown";
5
4
  export type ProfilerProps = {
@@ -55,6 +54,4 @@ declare function useProfiler(name: string, options?: {
55
54
  hasRenderSpan?: boolean;
56
55
  }): void;
57
56
  export { withProfiler, Profiler, useProfiler };
58
- /** Grabs active transaction off scope */
59
- export declare function getActiveTransaction<T extends Transaction>(hub?: Hub): T | undefined;
60
57
  //# sourceMappingURL=profiler.d.ts.map