1
1
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
2
2
/* eslint-disable @typescript-eslint/no-explicit-any */
3
3
import { getCurrentHub , Hub } from '@sentry/browser' ;
4
- import { Integration , IntegrationClass , Span , Transaction } from '@sentry/types' ;
4
+ import { Span , Transaction } from '@sentry/types' ;
5
5
import { timestampWithMs } from '@sentry/utils' ;
6
6
import hoistNonReactStatics from 'hoist-non-react-statics' ;
7
7
import * as React from 'react' ;
@@ -10,66 +10,6 @@ import { REACT_MOUNT_OP, REACT_RENDER_OP, REACT_UPDATE_OP } from './constants';
10
10
11
11
export const UNKNOWN_COMPONENT = 'unknown' ;
12
12
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
-
73
13
export type ProfilerProps = {
74
14
// The name of the component being profiled.
75
15
name : string ;
@@ -95,9 +35,6 @@ class Profiler extends React.Component<ProfilerProps> {
95
35
*/
96
36
protected _mountSpan : Span | undefined = undefined ;
97
37
98
- // The activity representing how long it takes to mount a component.
99
- private _mountActivity : number | null = null ;
100
-
101
38
// eslint-disable-next-line @typescript-eslint/member-ordering
102
39
public static defaultProps : Partial < ProfilerProps > = {
103
40
disabled : false ,
@@ -113,32 +50,19 @@ class Profiler extends React.Component<ProfilerProps> {
113
50
return ;
114
51
}
115
52
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
+ } ) ;
129
59
}
130
60
}
131
61
132
62
// If a component mounted, we can finish the mount activity.
133
63
public componentDidMount ( ) : void {
134
64
if ( this . _mountSpan ) {
135
65
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 ;
142
66
}
143
67
}
144
68
0 commit comments