From bf67f18d4a56f4f42768cd0eb3103236cffd2d74 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Fri, 18 Nov 2022 10:15:08 +0100 Subject: [PATCH] feat(vue): Actually `console.warn` when not passing app/Vue --- packages/vue/src/sdk.ts | 14 +++++++------- packages/vue/test/integration/init.test.ts | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/packages/vue/src/sdk.ts b/packages/vue/src/sdk.ts index f6513676621c..a2063038402c 100644 --- a/packages/vue/src/sdk.ts +++ b/packages/vue/src/sdk.ts @@ -1,5 +1,5 @@ import { init as browserInit, SDK_VERSION } from '@sentry/browser'; -import { arrayify, GLOBAL_OBJ, logger } from '@sentry/utils'; +import { arrayify, GLOBAL_OBJ } from '@sentry/utils'; import { DEFAULT_HOOKS } from './constants'; import { attachErrorHandler } from './errorhandler'; @@ -43,12 +43,12 @@ export function init( browserInit(options); if (!options.Vue && !options.app) { - __DEBUG_BUILD__ && - logger.warn( - 'Misconfigured SDK. Vue specific errors will not be captured.\n' + - 'Update your `Sentry.init` call with an appropriate config option:\n' + - '`app` (Application Instance - Vue 3) or `Vue` (Vue Constructor - Vue 2).', - ); + // eslint-disable-next-line no-console + console.warn( + `[@sentry/vue]: Misconfigured SDK. Vue specific errors will not be captured. +Update your \`Sentry.init\` call with an appropriate config option: +\`app\` (Application Instance - Vue 3) or \`Vue\` (Vue Constructor - Vue 2).`, + ); return; } diff --git a/packages/vue/test/integration/init.test.ts b/packages/vue/test/integration/init.test.ts index 7723c92233ef..a9936c97bc89 100644 --- a/packages/vue/test/integration/init.test.ts +++ b/packages/vue/test/integration/init.test.ts @@ -71,4 +71,23 @@ describe('Sentry.init', () => { '[@sentry/vue]: Misconfigured SDK. Vue app is already mounted. Make sure to call `app.mount()` after `Sentry.init()`.', ]); }); + + it('warns when not passing app & Vue', () => { + const el = document.createElement('div'); + const app = createApp({ + template: '
hello
', + }); + + Sentry.init({ + defaultIntegrations: false, + }); + + app.mount(el); + + expect(warnings).toEqual([ + `[@sentry/vue]: Misconfigured SDK. Vue specific errors will not be captured. +Update your \`Sentry.init\` call with an appropriate config option: +\`app\` (Application Instance - Vue 3) or \`Vue\` (Vue Constructor - Vue 2).`, + ]); + }); });