Skip to content

Commit 1789080

Browse files
committed
ref(tracing): Remove references to @sentry/apm (#4845)
Removes all references to `@sentry/apm`, a deprecated package we do not use anymore.
1 parent c518955 commit 1789080

File tree

2 files changed

+16
-132
lines changed

2 files changed

+16
-132
lines changed

packages/integrations/src/vue.ts

+9-49
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,6 @@ import { basename, getGlobalObject, logger, timestampWithMs } from '@sentry/util
55

66
import { IS_DEBUG_BUILD } from './flags';
77

8-
/**
9-
* Used to extract Tracing integration from the current client,
10-
* without the need to import `Tracing` itself from the @sentry/apm package.
11-
* @deprecated as @sentry/tracing should be used over @sentry/apm.
12-
*/
13-
const TRACING_GETTER = {
14-
id: 'Tracing',
15-
} as any as IntegrationClass<Integration>;
16-
178
/**
189
* Used to extract BrowserTracing integration from @sentry/tracing
1910
*/
@@ -150,7 +141,6 @@ export class Vue implements Integration {
150141
private readonly _componentsCache: { [key: string]: string } = {};
151142
private _rootSpan?: Span;
152143
private _rootSpanTimer?: ReturnType<typeof setTimeout>;
153-
private _tracingActivity?: number;
154144

155145
/**
156146
* @inheritDoc
@@ -260,30 +250,12 @@ export class Vue implements Integration {
260250
vm.$once(`hook:${hook}`, () => {
261251
// Create an activity on the first event call. There'll be no second call, as rootSpan will be in place,
262252
// thus new event handler won't be attached.
263-
264-
// We do this whole dance with `TRACING_GETTER` to prevent `@sentry/apm` from becoming a peerDependency.
265-
// We also need to ask for the `.constructor`, as `pushActivity` and `popActivity` are static, not instance methods.
266-
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
267-
// eslint-disable-next-line deprecation/deprecation
268-
const tracingIntegration = getCurrentHub().getIntegration(TRACING_GETTER);
269-
if (tracingIntegration) {
270-
this._tracingActivity = (tracingIntegration as any).constructor.pushActivity('Vue Application Render');
271-
const transaction = (tracingIntegration as any).constructor.getTransaction();
272-
if (transaction) {
273-
this._rootSpan = transaction.startChild({
274-
description: 'Application Render',
275-
op: VUE_OP,
276-
});
277-
}
278-
// Use functionality from @sentry/tracing
279-
} else {
280-
const activeTransaction = getActiveTransaction(getCurrentHub());
281-
if (activeTransaction) {
282-
this._rootSpan = activeTransaction.startChild({
283-
description: 'Application Render',
284-
op: VUE_OP,
285-
});
286-
}
253+
const activeTransaction = getActiveTransaction(getCurrentHub());
254+
if (activeTransaction) {
255+
this._rootSpan = activeTransaction.startChild({
256+
description: 'Application Render',
257+
op: VUE_OP,
258+
});
287259
}
288260
/* eslint-enable @typescript-eslint/no-unsafe-member-access */
289261
});
@@ -349,24 +321,13 @@ export class Vue implements Integration {
349321
};
350322

351323
/** Finish top-level span and activity with a debounce configured using `timeout` option */
352-
private _finishRootSpan(timestamp: number, getCurrentHub: () => Hub): void {
324+
private _finishRootSpan(timestamp: number, _getCurrentHub: () => Hub): void {
353325
if (this._rootSpanTimer) {
354326
clearTimeout(this._rootSpanTimer);
355327
}
356328

357329
this._rootSpanTimer = setTimeout(() => {
358-
if (this._tracingActivity) {
359-
// We do this whole dance with `TRACING_GETTER` to prevent `@sentry/apm` from becoming a peerDependency.
360-
// We also need to ask for the `.constructor`, as `pushActivity` and `popActivity` are static, not instance methods.
361-
// eslint-disable-next-line deprecation/deprecation
362-
const tracingIntegration = getCurrentHub().getIntegration(TRACING_GETTER);
363-
if (tracingIntegration) {
364-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
365-
(tracingIntegration as any).constructor.popActivity(this._tracingActivity);
366-
}
367-
}
368-
369-
// We should always finish the span, only should pop activity if using @sentry/apm
330+
// We should always finish the span
370331
if (this._rootSpan) {
371332
this._rootSpan.finish(timestamp);
372333
}
@@ -379,8 +340,7 @@ export class Vue implements Integration {
379340

380341
this._options.Vue.mixin({
381342
beforeCreate(this: ViewModel): void {
382-
// eslint-disable-next-line deprecation/deprecation
383-
if (getCurrentHub().getIntegration(TRACING_GETTER) || getCurrentHub().getIntegration(BROWSER_TRACING_GETTER)) {
343+
if (getCurrentHub().getIntegration(BROWSER_TRACING_GETTER)) {
384344
// `this` points to currently rendered component
385345
applyTracingHooks(this, getCurrentHub);
386346
} else {

packages/react/src/profiler.tsx

+7-83
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
22
/* eslint-disable @typescript-eslint/no-explicit-any */
33
import { getCurrentHub, Hub } from '@sentry/browser';
4-
import { Integration, IntegrationClass, Span, Transaction } from '@sentry/types';
4+
import { Span, Transaction } from '@sentry/types';
55
import { timestampWithMs } from '@sentry/utils';
66
import hoistNonReactStatics from 'hoist-non-react-statics';
77
import * as React from 'react';
@@ -10,66 +10,6 @@ import { REACT_MOUNT_OP, REACT_RENDER_OP, REACT_UPDATE_OP } from './constants';
1010

1111
export 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-
7313
export 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

Comments
 (0)