Skip to content

Commit 43cea28

Browse files
committed
feat(vue/v8): Remove all deprecated exports from vue
1 parent 81a5b4f commit 43cea28

File tree

5 files changed

+40
-360
lines changed

5 files changed

+40
-360
lines changed

packages/vue/src/index.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
export * from '@sentry/browser';
22

33
export { init } from './sdk';
4-
// eslint-disable-next-line deprecation/deprecation
5-
export { vueRouterInstrumentation } from './router';
64
export { browserTracingIntegration } from './browserTracingIntegration';
75
export { attachErrorHandler } from './errorhandler';
86
export { createTracingMixins } from './tracing';
9-
export {
10-
vueIntegration,
11-
// eslint-disable-next-line deprecation/deprecation
12-
VueIntegration,
13-
} from './integration';
7+
export { vueIntegration } from './integration';

packages/vue/src/integration.ts

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { convertIntegrationFnToClass, defineIntegration, hasTracingEnabled } from '@sentry/core';
2-
import type { Client, Integration, IntegrationClass, IntegrationFn } from '@sentry/types';
1+
import { defineIntegration, hasTracingEnabled } from '@sentry/core';
2+
import type { Client, IntegrationFn } from '@sentry/types';
33
import { GLOBAL_OBJ, arrayify, consoleSandbox } from '@sentry/utils';
44

55
import { DEFAULT_HOOKS } from './constants';
6+
import { DEBUG_BUILD } from './debug-build';
67
import { attachErrorHandler } from './errorhandler';
78
import { createTracingMixins } from './tracing';
89
import type { Options, Vue, VueOptions } from './types';
@@ -33,17 +34,6 @@ const _vueIntegration = ((integrationOptions: Partial<VueOptions> = {}) => {
3334

3435
export const vueIntegration = defineIntegration(_vueIntegration);
3536

36-
/**
37-
* Initialize Vue error & performance tracking.
38-
*
39-
* @deprecated Use `vueIntegration()` instead.
40-
*/
41-
// eslint-disable-next-line deprecation/deprecation
42-
export const VueIntegration = convertIntegrationFnToClass(
43-
INTEGRATION_NAME,
44-
vueIntegration,
45-
) as IntegrationClass<Integration>;
46-
4737
function _setupIntegration(client: Client, integrationOptions: Partial<VueOptions>): void {
4838
const options: Options = { ...DEFAULT_CONFIG, ...client.getOptions(), ...integrationOptions };
4939
if (!options.Vue && !options.app) {
@@ -67,23 +57,25 @@ Update your \`Sentry.init\` call with an appropriate config option:
6757
}
6858

6959
const vueInit = (app: Vue, options: Options): void => {
70-
// Check app is not mounted yet - should be mounted _after_ init()!
71-
// This is _somewhat_ private, but in the case that this doesn't exist we simply ignore it
72-
// See: https://github.com/vuejs/core/blob/eb2a83283caa9de0a45881d860a3cbd9d0bdd279/packages/runtime-core/src/component.ts#L394
73-
const appWithInstance = app as Vue & {
74-
_instance?: {
75-
isMounted?: boolean;
60+
if (DEBUG_BUILD) {
61+
// Check app is not mounted yet - should be mounted _after_ init()!
62+
// This is _somewhat_ private, but in the case that this doesn't exist we simply ignore it
63+
// See: https://github.com/vuejs/core/blob/eb2a83283caa9de0a45881d860a3cbd9d0bdd279/packages/runtime-core/src/component.ts#L394
64+
const appWithInstance = app as Vue & {
65+
_instance?: {
66+
isMounted?: boolean;
67+
};
7668
};
77-
};
7869

79-
const isMounted = appWithInstance._instance && appWithInstance._instance.isMounted;
80-
if (isMounted === true) {
81-
consoleSandbox(() => {
82-
// eslint-disable-next-line no-console
83-
console.warn(
84-
'[@sentry/vue]: Misconfigured SDK. Vue app is already mounted. Make sure to call `app.mount()` after `Sentry.init()`.',
85-
);
86-
});
70+
const isMounted = appWithInstance._instance && appWithInstance._instance.isMounted;
71+
if (isMounted === true) {
72+
consoleSandbox(() => {
73+
// eslint-disable-next-line no-console
74+
console.warn(
75+
'[@sentry/vue]: Misconfigured SDK. Vue app is already mounted. Make sure to call `app.mount()` after `Sentry.init()`.',
76+
);
77+
});
78+
}
8779
}
8880

8981
attachErrorHandler(app, options);

packages/vue/src/router.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import { WINDOW, captureException } from '@sentry/browser';
2-
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, spanToJSON } from '@sentry/core';
2+
import {
3+
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
4+
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
5+
getActiveSpan,
6+
getRootSpan,
7+
spanToJSON,
8+
} from '@sentry/core';
39
import type { SpanAttributes, Transaction, TransactionContext, TransactionSource } from '@sentry/types';
410

5-
import { getActiveTransaction } from './tracing';
6-
711
interface VueRouterInstrumationOptions {
812
/**
913
* What to use for route labels.
@@ -139,17 +143,17 @@ export function instrumentVueRouter(
139143
}
140144

141145
if (options.instrumentPageLoad && isPageLoadNavigation) {
142-
// eslint-disable-next-line deprecation/deprecation
143-
const pageloadTransaction = getActiveTransaction();
144-
if (pageloadTransaction) {
145-
const existingAttributes = spanToJSON(pageloadTransaction).data || {};
146+
const activeSpan = getActiveSpan();
147+
const rootSpan = activeSpan && getRootSpan(activeSpan);
148+
if (rootSpan) {
149+
const existingAttributes = spanToJSON(rootSpan).data || {};
146150
if (existingAttributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] !== 'custom') {
147-
pageloadTransaction.updateName(transactionName);
148-
pageloadTransaction.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, transactionSource);
151+
rootSpan.updateName(transactionName);
152+
rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, transactionSource);
149153
}
150154
// Set router attributes on the existing pageload transaction
151-
// This will the origin, and add params & query attributes
152-
pageloadTransaction.setAttributes({
155+
// This will override the origin, and add params & query attributes
156+
rootSpan.setAttributes({
153157
...attributes,
154158
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.pageload.vue',
155159
});
@@ -158,6 +162,7 @@ export function instrumentVueRouter(
158162

159163
if (options.instrumentNavigation && !isPageLoadNavigation) {
160164
attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] = transactionSource;
165+
attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] = 'auto.navigation.vue';
161166
startNavigationSpanFn({
162167
name: transactionName,
163168
op: 'navigation',

packages/vue/src/tracing.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { getActiveSpan, getCurrentScope, startInactiveSpan } from '@sentry/browser';
2-
import type { Span, Transaction } from '@sentry/types';
1+
import { getActiveSpan, startInactiveSpan } from '@sentry/browser';
2+
import type { Span } from '@sentry/types';
33
import { logger, timestampInSeconds } from '@sentry/utils';
44

55
import { DEFAULT_HOOKS } from './constants';
@@ -32,16 +32,6 @@ const HOOKS: { [key in Operation]: Hook[] } = {
3232
update: ['beforeUpdate', 'updated'],
3333
};
3434

35-
/**
36-
* Grabs active transaction off scope.
37-
*
38-
* @deprecated You should not rely on the transaction, but just use `startSpan()` APIs instead.
39-
*/
40-
export function getActiveTransaction(): Transaction | undefined {
41-
// eslint-disable-next-line deprecation/deprecation
42-
return getCurrentScope().getTransaction();
43-
}
44-
4535
/** Finish top-level span and activity with a debounce configured using `timeout` option */
4636
function finishRootSpan(vm: VueSentry, timestamp: number, timeout: number): void {
4737
if (vm.$_sentryRootSpanTimer) {

0 commit comments

Comments
 (0)