11/* eslint-disable @typescript-eslint/no-unsafe-member-access */
22/* eslint-disable @typescript-eslint/no-explicit-any */
33import { getCurrentHub , Hub } from '@sentry/browser' ;
4- import { Integration , IntegrationClass , Span , Transaction } from '@sentry/types' ;
4+ import { Span , Transaction } from '@sentry/types' ;
55import { timestampWithMs } from '@sentry/utils' ;
66import hoistNonReactStatics from 'hoist-non-react-statics' ;
77import * as React from 'react' ;
@@ -10,66 +10,6 @@ import { REACT_MOUNT_OP, REACT_RENDER_OP, REACT_UPDATE_OP } from './constants';
1010
1111export const UNKNOWN_COMPONENT = 'unknown' ;
1212
13- const TRACING_GETTER = ( {
14- id : 'Tracing' ,
15- } as any ) as IntegrationClass < Integration > ;
16-
17- let globalTracingIntegration : Integration | null = null ;
18- /** @deprecated remove when @sentry/apm no longer used */
19- const getTracingIntegration = ( ) : Integration | null => {
20- if ( globalTracingIntegration ) {
21- return globalTracingIntegration ;
22- }
23-
24- globalTracingIntegration = getCurrentHub ( ) . getIntegration ( TRACING_GETTER ) ;
25- return globalTracingIntegration ;
26- } ;
27-
28- /**
29- * pushActivity creates an new react activity.
30- * Is a no-op if Tracing integration is not valid
31- * @param name displayName of component that started activity
32- * @deprecated remove when @sentry/apm no longer used
33- */
34- function pushActivity ( name : string , op : string ) : number | null {
35- if ( globalTracingIntegration === null ) {
36- return null ;
37- }
38-
39- return ( globalTracingIntegration as any ) . constructor . pushActivity ( name , {
40- description : `<${ name } >` ,
41- op,
42- } ) ;
43- }
44-
45- /**
46- * popActivity removes a React activity.
47- * Is a no-op if Tracing integration is not valid.
48- * @param activity id of activity that is being popped
49- * @deprecated remove when @sentry/apm no longer used
50- */
51- function popActivity ( activity : number | null ) : void {
52- if ( activity === null || globalTracingIntegration === null ) {
53- return ;
54- }
55-
56- ( globalTracingIntegration as any ) . constructor . popActivity ( activity ) ;
57- }
58-
59- /**
60- * Obtain a span given an activity id.
61- * Is a no-op if Tracing integration is not valid.
62- * @param activity activity id associated with obtained span
63- * @deprecated remove when @sentry/apm no longer used
64- */
65- function getActivitySpan ( activity : number | null ) : Span | undefined {
66- if ( activity === null || globalTracingIntegration === null ) {
67- return undefined ;
68- }
69-
70- return ( globalTracingIntegration as any ) . constructor . getActivitySpan ( activity ) as Span | undefined ;
71- }
72-
7313export type ProfilerProps = {
7414 // The name of the component being profiled.
7515 name : string ;
@@ -95,9 +35,6 @@ class Profiler extends React.Component<ProfilerProps> {
9535 */
9636 protected _mountSpan : Span | undefined = undefined ;
9737
98- // The activity representing how long it takes to mount a component.
99- private _mountActivity : number | null = null ;
100-
10138 // eslint-disable-next-line @typescript-eslint/member-ordering
10239 public static defaultProps : Partial < ProfilerProps > = {
10340 disabled : false ,
@@ -113,32 +50,19 @@ class Profiler extends React.Component<ProfilerProps> {
11350 return ;
11451 }
11552
116- // If they are using @sentry /apm, we need to push/pop activities
117- // eslint-disable-next-line deprecation/deprecation
118- if ( getTracingIntegration ( ) ) {
119- // eslint-disable-next-line deprecation/deprecation
120- this . _mountActivity = pushActivity ( name , REACT_MOUNT_OP ) ;
121- } else {
122- const activeTransaction = getActiveTransaction ( ) ;
123- if ( activeTransaction ) {
124- this . _mountSpan = activeTransaction . startChild ( {
125- description : `<${ name } >` ,
126- op : REACT_MOUNT_OP ,
127- } ) ;
128- }
53+ const activeTransaction = getActiveTransaction ( ) ;
54+ if ( activeTransaction ) {
55+ this . _mountSpan = activeTransaction . startChild ( {
56+ description : `<${ name } >` ,
57+ op : REACT_MOUNT_OP ,
58+ } ) ;
12959 }
13060 }
13161
13262 // If a component mounted, we can finish the mount activity.
13363 public componentDidMount ( ) : void {
13464 if ( this . _mountSpan ) {
13565 this . _mountSpan . finish ( ) ;
136- } else {
137- // eslint-disable-next-line deprecation/deprecation
138- this . _mountSpan = getActivitySpan ( this . _mountActivity ) ;
139- // eslint-disable-next-line deprecation/deprecation
140- popActivity ( this . _mountActivity ) ;
141- this . _mountActivity = null ;
14266 }
14367 }
14468
0 commit comments