Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(vue): Remove logError from vueIntegration #14958

Merged
merged 4 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test('sends an error', async ({ page }) => {
type: 'Error',
value: 'This is a Vue test error',
mechanism: {
type: 'generic',
type: 'vue',
handled: false,
},
},
Expand Down Expand Up @@ -47,7 +47,7 @@ test('sends an error with a parameterized transaction name', async ({ page }) =>
type: 'Error',
value: 'This is a Vue test error',
mechanism: {
type: 'generic',
type: 'vue',
handled: false,
},
},
Expand Down
6 changes: 6 additions & 0 deletions docs/migration/v8-to-v9.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ The following changes are unlikely to affect users of the SDK. They are listed h
});
```

- The option `logErrors` in the `vueIntegration` has been removed. The Sentry Vue error handler will propagate the error to a user-defined error handler
or just re-throw the error (which will log the error without modifying).

## 5. Build Changes

Previously the CJS versions of the SDK code (wrongfully) contained compatibility statements for default exports in ESM:
Expand Down Expand Up @@ -375,6 +378,9 @@ The Sentry metrics beta has ended and the metrics API has been removed from the
});
```

- Deprecated `logErrors` in the `vueIntegration`. The Sentry Vue error handler will propagate the error to a user-defined error handler
or just re-throw the error (which will log the error without modifying).

## `@sentry/nuxt` and `@sentry/vue`

- When component tracking is enabled, "update" spans are no longer created by default.
Expand Down
22 changes: 5 additions & 17 deletions packages/vue/src/errorhandler.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { captureException, consoleSandbox } from '@sentry/core';
import { captureException } from '@sentry/core';
import type { ViewModel, Vue, VueOptions } from './types';
import { formatComponentName, generateComponentTrace } from './vendor/components';

type UnknownFunc = (...args: unknown[]) => void;

export const attachErrorHandler = (app: Vue, options: VueOptions): void => {
const { errorHandler: originalErrorHandler, warnHandler, silent } = app.config;
const { errorHandler: originalErrorHandler } = app.config;

app.config.errorHandler = (error: Error, vm: ViewModel, lifecycleHook: string): void => {
const componentName = formatComponentName(vm, false);
Expand All @@ -30,27 +30,15 @@ export const attachErrorHandler = (app: Vue, options: VueOptions): void => {
setTimeout(() => {
captureException(error, {
captureContext: { contexts: { vue: metadata } },
mechanism: { handled: false },
mechanism: { handled: !!originalErrorHandler, type: 'vue' },
});
});

// Check if the current `app.config.errorHandler` is explicitly set by the user before calling it.
if (typeof originalErrorHandler === 'function' && app.config.errorHandler) {
(originalErrorHandler as UnknownFunc).call(app, error, vm, lifecycleHook);
}

if (options.logErrors) {
const hasConsole = typeof console !== 'undefined';
const message = `Error in ${lifecycleHook}: "${error?.toString()}"`;

if (warnHandler) {
(warnHandler as UnknownFunc).call(null, message, vm, trace);
} else if (hasConsole && !silent) {
consoleSandbox(() => {
// eslint-disable-next-line no-console
console.error(`[Vue warn]: ${message}${trace}`);
});
}
} else {
throw error;
}
};
};
1 change: 0 additions & 1 deletion packages/vue/src/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const globalWithVue = GLOBAL_OBJ as typeof GLOBAL_OBJ & { Vue: Vue };
const DEFAULT_CONFIG: VueOptions = {
Vue: globalWithVue.Vue,
attachProps: true,
logErrors: true,
attachErrorHandler: true,
tracingOptions: {
hooks: DEFAULT_HOOKS,
Expand Down
6 changes: 0 additions & 6 deletions packages/vue/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ export interface VueOptions {
*/
attachProps: boolean;

/**
* When set to `true`, original Vue's `logError` will be called as well.
* https://github.com/vuejs/vue/blob/c2b1cfe9ccd08835f2d99f6ce60f67b4de55187f/src/core/util/error.js#L38-L48
*/
logErrors: boolean;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there is an easy way to deprecate this in v8

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I deprecated it in this PR: #14943


/**
* By default, Sentry attaches an error handler to capture exceptions and report them to Sentry.
* When `attachErrorHandler` is set to `false`, automatic error reporting is disabled.
Expand Down
Loading
Loading