Skip to content

Commit 888b05a

Browse files
andreiborzas1gr1d
andauthored
feat(vue)!: Remove configuring Vue tracing options anywhere else other than through the vueIntegration's tracingOptions option (#14856)
Deprecation PR: #14265 Closes: #5907 --------- Co-authored-by: Sigrid Huemer <[email protected]>
1 parent 9cd0e8e commit 888b05a

File tree

6 files changed

+38
-81
lines changed

6 files changed

+38
-81
lines changed

dev-packages/e2e-tests/test-applications/vue-3/src/main.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import router from './router';
77
import { createPinia } from 'pinia';
88

99
import * as Sentry from '@sentry/vue';
10-
import { browserTracingIntegration } from '@sentry/vue';
10+
import { browserTracingIntegration, vueIntegration } from '@sentry/vue';
1111

1212
const app = createApp(App);
1313
const pinia = createPinia();
@@ -17,12 +17,16 @@ Sentry.init({
1717
dsn: import.meta.env.PUBLIC_E2E_TEST_DSN,
1818
tracesSampleRate: 1.0,
1919
integrations: [
20+
vueIntegration({
21+
tracingOptions: {
22+
trackComponents: ['ComponentMainView', '<ComponentOneView>'],
23+
},
24+
}),
2025
browserTracingIntegration({
2126
router,
2227
}),
2328
],
2429
tunnel: `http://localhost:3031/`, // proxy server
25-
trackComponents: ['ComponentMainView', '<ComponentOneView>'],
2630
});
2731

2832
pinia.use(

docs/migration/v8-to-v9.md

+21
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,27 @@ Sentry.init({
152152
Use the `SentryGlobalFilter` instead.
153153
The `SentryGlobalFilter` is a drop-in replacement.
154154

155+
## `@sentry/vue`
156+
157+
- The options `tracingOptions`, `trackComponents`, `timeout`, `hooks` have been removed everywhere except in the `tracingOptions` option of `vueIntegration()`.
158+
These options should now be set as follows:
159+
160+
```ts
161+
import * as Sentry from '@sentry/vue';
162+
163+
Sentry.init({
164+
integrations: [
165+
Sentry.vueIntegration({
166+
tracingOptions: {
167+
trackComponents: true,
168+
timeout: 1000,
169+
hooks: ['mount', 'update', 'unmount'],
170+
},
171+
}),
172+
],
173+
});
174+
```
175+
155176
## 5. Build Changes
156177

157178
Previously the CJS versions of the SDK code (wrongfully) contained compatibility statements for default exports in ESM:

packages/vue/src/integration.ts

+6-10
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ const DEFAULT_CONFIG: VueOptions = {
1212
attachProps: true,
1313
logErrors: true,
1414
attachErrorHandler: true,
15-
hooks: DEFAULT_HOOKS,
16-
timeout: 2000,
17-
trackComponents: false,
15+
tracingOptions: {
16+
hooks: DEFAULT_HOOKS,
17+
timeout: 2000,
18+
trackComponents: false,
19+
},
1820
};
1921

2022
const INTEGRATION_NAME = 'Vue';
@@ -73,12 +75,6 @@ const vueInit = (app: Vue, options: Options): void => {
7375
}
7476

7577
if (hasTracingEnabled(options)) {
76-
app.mixin(
77-
createTracingMixins({
78-
...options,
79-
// eslint-disable-next-line deprecation/deprecation
80-
...options.tracingOptions,
81-
}),
82-
);
78+
app.mixin(createTracingMixins(options.tracingOptions));
8379
}
8480
};

packages/vue/src/sdk.ts

+2-11
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,12 @@ import { SDK_VERSION, getDefaultIntegrations, init as browserInit } from '@sentr
22

33
import type { Client } from '@sentry/core';
44
import { vueIntegration } from './integration';
5-
import type { Options, TracingOptions } from './types';
5+
import type { Options } from './types';
66

77
/**
88
* Inits the Vue SDK
99
*/
10-
export function init(
11-
config: Partial<
12-
Omit<Options, 'tracingOptions'> & {
13-
/**
14-
* @deprecated Add the `vueIntegration()` and pass the `tracingOptions` there instead.
15-
*/
16-
tracingOptions: Partial<TracingOptions>;
17-
}
18-
> = {},
19-
): Client | undefined {
10+
export function init(config: Partial<Omit<Options, 'tracingOptions'>> = {}): Client | undefined {
2011
const options = {
2112
_metadata: {
2213
sdk: {

packages/vue/src/tracing.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export function findTrackComponent(trackComponents: string[], formattedName: str
5959
return isMatched;
6060
}
6161

62-
export const createTracingMixins = (options: TracingOptions): Mixins => {
62+
export const createTracingMixins = (options: Partial<TracingOptions> = {}): Mixins => {
6363
const hooks = (options.hooks || [])
6464
.concat(DEFAULT_HOOKS)
6565
// Removing potential duplicates
@@ -138,7 +138,7 @@ export const createTracingMixins = (options: TracingOptions): Mixins => {
138138
if (!span) return;
139139
span.end();
140140

141-
finishRootSpan(this, timestampInSeconds(), options.timeout);
141+
finishRootSpan(this, timestampInSeconds(), options.timeout || 2000);
142142
}
143143
};
144144
}

packages/vue/src/types.ts

+1-56
Original file line numberDiff line numberDiff line change
@@ -60,64 +60,9 @@ export interface VueOptions {
6060

6161
/** {@link TracingOptions} */
6262
tracingOptions?: Partial<TracingOptions>;
63-
64-
/**
65-
* Decides whether to track components by hooking into its lifecycle methods.
66-
* Can be either set to `boolean` to enable/disable tracking for all of them.
67-
* Or to an array of specific component names (case-sensitive).
68-
*
69-
* @deprecated Use tracingOptions
70-
*/
71-
trackComponents: boolean | string[];
72-
73-
/**
74-
* How long to wait until the tracked root activity is marked as finished and sent of to Sentry
75-
*
76-
* @deprecated Use tracingOptions
77-
*/
78-
timeout: number;
79-
80-
/**
81-
* List of hooks to keep track of during component lifecycle.
82-
* Available hooks: 'activate' | 'create' | 'destroy' | 'mount' | 'unmount' | 'update'
83-
* Based on https://vuejs.org/v2/api/#Options-Lifecycle-Hooks
84-
*
85-
* @deprecated Use tracingOptions
86-
*/
87-
hooks: Operation[];
8863
}
8964

90-
export interface Options extends BrowserOptions, VueOptions {
91-
/**
92-
* @deprecated Use `vueIntegration` tracingOptions
93-
*/
94-
tracingOptions?: Partial<TracingOptions>;
95-
96-
/**
97-
* Decides whether to track components by hooking into its lifecycle methods.
98-
* Can be either set to `boolean` to enable/disable tracking for all of them.
99-
* Or to an array of specific component names (case-sensitive).
100-
*
101-
* @deprecated Use `vueIntegration` tracingOptions
102-
*/
103-
trackComponents: boolean | string[];
104-
105-
/**
106-
* How long to wait until the tracked root activity is marked as finished and sent of to Sentry
107-
*
108-
* @deprecated Use `vueIntegration` tracingOptions
109-
*/
110-
timeout: number;
111-
112-
/**
113-
* List of hooks to keep track of during component lifecycle.
114-
* Available hooks: 'activate' | 'create' | 'destroy' | 'mount' | 'unmount' | 'update'
115-
* Based on https://vuejs.org/v2/api/#Options-Lifecycle-Hooks
116-
*
117-
* @deprecated Use `vueIntegration` tracingOptions
118-
*/
119-
hooks: Operation[];
120-
}
65+
export type Options = BrowserOptions & VueOptions;
12166

12267
/** Vue specific configuration for Tracing Integration */
12368
export interface TracingOptions {

0 commit comments

Comments
 (0)